On-Device Open LLM Architecture Evolution and Inference Engine Adaptation

    This article examines how the latest open LLM family has shifted from parameter scaling to mechanism composition across 2B–30B size classes, and what this means for inference engine adaptation. It breaks down Per-Layer Embeddings, cross-layer KV cache sharing, and native multimodal support, then outlines a practical adaptation path covering weight parsing, validation, quantization, memory planning, and benchmarking. It also provides deployment guidance for matching model size to use cases and using general cloud infrastructure for elastic inference.

    1. Background: Model Specs Are No Longer Simple Parameter Scaling

    In recent years, competition in on-device and lightweight open LLMs has shifted from parameter scale to architecture innovation density. The latest open model family typically includes four size classes ranging from 2B to 30B, covering all compute tiers from phones and tablets to desktop workstations and servers. Notably, these size classes are not simple scalings of layer count and width; they combine different architecture mechanisms. Smaller models emphasize activation sparsity and lookup-table acceleration, medium models emphasize KV compression and hybrid attention, and larger models introduce mixture-of-experts (MoE) and heterogeneous attention head designs.

    For inference engine developers, this means adaptation is no longer about writing one set of operators and running all size classes. Each size class has its own mechanism switches that must be handled separately. Based on adaptation practices from a production inference framework, this article breaks down three representative mechanisms: Per-Layer Embeddings (PLE), cross-layer KV cache sharing, and native multimodal support. It also provides a complete engineering path from model export to on-device evaluation.

    2. Architecture Evolution: From Basic Attention to Combined Mechanism Innovation

    To understand this generation of models, it helps to first look at how they differ from the previous two generations. The evolution can be summarized along three main lines:

    1. Tighter attention and normalization strategies. Early models normalized only Q and K. The new generation generally extends normalization to Q, K, and V, and fixes the attention scaling factor at 1.0 to improve training stability and low-bit quantization friendliness. Some size classes even remove the independent V projection matrix and let K and V share weights, directly cutting nearly a quarter of the KV-related parameter count.

    2. KV Cache moves from per-layer independence to cross-layer sharing. Previous on-device specialized versions already tried sharing KV across around 10 layers. The new generation expands the sharing range to 18–20 layers, meaning deeper layers no longer maintain independent key-value caches and instead reuse KV representations from shallower layers. The benefit is a near-linear reduction in memory usage, which significantly relieves the memory wall in long-context inference. The cost is that hybrid attention with alternating global and local attention is needed to compensate for the loss in representational capacity.

    3. Embeddings move from single-table sharing to layered injection. The traditional approach shares one token embedding table across all layers and performs lookup only in the first layer. The new mechanism allows several intermediate layers to directly look up prior token representations and then fuse them with hidden states. On-device versions mostly use direct lookup injection. The new generation evolves this into lookup plus small projection fusion, using a very small parameter cost to give deeper layers continuous awareness of token identity information.

    In addition, the vision encoder returns to a ViT-like structure with a pooler, the audio side uses an improved Conformer encoder, and flagship size classes introduce MoE layers with 128 experts and Top-8 routing. Unique designs such as heterogeneous KV head counts and dual RoPE frequency configurations also appear. The overall trend is that architecture innovation has moved down into every submodule, and the inference side must provide highly configurable operator composition.

    3. Core Mechanisms and Engineering Impact

    3.1 Per-Layer Embeddings (PLE)

    Design motivation: As layers deepen, hidden states become increasingly dominated by semantic representations, and the discrete identity information of the token itself is diluted. This clearly affects instruction following and factual recall in smaller models. PLE directly adds token embeddings, or their low-rank projections, back into hidden states at specified layers, effectively injecting an “original input reminder” into deeper layers.

    Engineering impact:

    • The inference flow must retain token IDs until the last injection layer; it cannot perform only first-layer embedding.
    • Each injection is a gather plus a small matrix projection plus an elementwise add. The computation is tiny, but it breaks the regular inter-layer pipeline, so the operator scheduling layer must support “in-layer side inputs.”
    • During quantization, projection matrices should retain higher precision, such as 8-bit rather than 4-bit. Otherwise, the signal-to-noise ratio of the injected signal drops noticeably.

    Illustrative pseudocode:

    1. hidden = embed(token_ids)
    2. for i, layer in enumerate(layers):
    3. hidden = layer(hidden, kv_cache)
    4. if i in ple_layers: # Per-Layer Embedding injection point
    5. hidden = hidden + ple_proj[i](embed_table[token_ids])

    3.2 Cross-Layer KV Cache Sharing

    Design motivation: The first bottleneck in on-device inference is memory bandwidth rather than compute, and KV Cache grows linearly with context length. Experiments show that deep-layer KV is highly correlated with shallow-layer KV. Therefore, letting a group of deep layers share the same KV can compress the total cache size by more than half.

    Engineering impact:

    • The cache layout changes from one block per layer to blocks by sharing group, and the memory allocator must support alias references.
    • During incremental decoding, only the owner layer of a sharing group performs KV writes, while other layers only read. Write dependencies must be marked during graph compilation.
    • When combined with local sliding-window attention, sliding-window trimming occurs only at the owner layer to avoid inconsistent trimming logic across multiple copies.

    3.3 Native Multimodal Support

    The new generation treats vision and audio encoders as first-class citizens: images are compressed by a ViT plus pooler into a fixed number of visual tokens, and audio is encoded by a Conformer and aligned to text positions according to frame rate. The key engineering point is a unified tokenization interface. All modalities are ultimately mapped to the same embedding space and positional encoding system, so text-side mechanisms such as hybrid attention, PLE, and KV sharing do not need special handling for modality branches. The inference framework only needs to add a pre-processing pipeline for image tiling and mel-spectrogram extraction, plus modality placeholder replacement logic.

    4. Complete Adaptation Path for Inference Engines

    Based on the mechanisms above, the recommended adaptation order is:

    1. Weight parsing and graph reconstruction. First implement a configuration-driven model description layer, turning switches such as “whether PLE is enabled,” “KV sharing group partitioning,” and “whether K=V” into boolean flags. Avoid hardcoding structures for each size class.
    2. Export and validation. Align intermediate outputs with the reference implementation layer by layer, including the first layer, injection layers, and final logits. An error threshold around 1e-3 is recommended before moving on to whole-sentence generation comparison.
    3. Quantization strategy. Use 8-bit for embeddings and PLE projections, and 4-bit for attention and FFN. MoE expert layers are more sensitive to quantization due to sparse activation, so per-layer sensitivity analysis should be performed before deciding the quantization level.
    4. Memory planning. Calculate the cache upper bound under long context based on KV sharing groups. On-device devices should evaluate the maximum supported context under a three-part budget: model weights, peak activations, and KV cache.
    5. Empirical evaluation. Cover at least four metrics: first-token latency, decoding throughput, long-context stability, and multimodal end-to-end latency. Compare against previous-generation models of similar parameter scale to verify whether the mechanism benefits are realized.

    5. Usage and Deployment Recommendations

    For application developers, model selection should follow the principle of “scenario defines size class”: 2B-level models are suitable for mobile summarization and offline assistants; 7B–12B models balance quality and desktop experience; 27B+ or MoE size classes are suitable for high-quality server-side generation. If elastic compute is required, general-purpose cloud services such as container platforms, object storage, and monitoring and alerting can be used to host model artifacts, provide elastic scaling, and enable online observability without maintaining the underlying infrastructure.

    Overall, the value of this generation of model family is not the performance numbers of any single size class, but the methodology it demonstrates: combining architecture mechanisms according to hardware constraints. For inference engine teams, abstracting mechanisms into configurable capabilities is the best way to cope with rapid future model iteration.