Open-Source Multimodal LLM Architecture Evolution and On-Device Inference Adaptation Practices

    This article examines the architectural evolution of a new open-source multimodal large language model family, focusing on three key mechanisms: PLE (per-layer embedding), cross-layer KV sharing, and heterogeneous KV heads with K=V merging. It provides practical guidance for inference engine adaptation, export strategies, and deployment decisions across device tiers, from mobile to desktop-scale models.

    Introduction: Background and Core Challenges

    As multimodal large language models (LLMs) gradually shift from cloud to on-device deployment, the pace of architectural innovation has accelerated significantly. The latest generation of open-source LLM families offers multiple model sizes, ranging from lightweight on-device variants to desktop-scale configurations, covering smartphones, tablets, laptops, and servers. Notably, these variants are not simple parameter scaling; they employ differentiated combinations of architectural mechanisms, which introduces multiple challenges for inference engine adaptation.

    Specifically, different model sizes exhibit significant differences in attention mechanisms, embedding layer design, KV cache management, vision encoders, and mixture-of-experts (MoE) structures. For an inference engine, failing to cover these variations with a unified abstraction layer would require per-operator special-casing, leading to sharply increased development costs and maintenance burdens. This article focuses on the adaptation practices for this model family, dissecting three mechanisms of high engineering value: per-layer embedding (PLE), cross-layer KV sharing, and native multimodal support, along with actionable export and deployment recommendations.

    Architectural Evolution: From the Previous Generation to the Current Version

    To understand the architectural choices of the new generation, it is necessary to trace the evolution path. Between the previous generation and the current version, there exists a key transitional version. That transitional version was a multimodal model specifically designed for on-device use, and it first introduced mechanisms such as PLE and KV sharing. The current version inherits these mechanisms and expands them systematically.

    The following table compares the architectural characteristics across the three generations:

    Feature Dimension Previous Generation Transitional Version Current Version
    Attention Mechanism Hybrid attention Hybrid attention Hybrid attention (with alternating upsampling)
    KV Cache Independent per layer KV sharing (across 10 layers) KV sharing (across 18–20 layers)
    Embedding Shared embedding PLE (table lookup direct injection) PLE (table lookup + projection fusion)
    QKV Normalization Q/K normalization Q/K/V normalization Q/K/V normalization + attn_scale=1.0
    V Projection Independent v_proj Independent v_proj K=V merged in some sizes
    KV Heads Uniform Uniform Heterogeneous KV heads
    Vision Encoder SigLIP ViT MobileNetV5 SigLIP ViT + Pooler
    Audio Support None Conformer Streaming USM Conformer
    MoE None None ~24B activation: 128 experts / Top-8
    Exclusive Mechanisms — Alternating upsampling, structured sparsity K=V merging, heterogeneous KV heads, dual RoPE

    From the table, several clear evolutionary lines emerge:

    First, the on-device design genes are inherited and strengthened. PLE and KV sharing were initially designed for on-device inference in the transitional version and have been preserved and expanded in the current version—the KV sharing span increases from 10 layers to 18–20 layers, confirming that the mechanism brings verified benefits in memory savings and access locality improvements.

    Second, attention mechanisms are more finely split. The evolution from Q/K normalization to Q/K/V triple normalization implies higher numerical stability requirements; some sizes introduce K=V sharing, representing a new trade-off between capacity loss and inference speedup.

    Third, heterogeneous multi-head designs are introduced. Different attention heads use different KV head configurations, breaking the previous convention of uniform KV heads. This imposes new requirements on the inference engine’s kernel selection strategy—a single operator must simultaneously support multiple sets of head configurations.

    Deep Dive into Distinctive Mechanisms and Engineering Adaptation

    Per-Layer Embedding (PLE): From Direct Table Lookup to Table Lookup + Projection Fusion

    In the traditional Transformer architecture, input tokens first go through an embedding table to obtain vectors, which are then passed through a projection matrix before entering the first layer. The PLE mechanism changes this flow: each layer (or a group of layers) maintains its own embedding table. The model input, in the form of discrete token IDs, is directly injected into deeper layers, where the layer’s embedding table performs the lookup and projection, achieving a “progressive refinement with depth” effect.

    In the transitional version, PLE was a pure table lookup direct injection method—each layer’s embedding table was independent, and the output directly served as the input to that layer’s attention. The current version further evolves this into “table lookup + projection fusion”: after lookup, each layer’s embedding vectors pass through a lightweight projection matrix before attention computation. This change maintains on-device deployment friendliness while improving model capacity utilization.

    Inference engine adaptation points:

    • The multiple independent embedding tables should be treated as a “multi-input lookup” operation rather than a single embedding operator.
    • For projection fusion, avoid per-layer matrix multiplication kernel launch overhead; consider fusing multiple small projections into batched GEMM operations.
    • On-device deployment must account for the additional memory overhead of multiple embedding tables. A rough rule of thumb: embedding tables account for approximately 8% to 12% of total model parameters, which is acceptable for a 4B-scale model.

    Cross-Layer KV Sharing: A Win-Win for Memory Savings and Access Locality

    The KV cache is the most memory-access-intensive structure in autoregressive generation. Traditional approaches store KV independently per layer, with memory usage growing linearly with the number of layers. Cross-layer KV sharing allows adjacent layers to reuse the same set of KV tensors, compressing the total KV cache size to the ratio of “total layers / sharing span.”

    In the current version, the KV sharing span reaches 18–20 layers. For a 30B-scale model, this reduces KV cache memory usage by approximately 40% to 50% compared to per-layer independence. For on-device inference, this directly determines whether long-context generation tasks can run within a phone’s memory budget.

    However, a key engineering issue arises: the attention normalization method for shared KV layers. If K/V normalization is still applied on top of shared KV, the inference engine must ensure that all shared layers use the same normalized KV, rather than normalizing independently for each layer—otherwise the sharing semantics are broken, and output quality degrades noticeably. In MNN’s implementation, shared storage with reference counting is used to manage the normalized KV tensors, ensuring consistent read paths across layers.

    Heterogeneous KV Heads and K=V Merging: New Frontiers for Operator Fusion

    The current version makes aggressive changes to multi-head attention. Traditional MHA/MQA/GQA assume all attention heads share the same KV head configuration, but the current version’s some sizes adopt heterogeneous KV heads: different attention head groups use different numbers of KV heads. This means the attention operator internally must support dynamic head mapping, which cannot be statically determined at compile time; the computation graph must be constructed at runtime based on the configuration.

    Furthermore, some sizes merge K and V into a single tensor, i.e., K=V. Mathematically, this is equivalent to using a symmetric key-value projection for attention scores, but it does not change attention computational complexity. However, it eliminates one projection matrix’s storage and computation. For a 30B-scale model, removing the independent v_proj can reduce parameter count and corresponding computation by approximately 4% to 6%.

    Measured data observations: MNN compared performance before and after importing K=V merging on a desktop-scale configuration (approximately 30B parameters, long-context scenarios). The results show that in streaming generation with batch size 1, single-token generation latency decreased by about 8% to 11%, memory usage dropped by about 5%; in offline preprocessing with high batch size, throughput increased by about 4%. This indicates that K=V merging brings significantly more benefit to memory-bound scenarios than to compute-bound scenarios.

    Dual RoPE Position Encoding: An Advanced Solution for Long-Context Extrapolation

    The current version introduces dual RoPE in some sizes, where independent position encoding parameters are configured for self-attention and cross-attention. The primary motivation is that the model needs to process both text sequences and image token sequences simultaneously; the length distributions and positional semantics differ significantly between them. Sharing the same RoPE base frequency would limit extrapolation ability.

    The engineering challenge lies in the fact that dual RoPE requires the inference engine to apply rotation matrices with different frequencies to Q/K before attention computation. Additionally, the concatenation order of visual tokens and text tokens (e.g., prepended or interleaved) affects the computation of position index offsets. MNN’s adaptation approach: during the export phase, the frequency vectors for rotary position encoding are treated as constant inputs; at runtime, the position index offsets are dynamically computed based on the modality segmentation points in the input sequence, avoiding the need to separately compile kernels for each modality.

    Three-Layer Architecture for Native Multimodal Support

    The current version’s multimodal support can be divided into three layers, a layered design that offers valuable lessons.

    Layer 1: Vision encoding and pooling. The vision encoder still uses the SigLIP ViT structure but adds a new pooling module—this module compresses the dense feature sequence output by ViT into fewer visual tokens, reducing computational and storage overhead on the vision side. For on-device deployment, the number of visual tokens directly affects the KV cache size in cross-attention layers. The pooling module can reduce visual tokens by approximately 60% to 70% while preserving visual semantic integrity.

    Layer 2: Streaming audio understanding. The audio encoder adopts a streaming USM Conformer structure, supporting streaming audio input rather than whole-utterance offline processing, which is critical for voice interaction scenarios. The inference engine must simultaneously maintain the streaming state of the audio encoder and the state of the language model; the synchronization mechanism between the two involves certain engineering complexity.

    Layer 3: Cross-modal fusion. Text, image, and audio modalities undergo cross-attention fusion in the deep layers of the language model. It is important to note that the embedding dimensions of different modalities are not identical; they must be aligned to a unified dimension via projection layers before fusion. This means the exported graph contains multiple modality-specific pre-projection operators, which the inference engine needs to identify and combine into a fused subgraph for holistic optimization.

    Key Processing Strategies in the Export Pipeline

    Based on the adaptation experience in this work, the following strategies have general reference value for bringing large models to on-device deployment:

    1. Operator fusion before new operator introduction. Most new architectural mechanisms can be implemented through combination and fusion of existing operators, rather than requiring new low-level operators. For example, heterogeneous KV heads can be implemented by adding lightweight “remap + slice” logic, without modifying the main attention kernel.

    2. Constant folding and static shape derivation. Because large-model export graphs are huge, all non-constant but statically computable nodes—such as RoPE frequency vectors, attention mask matrices, and pooling parameters—should be folded offline to reduce runtime overhead.

    3. Template-based handling of multiple model configurations. Abstract the differences between model sizes into configuration files rather than maintaining separate source code for each size. In this adaptation, four sizes share the same inference code, differing only through configuration.

    4. Global memory planning. KV sharing and K=V merging complicate tensor lifecycles and memory reuse relationships. The inference engine should adopt a memory planning strategy based on the global computation graph rather than per-operator allocation and deallocation.

    Deployment Recommendations

    Based on test data and adaptation experience, the following deployment suggestions are offered:

    • On-device lightweight size (approximately 2B) suits memory-constrained devices such as phones. Enable KV sharing and PLE in the export. First-token latency can be kept within interactive ranges, and long-context memory usage is approximately 60% of a traditional architecture.

    • Desktop-scale size (approximately 30B) suits laptops or small workstations with discrete GPUs or unified memory architectures. Prioritize K=V merging and KV sharing; these yield an 8% to 11% generation latency reduction without significant quality loss.

    • In multimodal scenarios, leverage the pooling module to reduce the number of visual tokens. This is the most cost-effective step for optimizing cross-modal inference.

    • For streaming audio scenarios, pay attention to the state synchronization overhead between the encoder and the language model. Pre-test the impact of different audio chunk sizes (e.g., 1s, 2s, 5s) on end-to-end latency.

    Outlook

    This model family demonstrates several frontier directions for on-device and desktop-scale multimodal inference: more aggressive KV compression strategies, finer-grained attention head configurations, and more flexible multimodal encoder combinations. These mechanisms will further raise the abstraction ceiling of inference engines. For developers, understanding the evolutionary direction of model architectures holds more long-term value than chasing any single optimization technique. In the future, the competitiveness of on-device inference engines will be reflected in their adaptability to “architectural diversity”—the model of “one architecture, one solution” is unsustainable. A unified abstraction driven by offline configurations will become the mainstream approach.