On-Device LLM Architecture Evolution and Inference Engine Adaptation: PLE, KV Cache Sharing, and Multimodal Support
This article examines how a recent open-source LLM family’s evolving architectures affect on-device inference engine adaptation. It focuses on three representative mechanisms—Per-Layer Embedding (PLE), cross-layer KV cache sharing, and multimodal support—and summarizes practical export, validation, benchmarking, and quantization workflows for deploying models across different size classes.
1. Background: Adaptation Challenges from Architectural Innovation
A recent open-source LLM family has released its latest generation, spanning on-device small models with several billion parameters to desktop-class and server-class models with tens of billions of parameters, forming a complete size gradient. Notably, these specifications are not simply parameter-count scaling. They combine different architectural mechanisms across attention structure, cache organization, embedding methods, and other dimensions.
This creates a practical challenge for inference engines: a single inference framework must support multiple differentiated computation graph structures without breaking the core execution path. Using the adaptation process of a mainstream on-device inference engine as a thread, this article focuses on three of the most representative mechanisms: Per-Layer Embedding (PLE), cross-layer KV cache sharing, and multimodal support. It also shares practical experience in export and evaluation.
2. Architecture Evolution: Technical Paths Across Three Generations
The model family’s evolution was not completed in a single step. The base version established a hybrid attention backbone with alternating local sliding-window attention and global attention. A subsequent on-device-specific version first introduced mechanisms such as PLE and KV sharing. The latest generation extends and deepens these mechanisms on that foundation. The differences can be summarized across the following dimensions:
1. KV cache organization. The base version maintains an independent KV cache per layer. The on-device version begins to share KV across several layers (about 10 layers). The latest generation expands the sharing range to 18–20 layers. The benefit of KV sharing is direct: during long-sequence inference, memory usage decreases roughly proportionally, which is significant for memory-constrained on-device devices.
2. Embedding injection method. Traditionally, vocabulary embeddings are looked up only once at the input layer. Per-Layer Embedding (PLE) allows intermediate layers to fetch vectors from the embedding table on demand. The on-device version uses “direct lookup injection,” while the latest generation changes to “lookup + projection fusion.” In the latter, the fetched vector is fused with the hidden state through a projection matrix. This improves expressiveness but adds one more layer of computation.
3. Normalization and scaling details. The design evolves from normalizing only Q/K to normalizing Q/K/V, and the attention scaling coefficient is fixed at 1.0. Although these details are small, they directly affect numerical stability. During adaptation, retaining the old default 1/sqrt(d) scaling would cause output deviations.
4. Heterogeneous projection structures. In some model specifications, K and V share the same projection (that is, K=V, with no independent V projection). The number of KV heads also becomes non-uniform across layers (heterogeneous KV heads), and dual RoPE frequency configurations are introduced. These designs further reduce parameter count and cache overhead, but they require the inference engine’s attention operators to offer sufficient parameterization.
5. Multimodal and MoE. On the vision side, the design moves from a lightweight convolutional network back to a classic ViT encoder and adds a Pooler to compress the number of visual tokens. On the audio side, it uses an upgraded Conformer encoder. The largest specification also introduces a MoE structure with 128 experts and Top-8 routing, with about 4B active parameters, balancing quality and inference cost.
3. Key Adaptation Points for Three Core Mechanisms
3.1 Per-Layer Embedding (PLE)
The essence of PLE is to turn the embedding table from a “one-time input” into “repeatedly readable external memory.” There are two key implementation points:
- The embedding table must remain resident and accessible. The embedding layer can no longer be treated as the first graph operator and released after execution. It must serve as a global weight referenced by multiple intermediate layers.
- Index sources must be aligned. The token IDs and sequence positions used for intermediate-layer lookups must remain consistent with the input. In particular, during incremental decoding (decode), index misalignment caused by KV truncation must be avoided.
It is recommended to model PLE as an independent subgraph of “lookup + projection + residual fusion,” and to control the layers where it takes effect through configuration rather than hardcoding it into the attention module.
3.2 KV Cache Sharing
KV sharing means that multiple attention layers read and write the same KV cache. The core adaptation work includes:
- Fewer cache allocation layers. Allocate cache by sharing group rather than by layer count. Memory usage can drop by more than 40%.
- Clear write ownership. Within each sharing group, only one “primary layer” performs KV append operations; the other layers are read-only. This avoids duplicate writes.
- Consistent sliding-window logic. Under hybrid attention, when local layers use sliding-window truncation and global layers share the cache, confirm that the truncation strategy does not cause out-of-bounds reads due to sharing.
3.3 Multimodal Support
The integration of vision and audio encoders centers on spatial alignment between modality embeddings and text embeddings. Features output by the encoders must be mapped to the language model’s hidden dimension through a projection layer and filled back into the input sequence at placeholder token positions. The Pooler makes the number of visual tokens dynamic, so the inference engine must support variable-length concatenation rather than fixed-shape assumptions. From an engineering perspective, it is recommended to export modality encoders as independent submodels, with the main model receiving already aligned embeddings to reduce coupling.
4. Export and Evaluation Practices
A complete adaptation workflow is recommended as follows:
- Weight conversion: Unify weight naming and layout. Pay special attention to missing V projection weights in K=V specifications; these need to be mapped or marked in the export script.
- Layer-by-layer accuracy validation: Use the per-layer outputs of the reference implementation as a baseline to locate sources of numerical deviation. Common issues include RoPE frequency configuration and attention scaling coefficients.
- End-to-end metric evaluation: Cover three core metrics: first-token latency (prefill speed), per-token decode speed, and peak memory. Test them separately with text-only and multimodal inputs.
- Quantization validation: Repeat the above workflow for 4-bit and 8-bit quantized versions, confirming that PLE lookup and KV sharing do not show obvious accuracy degradation at low precision.
For teams that want to start validation quickly, cloud compute can be used to complete export and benchmark testing of large models. Model artifacts can then be managed with object storage, and evaluation tasks can be orchestrated through a container platform to form a reproducible CI workflow.
5. Summary and Recommendations
The architectural evolution of this generation of on-device models sends a clear signal: efficiency optimization is moving from “generic scaling” to “structured customization.” Mechanisms such as KV sharing, K=V, heterogeneous KV heads, and PLE are essentially fine-grained trade-offs among memory, parameter count, and expressiveness. For inference engine developers, the response is to improve operator parameterization and composability, replacing hardcoding with configuration-driven design. For application developers, model selection should first evaluate the benefits of KV sharing against the target device’s memory budget, and then decide on the model specification. The co-evolution of architectural innovation and inference frameworks will remain a central theme in on-device LLM deployment.
