Characterizing Mobile SoC for Accelerating Heterogeneous LLM Inference

Le Chen, Dahu Feng, Erhu Feng, Yingrui Wang, Rong Zhao, Yubin Xia, Pinjie Xu, Haibo Chen

TL;DR

This paper introduces HeteroInfer, a novel LLM inference engine for mobile SoCs that leverages both GPUs and NPUs for significant speedups. By deeply characterizing the performance nuances of these heterogeneous processors and developing sophisticated partitioning and synchronization strategies, HeteroInfer achieves up to 6.02x faster inference compared to existing mobile LLM engines, all while maintaining negligible interference with other applications.

What Problem Does This Paper Address?

The rapid rise of large language models (LLMs) like ChatGPT has created a demand for on-device AI capabilities on mobile devices to enhance privacy and reduce latency. Modern mobile System-on-Chips (SoCs) are equipped with diverse AI accelerators, primarily GPUs and Neural Processing Units (NPUs), to handle these computational demands. However, existing LLM inference engines on mobile platforms often only utilize a single accelerator, leading to suboptimal resource utilization and memory bandwidth bottlenecks. Furthermore, the performance characteristics of these heterogeneous processors are not well-understood, and synchronizing them efficiently for LLM inference presents a significant challenge, especially given the inherent memory-intensive nature of LLM decoding. This paper aims to bridge this gap by providing a comprehensive characterization of mobile SoC heterogeneous processors and developing an inference engine that can effectively exploit their combined power.

Methods

HeteroInfer employs a multi-faceted approach to accelerate LLM inference on heterogeneous mobile SoCs:

  • Heterogeneous Processor Characterization: The authors meticulously analyze the performance characteristics of mobile GPUs and NPUs, identifying key factors like tensor sensitivity, synchronization costs, and memory bandwidth limitations. They highlight NPU's order-sensitive and shape-sensitive performance, and the underutilization of SoC memory bandwidth by single processors.
  • Layer-level and Tensor-level Parallelism:
    • Layer-level: Operators are assigned to GPU or NPU based on their affinities (e.g., Matmul to NPU, RMSNorm to GPU).
  • Tensor-level: To overcome limitations of layer-level parallelism, three strategies are introduced:
  • Weight-centric Partition: Partitions weight tensors to enable parallel execution between GPU and NPU, especially useful when NPU performance degrades due to unfavorable tensor shapes.
  • Activation-centric Partition: Addresses dynamic sequence lengths by offloading arbitrary shape tensors to the GPU while fixed-size computations run on the NPU.
  • Hybrid Partition: Combines activation-centric partitioning with padding and weight-centric partitioning to maximize computational power and maintain flexibility.
  • Fast Synchronization: To mitigate the high synchronization overhead between GPU and NPU, HeteroInfer utilizes a unified memory architecture and a predictable kernel waiting time mechanism. This involves a lightweight CPU thread that sleeps for a predicted time and then polls a flag to achieve microsecond-level synchronization.
  • Profiler-Solver-Engine Architecture: An offline profiler gathers performance metrics, a solver determines optimal partitioning strategies, and an online inference engine dynamically selects execution strategies based on these insights.

Datasets

The paper evaluates HeteroInfer on real-world LLM tasks and datasets, including:

  • Multi-turn dialogue: BELLE_multiturn_chat
  • Simple QA: GSM8K
  • Long-text processing: Longbench_TriviaQA

The models used for evaluation include Llama-7B, Llama-8B, Llama-3B, and InternLM-1.8B.

Key Insights and Ideas

  • NPU's Hidden Potential and Pitfalls: NPUs offer significant computational power, but their performance is highly sensitive to tensor shape and order. Simply offloading to NPU without considering these factors can lead to suboptimal results.
  • Memory Bandwidth is King (for Decoding): In memory-intensive LLM decoding, maximizing SoC memory bandwidth is crucial. Concurrent GPU-NPU execution effectively utilizes this bandwidth, achieving significantly higher performance than single-processor approaches.
  • Synchronization is a Major Bottleneck: The overhead of synchronizing heterogeneous processors on mobile SoCs can be substantial, especially for short kernel execution times in the decoding phase. Efficient synchronization mechanisms are critical for achieving true parallelism.
  • Dynamic Shapes Require Smart Partitioning: Mobile NPUs typically rely on static computation graphs, which are incompatible with the dynamic sequence lengths of LLM inputs. HeteroInfer's activation-centric and hybrid partitioning strategies effectively handle this by intelligently splitting workloads between GPU and NPU.
  • Heterogeneity is the Future: The paper strongly advocates for exploiting the combined strengths of different accelerators (GPU, NPU) rather than relying on a single one, paving the way for more efficient mobile AI.

Key Results

  • End-to-End Speedup: HeteroInfer achieves a 1.34× to 6.02× speedup over state-of-the-art GPU-only and NPU-only LLM engines across various workloads.
  • Prefill Performance: Achieves up to 6.02× speedup in prefill-dominant workloads and up to 3.29× speedup over NPU-only engines.
  • Decoding Performance: Delivers speedups between 1.50× and 2.53×, reaching up to 51.12 tokens/s on InternLM-1.8B.
  • Dynamic Sequence Length Handling: Achieves significant latency reduction (e.g., 2.24× speedup over Online-prepare at sequence length 525) by adaptively partitioning workloads.
  • Low Interference: Maintains negligible interference with other applications, with only a 2.2% slowdown in prefill and 17.7% in decoding when running concurrently with a mobile game, while keeping game FPS unaffected.
  • Energy Efficiency: Consumes 55% less energy than GPU-only and 12.8% less than Hetero-layer for end-to-end LLM inference.

Limitations and Future Work

  • Limitations:
    • The profiling process, while efficient, is constrained by a predefined set of tensor shapes and sequence lengths.
  • The current implementation avoids activation quantization and sparsity techniques to maintain accuracy, which could be explored for further optimization.
  • The paper notes that NPU currently does not support W4A16 for decoding, which is a limitation for that specific phase.
  • Future Work:
    • The authors suggest that future edge AI SoCs could benefit from unified GPU-NPU scheduling, coherent memory management across processing units, and a fast, lightweight synchronization library for heterogeneous processors.
  • The system's portability to other mobile SoCs with minimal retuning is highlighted, suggesting broader applicability.
  • The techniques are designed to be applicable to models with diverse architectures, hinting at future work in supporting more complex model types like MoE.

Summary updated

BibTeX
@inproceedings{chen2025characterizing,
  author = {Le Chen and Dahu Feng and Erhu Feng and Yingrui Wang and Rong Zhao and Yubin Xia and Pinjie Xu and Haibo Chen},
  title = {{Characterizing Mobile SoC for Accelerating Heterogeneous LLM Inference}},
  booktitle = {SOSP},
  year = {2025},
  doi = {10.1145/3731569.3764808},
}
Figure