Per-Layer Embeddings: A Path to Memory-Efficient On-Device LLMs
Per-layer embeddings (PLE) offer a way to reduce accelerator memory requirements for on-device large language models by separating embedding parameters from core Transformer weights. This article explains the memory-tiering approach, its layer-specific signal paths, and how it works alongside KV cache optimization, activation quantization, and prefetching to support local inference on memory-constrained devices.
1. Why On-Device AI Needs Dedicated Memory Optimization
Deploying large language models on phones, tablets, and in-vehicle systems is often constrained more by memory than by compute. Cloud inference can rely on specialized accelerators with large amounts of dedicated memory. Mobile devices, by contrast, typically have only a few gigabytes available to their GPU or NPU, often within a unified memory pool shared with the operating system and applications.
Memory bandwidth is another critical constraint. Autoregressive inference is memory-intensive: generating each token generally requires reading the model’s weights again. Keeping all parameters in a bandwidth-constrained accelerator memory region can limit generation speed. Placing parameters in CPU-accessible main memory introduces a different challenge: coordinating storage, data movement, and computation.
Per-layer embeddings (PLE) address this tension by separating parameter capacity from the amount of memory that must remain resident on the accelerator. The goal is to let a larger model operate with an accelerator memory footprint closer to that of a smaller model.
With this type of tiered parameter management, 5B- and 8B-parameter models can have accelerator-resident footprints comparable to those of 2B- and 4B-parameter models, respectively. Combined with other optimizations, this approach can support local multimodal inference within a mobile memory budget below 2 GB. These figures describe the intended memory savings; they should not be interpreted as eliminating the need to store the remaining parameters elsewhere.
2. How PLE Works: Tiered Memory Management
2.1 Move Parameters That Do Not Need to Stay on the Accelerator
PLE uses a tiered memory management strategy, separating model parameters into two groups:
- Per-layer embedding parameters: Large embedding-related parameter sets associated with individual Transformer layers. Their relatively predictable access patterns allow them to reside in CPU-accessible main memory, where the CPU can handle lookup and related processing.
- Core Transformer weights: The weights used for the main Transformer computations. These remain resident in accelerator-accessible memory to provide low-latency access during frequent, compute-intensive operations.
This division takes advantage of heterogeneous mobile hardware. The CPU manages large parameter tables and their access patterns, while the GPU or NPU handles dense matrix operations.
On devices with unified memory, this is primarily a distinction in memory placement, residency, and access strategy—not necessarily a division between physically separate memory chips.
2.2 A Dedicated Low-Dimensional Signal for Each Layer
At the architectural level, PLE gives each Transformer layer its own low-dimensional signal path:
- Each token receives a layer-specific vector as it passes through the model.
- The resulting signal combines token-specific information with the current contextual representation.
- Because this signal path is much narrower than the model’s main hidden dimension, processing and transferring the selected vectors adds relatively little overhead.
- Each layer gains an additional way to adjust its representations without requiring the full embedding parameter set to remain on the accelerator.
The distinction between the parameter tables and the vectors retrieved from them matters: the embedding tables may contain many parameters, while the vectors needed for a particular inference step are small.
This design can be particularly useful for smaller models, whose representational capacity is limited. Lightweight, layer-specific signals provide additional capacity while keeping the accelerator-resident working set relatively small.
2.3 A Simplified Illustration
The following pseudocode illustrates the proposed memory layout and execution flow. It is conceptual rather than an executable implementation or a real API.
# Conceptual illustration, not a real APIclass LayerWithPLE(nn.Module):def __init__(self, hidden_dim, ple_dim):self.core_weights = load_to_accelerator(...) # Resident in accelerator memoryself.ple_params = load_to_cpu_memory(...) # Resident in CPU-accessible main memorydef forward(self, token_ids, context):ple_vec = generate_ple(token_ids, context) # Low-dimensional signalh = accelerator_matmul(self.core_weights, h) # Main computation on the acceleratorh = h + project(ple_vec) # Inject a layer-specific signalreturn h
During inference, CPU-side embedding parameters are accessed according to the layer execution schedule. The accelerator retains the core weights, and the two sides coordinate through the device’s memory and data-transfer paths to complete the forward pass.
3. Complementary Techniques for On-Device Inference
PLE is not a complete inference optimization strategy on its own. It is typically combined with other techniques that address dynamic memory use, intermediate tensors, and data-transfer overhead.
KV Cache Sharing and Optimization
Autoregressive generation caches the key and value states of previous tokens. As context length grows, this KV cache can become a substantial part of the inference memory footprint.
Cache sharing, compression, and memory management strategies can reduce peak dynamic memory use, complementing PLE’s focus on parameter placement.
Activation Quantization
Low-bit quantization of activations reduces the storage and memory traffic associated with intermediate tensors. The objective is to lower memory requirements while preserving model accuracy as much as possible.
On-Demand Loading and Prefetching
Parameters stored in CPU-accessible memory can be scheduled and prefetched according to the order in which layers execute. This helps hide data-access and transfer latency rather than leaving the accelerator waiting for each layer’s inputs.
Together, these techniques can improve time to first token and token generation speed while reducing memory consumption. They can also make local multimodal inference, including text and image inputs, feasible on devices that would otherwise lack sufficient available memory.
The overall benefit depends on how effectively parameter access, computation, and data movement are coordinated.
4. Implications for On-Device AI Deployment
From an engineering perspective, tiered parameter management offers three important lessons.
4.1 Model Architecture and Hardware Must Be Designed Together
An on-device model should not simply inherit the parameter layout of a cloud-oriented deployment. Its design needs to account for memory tiers, available bandwidth, and the execution characteristics of the CPU, GPU, and NPU.
Deciding which parameters belong in which memory region should be part of model and runtime design, rather than an optimization left until deployment.
4.2 Parameter Count Does Not Have to Determine Accelerator Memory Use
Structured parameter management can loosen the relationship between a model’s total parameter count and its accelerator-resident footprint.
The parameters still need storage, but they do not all need to occupy the fastest memory at the same time. This provides a practical path toward retaining model capacity within a constrained accelerator memory budget.
4.3 Offline-First Operation Remains a Core Benefit
Local inference can reduce network-dependent latency, improve privacy by keeping inputs on the device, and preserve functionality when connectivity is limited or unavailable.
Cloud infrastructure can still support the broader lifecycle. Object storage, container platforms, monitoring, and alerting can be used in a hybrid architecture that combines cloud-based training and management with on-device inference. The aim is to place each workload where it is most appropriate.
5. Conclusion
Per-layer embeddings illustrate a practical approach to on-device model optimization: instead of trying to keep every parameter in the fastest memory, organize parameter storage and computation around the hardware’s memory hierarchy.
For teams deploying large models on mobile and embedded devices, the important lesson is the combination of tiered parameter management, heterogeneous execution, and quantization. PLE addresses one part of the problem; KV cache optimization, activation quantization, and prefetching help complete the system.
As on-device models become more capable, designing for memory placement and bandwidth from the outset will become an increasingly important part of production AI engineering.
