Per-Layer Embeddings for On-Device LLMs: Where Layered Parameter Placement Reduces Memory Use
This article explains why memory often limits multimodal models on phones and IoT devices before compute does. It covers how Per-Layer Embeddings (PLE) keep embedding tables in host memory and Transformer weights on the accelerator, the parameter separation and pipeline scheduling steps, how KV Cache sharing and activation quantization work alongside PLE, a comparison of options, a pre-deployment checklist, and the risks and cases where PLE does not apply.
Why On-Device LLMs Run Out of Memory First
When multimodal models run on phones and IoT devices, memory often becomes the constraint before compute does. Three things mainly use memory: model weights, activations during inference, and the KV Cache, which grows with context length. Weights are usually the largest share, so reducing the size of the weights kept on an accelerator (GPU or NPU) is a common approach to on-device deployment.
Per-Layer Embeddings (PLE) target one type of parameter: embedding tables. These tables have a large vocabulary or feature dimension, but each inference step looks up only a small number of vectors, so they are accessed infrequently. The attention and feed-forward weights in Transformer layers take part in matrix multiplications on every step and are sensitive to bandwidth and latency. The two types of parameters have different access patterns, and that difference is the basis for PLE’s layered placement.
1. The Core Idea and Limits of PLE
PLE places parameters by access pattern. Lookup parameters go in host memory, which the CPU can access directly. Compute-heavy Transformer weights stay in accelerator memory. As a result, accelerator memory usage is determined mainly by the core compute layers.
PLE has clear limits. It is not a general “put all parameters on the CPU” approach. It depends on three conditions. First, the model architecture must define the embedding parameters so that each layer can query them independently. Second, the runtime must manage data transfers between the CPU and the accelerator. Third, supporting techniques such as quantization or sharding must keep the transfer volume under control. If any of these is missing, the gain may be small, or transfer overhead may make inference slower.
Publicly, Google’s documentation for the Gemma 3n model family describes a similar Per-Layer Embeddings design, and it names models by effective parameter count. For specific memory footprints and how to run the models, refer to the official model card and runtime documentation. This article does not cite unverified figures.
2. Separating Parameters and Scheduling the Pipeline
The implementation typically has two steps.
The first step is parameter separation. When the model loads, the runtime identifies the embedding tables and maps them into host memory. The Transformer block weights load into accelerator memory. Which weights go to which side depends on the export format of the specific model, so developers should follow the parameter distribution reported by the toolchain output.
The second step is pipeline scheduling. The CPU performs the lookup first and produces hidden states. It then passes the tensors to the accelerator for attention and feed-forward computation, and finally returns the results to the CPU for decoding. Ideally, the CPU prepares the next batch of data while the accelerator computes, which hides part of the transfer latency.
The code below shows only the scheduling order. It is conceptual pseudocode and cannot run as written. A real implementation also needs device initialization, asynchronous copies and synchronization points, fallback logic for when memory is insufficient, and error code handling.
# Conceptual pseudocode: shows the scheduling order only, not runnable as writtendef ple_forward_pass(input_ids, weights):# 1. Look up the embedding table on the CPU (parameters reside in host memory)hidden = cpu_lookup_embedding(input_ids, weights["per_layer_embedding"])# 2. Copy asynchronously to the accelerator; a sync point ensures the data is readyh_dev = async_copy_to_device(hidden)wait_for_copy(h_dev)# 3. Run the Transformer layers on the accelerator (weights reside in device memory)for layer_weights in weights["transformer_layers"]:h_dev = device_transformer_block(h_dev, layer_weights)# 4. Copy results back to the CPU; switch to an available execution path on failureh_host = async_copy_to_host(h_dev)wait_for_copy(h_host)return cpu_lm_head(h_host, weights["lm_head"])
3. How KV Cache Sharing and Activation Quantization Fit with PLE
In long-context and multi-turn conversations, the KV Cache grows quickly, and it counts toward memory separately from the weights. Two common techniques can work with PLE, but each has its own prerequisites.
KV Cache sharing means that multiple layers reuse the same Key and Value tensors, or share cache across layers when the model architecture allows it. This reduces the number of cache entries, so it changes the model structure. It is not automatic deduplication performed by the runtime, and it cannot simply be applied to any trained model. Whether it applies depends on whether the model was trained with that structure.
Activation quantization compresses intermediate activations during inference into low-bit formats, such as INT8 or FP8. It reduces activation memory and also lowers the amount of data transferred between the CPU and the accelerator. The main risk is accuracy. In layers with many outliers, compressed outputs may drift from the original model. Dynamic quantization also has to compute scales at inference time, which adds overhead.
Validate both techniques with data from the target task. Memory numbers alone do not show whether they work.
4. Comparing Options
| Approach | Main memory reduced | Main cost | Suitable scenario | Common failure mode |
|---|---|---|---|---|
| Full load to accelerator | None | Highest accelerator memory requirement | Devices with enough accelerator memory | Device runs out of memory and cannot load the model |
| PLE layered placement | Embedding parameters on the accelerator | Depends on model structure and runtime support; transfer latency | On-device models where embedding parameters make up a large share | Transfer overhead cancels the memory savings |
| Low-bit weight quantization | Weight size | Accuracy loss | Tasks that tolerate some accuracy loss | Accuracy drops on specific tasks |
| KV Cache sharing | Number of cache entries | Requires model architecture support | Long contexts, where the model already uses this structure | Insufficient cross-layer information; output quality drops |
| Activation quantization | Intermediate activations and transfer bandwidth | Accuracy loss and extra computation | Layers with relatively stable activation distributions | Outliers cause accuracy loss |
These options can be combined, but each added option increases validation work.
5. Pre-Deployment Checklist
- Confirm the accelerator memory available on the target device, and reserve memory for the operating system and other apps.
- Check whether the model uses PLE or an equivalent layered embedding structure, and review the official documentation.
- Record the quantization settings, including weight bit width, activation bit width, and whether quantization is dynamic.
- Fix the test context length, and record first-token latency and sustained generation speed separately.
- Compare the output quality of the original and optimized models on the same task data.
- Monitor peak memory, temperature, and power draw. Sustained high load triggers throttling, so tests must run long enough to reveal it.
- Prepare a fallback path. When memory is insufficient or accuracy falls short, switch to a smaller model or cloud inference.
6. Risks and Unsuitable Scenarios
- Accuracy risk: Quantization and structural changes may affect specific tasks. Long-document understanding and fine-grained visual recognition need particular attention.
- Transfer bottleneck: If embedding lookups are frequent and the data volume is large, transfers between the CPU and the accelerator can become a new bottleneck.
- Heat and power: Devices throttle during sustained inference, so peak test results do not reflect long-term user experience.
- Unsuitable scenarios: Latency-critical real-time tasks, models whose architecture does not support layered embeddings, and devices that already have ample memory.
7. Conclusion
The value of PLE lies in matching where parameters are stored to how they are accessed. Its benefit depends on model structure, runtime support, and transfer control, so each deployment should be validated on the target task and device.
