Abstract
Local execution of Large Language Models (LLMs) on mobile devices is critical for privacy and low-latency applications. However, modern mobile System-on-Chips (SoCs) feature heterogeneous accelerators (CPU, GPU, NPU) that are typically underutilized by existing single-accelerator inference engines. We present HeteroInfer, a high-performance engine that achieves up to a 6.02× speedup by simultaneously utilizing the GPU and NPU. Through adaptive workload partitioning and microsecond-level synchronization, HeteroInfer maximizes memory bandwidth and overcomes the performance rigidity of mobile NPUs.
Introduction
The deployment of LLMs on smartphones represents a significant milestone for edge AI. Current state-of-the-art frameworks like llama.cpp or MLC-LLM primarily offload computation to a single accelerator, usually the GPU or the NPU. This approach fails to exploit the full potential of modern mobile SoCs, such as the Snapdragon 8 Gen 3, which are designed with multiple specialized processing units. HeteroInfer addresses this gap by treating the SoC as a unified heterogeneous platform.
The Problem of Single-Accelerator Inference
Single-accelerator approaches suffer from three primary limitations:
- Bandwidth Underutilization: A single processor often cannot saturate the total memory bandwidth available on the SoC.
- NPU Performance Rigidity: NPUs are optimized for specific tensor shapes and data layouts. Deviations from these "friendly" shapes cause significant performance drops, characterized by "stage performance" (stepped latency jumps) and "order sensitivity" (performance variance based on operand order).
- Synchronization Overhead: Standard operating system primitives for coordinating tasks between the GPU and NPU introduce delays (often ~400μs) that can exceed the actual computation time of individual neural network layers.
The HeteroInfer Framework
HeteroInfer introduces a tensor-level heterogeneous execution model. The system architecture manages the flow from input sequence parsing to optimized kernel execution across the GPU and NPU, as depicted in the following architectural overview.
Adaptive Partitioning Strategies
To handle the diverse shapes encountered in LLMs, HeteroInfer employs three partitioning strategies:
- Weight-centric: The weight matrix is split between the GPU and NPU for operators with fixed shapes.
- Activation-centric: The input sequence length (M) is partitioned, allowing the system to handle dynamic user inputs without requiring expensive NPU graph recompilation.
- Hybrid Partitioning: A combination of both methods is used to optimize for particularly "unfriendly" tensor shapes that would otherwise cause NPU stalls.
Fast Synchronization
To eliminate the "sync tax," HeteroInfer bypasses standard OS fences. Instead, it uses a CPU-assisted polling mechanism. The CPU predicts kernel completion times and monitors a "flag bit" in shared memory, triggering subsequent tasks with microsecond precision.
Key Insights: Maximizing Bandwidth
A core discovery of this work is the "Bandwidth Sweet Spot." While the Snapdragon 8 Gen 3 has a theoretical limit of 68 GB/s, a single accelerator typically maxes out at 40–45 GB/s.
By running the NPU and GPU concurrently, HeteroInfer achieves a combined bandwidth of approximately 60 GB/s. This represents 96% of the achievable maximum, effectively "filling the pipe" for memory-bound LLM operations.
Results and Evaluation
HeteroInfer was evaluated using Llama (3B, 7B, 8B) and InternLM (1.8B) models across benchmarks like BELLE and GSM8K.
- Performance: The engine delivers 1.34× to 6.02× end-to-end speedup over single-accelerator baselines. It is the first mobile engine to exceed 1000 tokens/sec in the prefill phase and 50 tokens/sec in decoding for billion-parameter models.
- Energy and Stability: HeteroInfer reduces energy consumption by 55% compared to GPU-only solutions by completing tasks faster. Furthermore, it exhibits lower interference with concurrent applications; for instance, it maintains stable frame rates in 3D games like League of Legends: Wild Rift where other engines cause significant lag.
Conclusion
HeteroInfer demonstrates that heterogeneous execution is the key to unlocking LLM performance on mobile devices. By intelligently bridging the gap between the GPU and NPU, it provides a scalable and efficient solution for local AI. Future work will focus on cross-vendor compatibility and deeper integration with mobile OS schedulers.
Summary updated