HeteGen: Efficient Heterogeneous Parallel Inference for Large Language Models on Resource-Constrained Devices

Xuanlei Zhao, Bin Jia, Haotian Zhou, Ziming Liu, Shenggan Cheng, Yang YouMLSys 2024

Abstract

Large Language Models (LLMs) are increasingly difficult to deploy on consumer-grade hardware due to the "memory wall"—the gap between model size and available GPU VRAM. While offloading techniques mitigate this by utilizing system RAM, they often suffer from high inference latency. This paper introduces HeteGen, a heterogeneous parallel inference system that treats the CPU as an active compute resource rather than a passive storage unit. By implementing a hybrid parallelism strategy and an optimized scheduling framework, HeteGen achieves up to a 317% speedup over state-of-the-art offloading baselines.

Introduction

The deployment of state-of-the-art LLMs, such as OPT-30B, requires substantial memory resources (approx. 60GB) that far exceed the capacity of common GPUs like the NVIDIA A10 (24GB). Existing solutions typically rely on offloading weights to CPU memory and swapping them into the GPU via PCIe. However, the limited bandwidth of PCIe creates a significant bottleneck, leading to high latency that hinders real-time interaction. HeteGen addresses this by shifting the paradigm from simple offloading to active heterogeneous computation.

Identifying the Bottleneck

To optimize inference, it is critical to identify which components contribute most to the memory footprint. Analysis of transformer-based architectures reveals that linear layers are the primary consumers of memory.

Breakdown of LLM module memory footprint, highlighting linear layers as the primary bottleneck.

As shown in the figure above, linear modules account for over 97% of the total memory footprint. Consequently, HeteGen focuses its optimization efforts on these modules to maximize system-wide efficiency.

Methodology

HeteGen introduces three core innovations to minimize inference latency:

1. Hybrid Heterogeneous Parallelism

Unlike traditional systems where the GPU remains idle while waiting for data transfers, HeteGen splits the workload of each layer. A portion of the computation is executed on the CPU, while the remainder is transferred to and processed by the GPU. This approach effectively overlaps computation with communication.

2. The Alpha (α) Strategy

The system employs a mathematical model to determine the optimal workload distribution ratio, denoted as α. The goal is to balance the execution time such that the CPU completes its assigned task exactly when the GPU finishes both its data transfer and its own computation. This synchronization minimizes "dead time" across hardware components.

3. Asynchronous Parameter Management

HeteGen utilizes a "look-ahead" mechanism to hide memory management overhead. While the current layer is being processed, the system pre-emptively "pins" and prepares memory for the subsequent layer.

The HeteGen system architecture, featuring the Alpha Benchmark scheduler and asynchronous Parameter Manager.

Experimental Results

The researchers evaluated HeteGen using the OPT model family (6.7B to 30B parameters). Key findings include:

  • Performance Gains: HeteGen consistently outperformed DeepSpeed and FlexGen. On OPT-30B, HeteGen achieved a 3.17x speedup compared to FlexGen.
  • Robustness: The system demonstrated high stability in extreme memory-constrained environments, successfully running the 30B model even when only 6.5% of the weights could be hosted on the GPU.
  • Resource Efficiency: Hardware utilization analysis confirmed that CPU and I/O resources were active nearly 100% of the time, validating the effectiveness of the asynchronous overlapping strategy.

Conclusion

HeteGen demonstrates that the CPU can be a powerful co-processor for LLM inference on resource-constrained devices. By intelligently distributing workloads and overlapping data transfers with computation, HeteGen significantly reduces latency, making large-scale models more accessible for local deployment. Future work will explore the integration of quantization techniques to further lower memory requirements.

Summary updated

BibTeX
@inproceedings{zhao2024hetegen,
  author = {Xuanlei Zhao and Bin Jia and Haotian Zhou and Ziming Liu and Shenggan Cheng and Yang You},
  title = {{HeteGen: Efficient Heterogeneous Parallel Inference for Large Language Models on Resource-Constrained Devices}},
  booktitle = {MLSys},
  year = {2024},
  url = {https://openreview.net/forum?id=0v6RtAozgt},
}

Loading related content...

Figure