Per-Layer Embeddings (PLE): Memory Optimization for On-Device AI

    As on-device AI models scale to billions of parameters, memory, rather than compute, often becomes the primary deployment bottleneck. This article explores Per-Layer Embeddings (PLE), a memory optimization technique that decouples total model parameters from accelerator resident parameters. By offloading large embedding and static parameters to the CPU while retaining core Transformer weights on the accelerator, PLE enables a pipelined inference process. We analyze its core architecture, inference workflow, key optimizations, and evaluation metrics, providing a practical approach for deploying multimodal models on memory-constrained edge devices.

    Per-Layer Embeddings (PLE): Memory Optimization for On-Device AI

    1. Background: The True Bottleneck of On-Device AI

    On-device AI deployment is often simplified to the question of “Can the model run?”, but in engineering practice, the more critical constraint is usually memory. The accelerator memory on mobile devices, embedded terminals, and edge computing boxes is typically much smaller than that of servers. Model parameters, activation values, runtime caches, and multimodal I/O buffers must all share the same memory budget. Especially as model parameter scales grow from hundreds of millions to billions, loading all weights into the accelerator at once will quickly exceed device limits, causing loading failures, frequent paging, or system-level memory reclamation.

    Per-Layer Embeddings (PLE) addresses exactly this contradiction. Its core is not simply to compress the model, but to re-partition “which parameters must be close to the accelerator and which can stay on the CPU side,” reducing the resident memory on the accelerator through a layered parameter processing mechanism. Designed for on-device multimodal model deployment, the goal is to maintain model capabilities within a limited memory budget and form an overlapping pipeline between the CPU and the accelerator.

    According to the public objectives of this technical approach, models with 5B and 8B parameters can have their equivalent accelerator resident weights reduced to 2B and 4B, enabling execution on mobile devices with less than 2GB of memory. It is important to emphasize that this equivalent scale is not achieved by simply deleting parameters, but by decoupling “total parameter count” and “accelerator resident parameter count” through parameter placement, layer-wise loading, and heterogeneous computing.

    2. Core Idea: Separating Large Parameters from Core Compute

    The basic concept of PLE can be summarized in three points:

    1. Layer-wise parameter organization: Embedding parameters, inter-layer static parameters, and some preprocessing parameters are organized by layer to form parameter blocks accessible on a per-layer basis, rather than requiring all weights to reside in the accelerator simultaneously.
    2. Heterogeneous memory placement: Large-capacity parameters with relatively regular access patterns are placed in CPU-accessible memory, where the CPU is responsible for loading, caching, and necessary computation. Core Transformer weights are retained in accelerator memory to ensure efficient execution of the main compute paths like attention and feed-forward networks.
    3. Layer-wise pipeline scheduling: During inference, execution advances layer by layer. The CPU side prepares the embedding signals required for the current or next layer in advance, while the accelerator side executes core weight computations. The two overlap through asynchronous copying and double buffering to reduce wait times.

    The direct benefit of this design is a reduction in accelerator memory usage. Assuming the total model parameters are (P), the core Transformer weights are (P_c), and the embedding and inter-layer static parameters are (P_e), the approximate relationship is:

    [
    P = P_c + P_e
    ]

    The traditional full-residency approach requires the accelerator to accommodate nearly (P) weights. Under PLE, the accelerator mainly accommodates (P_c), while the CPU side handles the loading and computation of (P_e). As long as (P_e) accounts for a high proportion, the accelerator’s peak memory can be significantly reduced. Combined with quantization, chunked caching, and layer-wise prefetching, the CPU-side parameters can also be kept within acceptable limits.

    3. System Architecture: Collaborative Layered Memory for CPU and Accelerator

    From a system architecture perspective, PLE can be divided into four layers:

    • Storage layer: Model parameters are stored in chunks, supporting layer-wise indexing and on-demand loading to avoid instantaneous memory peaks caused by full decompression or full mapping at startup.
    • CPU-side parameter cache: Caches embedding tables, inter-layer static parameters, and necessary intermediate results within the current window. Caching strategies can use Least Recently Used (LRU), layer-wise prefetching, and double buffering to avoid reloading for each layer.
    • Accelerator resident area: Stores only core Transformer weights, a small number of activation buffers, and the critical weights required by the output head. This area is the primary control point for the memory budget.
    • Scheduling and synchronization layer: Responsible for inter-layer task splitting, asynchronous copying, event synchronization, and fallback strategies. When the CPU side cannot prepare data in time, the scheduler should degrade to a more conservative prefetch depth to prevent pipeline stalling.

    The key to this architecture is defining the boundary between “resident” and “on-demand”. Core Transformer weights have high access frequency and are compute-intensive, making them best suited for the accelerator. Although embedding parameters are large in total volume, they are accessed by layer, by token, or by modality segment, making them suitable for chunking and prefetching. By moving large parameters out of the accelerator resident area, the memory curve of on-device models changes from “peak at startup” to “rolling by layer”.

    4. Inference Workflow: Layer-wise Preparation, Async Copy, Core Compute

    A simplified PLE inference workflow is as follows:

    1. Input tokens or multimodal features enter the preprocessing stage, and the CPU side prepares the layer’s embedding parameters based on the layer index.
    2. The CPU computes low-cost embedding lookups, projections, or conditional signals, forming layer input enhancement information.
    3. A small amount of intermediate results is asynchronously copied to the accelerator, avoiding the transfer of large embedding table blocks.
    4. The accelerator uses resident core Transformer weights to execute attention and feed-forward computations.
    5. Before moving to the next layer, the CPU side has already prefetched the parameters for the next layer, forming a pipeline overlap.
    6. After all layers are completed, the accelerator executes the output head and returns the results.

    The pseudocode below illustrates the scheduling logic and does not represent specific APIs:

    1. function ple_forward(tokens):
    2. hidden = init_hidden(tokens)
    3. prefetch_layer_params(0)
    4. for layer_id in range(num_layers):
    5. # CPU side: load large-capacity embedding/static params by layer and compute layer signals
    6. cpu_params = cpu_cache.get(layer_id)
    7. layer_signal = cpu_compute_embedding(tokens, cpu_params)
    8. # Asynchronously transfer a small amount of intermediate results to the accelerator
    9. async_copy_to_accelerator(layer_signal)
    10. wait_for_copy(layer_id)
    11. # Accelerator side: execute main compute using only resident core weights
    12. hidden = accelerator_transformer_block(
    13. hidden,
    14. layer_signal,
    15. resident_core_weights[layer_id]
    16. )
    17. # Prefetch the next layer to form a double buffer
    18. if layer_id + 1 < num_layers:
    19. prefetch_layer_params(layer_id + 1)
    20. return accelerator_output_head(hidden)

    There are two engineering key points in this workflow: First, what is transferred across the bus is the “layer signal” rather than the complete embedding table; otherwise, copy bandwidth will become a new bottleneck. Second, the prefetch depth must match the CPU cache and accelerator queue capacity—too deep will increase memory peaks, while too shallow will expose latency.

    5. Key Optimizations: Balancing Latency, Bandwidth, and Power

    PLE is not simply “throwing parameters to the CPU.” Practical implementation requires joint optimization around latency, bandwidth, and power consumption.

    1. Parameter chunking and layer-wise indexing. Splitting embedding parameters by layer and chunk and establishing a lightweight index allows the CPU to load only the data needed for the current layer. The chunking granularity must balance loading efficiency and cache hit rate—too large will cause memory peaks, while too small will increase scheduling overhead.

    2. Double buffering and pipeline overlap. When the CPU prepares layer (i+1), the accelerator computes layer (i). Double buffering hides part of the loading time. For on-device small-batch inference, pipeline fill and drain overheads account for a higher proportion, requiring a reduction in inter-layer synchronization frequency.

    3. Quantization and compression. Using low-bitwidth storage, chunked decompression, or sparsification for CPU-side parameters can reduce memory usage and bandwidth pressure. However, quantization errors accumulate across layers, requiring precision allocation between embedding signals and core weights to prioritize the stability of the core compute path.

    4. Caching strategy. On-device sessions typically feature short input lengths and frequent continuous requests. You can cache recently used embedding blocks by layer window, combining access frequency to determine retention priority. For multimodal scenarios, the embedding access patterns for image and audio segments differ, so separate cache budgets should be set.

    5. Power and thermal constraints. Increased CPU computation will raise power consumption. Avoid prolonged high-load decompression on the CPU; adopt event-driven, on-demand wake-up, and low-power waiting. When device temperature rises, you can reduce the prefetch depth or shorten the cache window to ensure uninterrupted inference.

    6. Evaluation Methods: Peak Memory Over Parameter Count

    When evaluating a PLE approach, it is recommended to establish multi-dimensional metrics:

    • Accelerator peak resident memory: The sum of core weights, activations, and output head. This is the primary indicator of whether the model can be loaded on-device.
    • CPU-side peak memory: The sum of parameter cache, decompression buffer, and intermediate results, ensuring the CPU side does not become a new bottleneck.
    • Time to First Token (TTFT) and Time per Output Token (TPOT): Observe whether pipeline filling, inter-layer synchronization, and prefetching are effective.
    • Cross-bus copy volume: Track the data transferred per layer to confirm that large parameters are not being moved back and forth.
    • CPU and accelerator utilization: The ideal state is overlapping execution, rather than alternating waits.
    • Power consumption and thermal rise: Tested under long-duration sessions, multimodal inputs, and low-battery scenarios.

    In terms of selection, PLE is suitable for on-device models with “large total parameter count, controllable core Transformer weight proportion, and layer-accessible embedding and inter-layer parameters.” If the model’s core weight proportion is too high, or inter-layer dependencies prevent prefetching, the benefits will decrease. Engineering should start with parameter profiling to determine the layering boundary, rather than blindly applying the technique.

    7. Conclusion

    The value of Per-Layer Embeddings (PLE) lies in transforming the on-device AI memory problem from “full residency” to “layered residency and pipeline scheduling.” By letting the CPU side handle large-capacity embedding and static parameters while the accelerator retains core Transformer weights, PLE reduces accelerator resident memory. It maintains inference continuity through layer-wise prefetching, asynchronous copying, and caching strategies. For developers looking to deploy multimodal models on memory-constrained devices, PLE provides an engineering-ready approach: first partition parameter access patterns, then design heterogeneous memory layouts, and finally use pipelining and quantization compression to balance latency, bandwidth, and power. Only by establishing an observable and tunable coordination mechanism among memory, compute, and power can on-device AI run stably on real devices.