Efficient On-Device Inference for Multimodal MoE Large Models: Architecture and Practice

    How can a 35-billion-parameter multimodal MoE model run on a smartphone? This article breaks down the core techniques behind efficient on-device inference: sparse expert activation, look-ahead expert scheduling that hides flash I/O behind computation, quantization and speculative decoding. Learn how decoding speed was boosted from 3.38 to over 20 token/s with only ~3GB of memory, and what these results mean for building edge-cloud AI applications.

    Efficient On-Device Inference for Multimodal MoE Large Models: Architecture and Practice

    The Core Challenge of On-Device Inference

    As large model capabilities continue to advance, the gap between parameter scale and the physical constraints of mobile devices keeps widening. Consider an on-device multimodal Mixture-of-Experts (MoE) model with 35 billion total parameters: its full weights weigh roughly 65.6 GiB—more than four times the memory of mainstream 16GB devices. Even with aggressive 4-bit quantization, the weights still occupy around 15GB, which is nearly impossible to load at once into the available memory of a flagship phone.

    On-device inference must find an optimal balance across latency, throughput, power consumption, and thermal constraints. The fundamental principle of model design here is to approach the limits of what these physical constraints allow, squeezing as much intelligence as possible out of limited edge resources. From a user experience perspective, an output speed of about 8 token/s is the lower threshold at which generation feels lag-free, while 15 token/s or above feels smooth. For conversational tasks, 15 token/s is therefore a reasonable engineering target. As mobile hardware compute and inference efficiency improve, the extra capacity should be spent on running stronger models rather than sitting idle.

    Sparse Activation: Trading MoE Architecture for Parameter Scale

    The model uses a Mixture-of-Experts architecture with 35 billion total parameters, but only about 3 billion parameters are activated per token. Expert weights account for 32.2B of the total—10,240 experts making up 93.6% of all parameters—and each token only invokes 320 of them (roughly 3.1%). The key insight behind this design is that the vast majority of expert weights sit idle at any given moment.

    This leads to a core optimization strategy: keep unused expert weights on device flash storage and load them on demand during computation, rather than keeping everything resident in memory. Combined with storage layout optimization, memory footprint drops to about 1/15 of the original, allowing a 35-billion-parameter model to run within roughly 3GB of RAM.

    The sparse activation compute pattern can be abstracted as:

    1. # Illustrative logic of sparse expert routing
    2. def moe_forward(hidden_state, router, experts):
    3. # The router selects Top-K experts for the current token
    4. expert_ids = router.top_k(hidden_state, k=320)
    5. # Load only the selected expert weights on demand (the rest stay in flash)
    6. weights = load_on_demand(expert_ids)
    7. return sum(w * experts[eid](hidden_state, weights[eid])
    8. for eid, w in expert_ids)

    Look-Ahead Expert Scheduling: Overlapping I/O with Computation

    The bottleneck of on-demand loading is flash bandwidth. If the system strictly serializes “compute → request experts → load → compute again,” output speed drops to only about 2–3 tokens per second. Look-Ahead Expert Scheduling (LES) takes a different approach: the system predicts which experts the next layer is likely to invoke and starts prefetching their weights from flash while the current layer is still computing, effectively hiding I/O latency inside computation time.

    In real-world testing, this scheduling strategy prepares over 80% of the required experts ahead of time in most scenarios, delivering an average speedup of roughly 5x on actual devices. Crucially, model output is identical to what it would be with the feature disabled—meaning this is a pure system-level optimization that does not alter model semantics. The workflow can be summarized as:

    1. Predict: Based on activation features of the current layer and routing history, estimate the set of experts most likely to be hit in the next layer;
    2. Prefetch: While computation proceeds, asynchronously load the predicted expert weights from flash into a memory cache;
    3. Hit or fall back: If the prediction hits, use the cache directly; otherwise, fall back to synchronous loading to guarantee correctness.

    Co-Optimizing Storage, Quantization, and Decoding

    Beyond scheduling, the model applies complementary optimizations across three dimensions:

    • Storage layout: Expert weights are stored contiguously in flash, reducing the addressing overhead of random reads and maximizing sequential read bandwidth;
    • Layer-wise mixed-precision quantization: Different layers have different sensitivity to quantization error, so each layer is assigned an appropriate precision, compressing weight size and loading bandwidth while preserving quality;
    • Speculative decoding: On the output side, a speculative decoding scheme is adopted in which a small model drafts candidate token sequences and the large model verifies them in parallel. Across multiple benchmark tasks on a 16GB tablet, the optimal configuration improved generation speed by about 1.17x on average.

    For visual processing, the input side uses visual token compression with two modes: 4x compression prioritizes detail preservation, suiting document understanding and small-text recognition; 16x compression prioritizes speed, suiting more latency-sensitive interactive scenarios.

    End-to-End Results and Engineering Takeaways

    Combining the techniques above, the model’s decoding speed on a flagship phone rose from 3.38 token/s to 20.51 token/s—well past the 15 token/s smoothness threshold. An upgraded version of the scheduling technique pushes the speed beyond 30 token/s with memory usage of about 3GB. These results offer several broadly applicable takeaways:

    1. Sparsity is a structural dividend for on-device large models: Activated parameters determine compute cost, while total parameters determine knowledge capacity. The MoE architecture allows the two to be decoupled;
    2. I/O is not a hard constraint: With prediction and prefetching, the flash bandwidth bottleneck can be masked by computation time;
    3. System optimization and algorithm optimization must go hand in hand: If any single link in the chain—quantization, storage layout, scheduling, or decoding—falls behind, the overall gains are significantly diminished.

    For developers looking to bring on-device multimodal capabilities into their own applications, an effective approach is to build an edge-cloud collaborative architecture: offload compute-heavy tasks to cloud inference services, keep lightweight and privacy-sensitive tasks on the device, distribute model weights via object storage, and monitor on-device performance metrics through alerting and observability tools—together forming a complete edge-cloud intelligent solution.