On-Device Inference for Mid-Size LLMs: Speculative Decoding and MoE Architecture Performance
This article examines how speculative decoding and Mixture-of-Experts (MoE) architectures perform when mid-size language models run on devices with limited unified memory. It presents test results for a 12-billion-parameter dense model and a MoE model with about 26 billion total parameters, shows how task type affects speculative decoding acceptance rates, and offers guidance for on-device deployment and cloud-edge collaboration.
Mid-size models, with around 12 billion parameters, fill the gap between lightweight edge models and very large MoE models. A recently open-sourced dense model of this size reasons and draws on knowledge better than small edge models. Its memory footprint is also smaller than that of models in the multi-billion-parameter range larger than it, which makes it a strong candidate for on-device and edge computing. However, running these models efficiently on devices with limited unified memory remains a difficult inference optimization problem. This article uses test data to examine how speculative decoding and MoE architecture perform in this setting and what trade-offs they involve.
1. Speculative Decoding on Edge Devices: Performance and Bottlenecks
Speculative decoding is a common technique for easing the memory bandwidth bottleneck of autoregressive generation. A lightweight draft model proposes candidate tokens quickly. The main model then verifies them in parallel. When candidates are accepted, the system outputs several tokens in one step, which raises decoding throughput.
In practice on edge devices, however, the gains often fall short of theory. The complexity of matching the underlying hardware architecture with the open-source inference framework is a major reason. In tests of an open-source inference framework on an edge device with unified memory, speculative decoding did not speed up a mid-size dense model. It slowed the model down.
Without speculative decoding, the baseline model averaged about 36.4 tokens/s across a range of comprehensive tasks, with an average latency of 31.4 seconds. With speculative decoding enabled (MTP, or Multi-Token Prediction), average speed fell to 31.6 tokens/s, and latency rose to 36.6 seconds. Overall, this is about 0.87x the baseline speed.
The root cause is the framework’s speculative decoding implementation on this specific hardware and software platform. It has defects that lead to a low token acceptance rate. Frequent drafting and discarding of candidate tokens adds extra computation and memory access overhead.
2. How Task Type Affects Acceptance Rate
Speculative decoding works best when the draft model and the main model produce similar output distributions. This similarity varies widely across task types. The test data shows that task type strongly determines the acceptance rate.
2.1 Highly structured tasks: relatively strong results
For coding and retrieval-augmented generation (RAG), which are highly structured and logically rigid, speculative decoding produced a modest positive gain. In coding tasks, the token acceptance rate reached 0.76, and generation speed rose from 36.15 t/s to 42.83 t/s, a 1.18x speedup. Latency dropped from 28.7 seconds to 24.5 seconds. For RAG tasks, the acceptance rate was even higher at 0.80, and latency stayed roughly the same. These tasks follow strong patterns, so the draft model predicts the next tokens more accurately.
2.2 Open-ended and complex reasoning tasks: clear slowdown
Tasks that require creativity or complex logical reasoning did not benefit. Acceptance rates for humanities, mathematical reasoning, and writing tasks fell to 0.57, 0.61, and 0.58. As a result, writing speed dropped from 34.66 t/s to 25.75 t/s, and latency increased from 35.2 seconds to 47.4 seconds, a performance ratio of 0.74x. In multi-turn role-play and multilingual translation, acceptance rates stayed between 0.61 and 0.72, causing performance losses of varying size. As randomness and reasoning depth increase, the small draft model’s predictions become less reliable. Frequent fallback to the main model then cancels out the benefit of parallel verification.
3. MoE Performance on Unified Memory Architecture
Mid-size dense models are not the only option for on-device use. In the same test environment, a MoE model with about 26 billion total parameters and about 4 billion active parameters per inference step (26B A4B) generated tokens at nearly 80 tokens/s on the device. The 12B dense model generated at about 36 tokens/s.
The main advantage of MoE is sparse activation. On unified memory architectures, compute capacity is often not the bottleneck. Memory bandwidth is the main limit on inference speed. MoE models have large total parameter counts and occupy more memory, but each inference step activates only a small subset of expert networks. This keeps high model capacity and strong generalization while greatly reducing memory bandwidth demand. As a result, on unified memory devices, a 26B-class MoE model can fit fully in memory, and its actual inference speed exceeds that of the 12B dense model, which has fewer total parameters.
This suggests a practical rule for on-device model selection: when memory capacity allows, a sparse MoE architecture can be more efficient for inference than a dense architecture of the same or even smaller parameter count.
4. Practical Recommendations for On-Device Deployment and Cloud-Edge Collaboration
Based on this analysis, developers should take a careful, evidence-based approach to on-device deployment.
First, evaluate the optimization mechanisms of the inference framework carefully. Not every technique marketed as an accelerator works on every hardware platform. Before adopting speculative decoding, validate it on the target device, taking its memory hierarchy and compute units into account. If the target workload is mostly open-ended generation, such as creative writing, enabling speculative decoding without testing may reduce performance.
Second, prioritize sparse architectures. When device memory, such as 16 GB to 32 GB of unified memory, can hold the model, choose a MoE model with a low active-parameter ratio. These models often provide a better real-time response experience.
Third, build a cloud-edge pipeline for model evaluation and distribution. When deploying on-device LLMs, enterprises can use Baidu AI Cloud’s GPU container platform or elastic compute instances to run large-scale benchmarking, fine-tuning, and quantization in the cloud. This process helps identify the model version best suited to the edge hardware. Model weights can then be distributed to edge nodes through Baidu AI Cloud object storage and a content delivery network (CDN). This architecture uses cloud compute for model iteration while helping protect on-device data and keeping inference latency low. It is a recommended approach for enterprise AI deployment.
