Accelerating LLM Inference via Dynamic KV Cache Placement in Heterogeneous Memory System

Yunhua Fang, Rui Xie, Asad Ul Haq, Linsen Ma, Kaoutar El Maghraoui, Naigang Wang, Meng Wang, Liu Liu, Tong Zhang

Abstract

Large Language Models (LLMs) are increasingly constrained by the "memory wall," particularly during the auto-regressive decoding stage where the Key-Value (KV) cache must be accessed. As context windows expand, this cache often exceeds the capacity of fast High-Bandwidth Memory (HBM), necessitating the use of slower off-package DRAM. This paper explores dynamic KV cache placement in heterogeneous memory systems. By modeling inference latency and using Simulated Annealing (SA) with an "oracle" foresight, the authors demonstrate that optimal placement of "important" tokens can achieve up to a 5.87x throughput increase. The findings highlight the significant potential for smarter memory management that leverages aggregated bandwidth and accounts for the temporal volatility of token importance.

Introduction

The performance of Large Language Model (LLM) inference is heavily memory-bandwidth bound, especially during the auto-regressive "decode" stage. Generating each new token requires reading the Key-Value (KV) cache, which stores the history of all previous tokens. As context lengths scale to tens of thousands of tokens, the KV cache size often surpasses the capacity of fast on-package High-Bandwidth Memory (HBM), forcing a reliance on larger but slower off-package DRAM.

The Challenge of Dynamic Importance

While attention sparsity techniques can reduce the active working set by skipping unimportant tokens, token relevance is not static. A token that is irrelevant for many steps may suddenly become crucial. This "dynamic importance" suggests that static memory placement is suboptimal. The core challenge is orchestrating data movement in heterogeneous memory systems (e.g., NVIDIA Grace Hopper) to ensure the most relevant tokens reside in the fastest memory at the appropriate time.

Illustration of suboptimal vs. improved token placement across HBM and DRAM.

Methodology

The researchers developed a formal mathematical framework to determine the theoretical upper bound of KV cache placement efficiency.

  1. Latency Modeling: Inference latency was formulated as a function of data movement across the memory hierarchy, considering parallel access capabilities of HBM and DRAM.
  2. Optimization via Simulated Annealing (SA): To navigate the complex search space of placement decisions, a Simulated Annealing algorithm was employed.
  3. Oracle Foresight: The SA optimizer was granted "perfect foresight" of future token importance. While not practical for real-time systems, this "Oracle" approach establishes a theoretical performance limit, revealing the maximum potential gain from optimized placement.

Evaluation was conducted using LLaMA-3.1-8B on long-context tasks (30k input, 10k output) from the NarrativeQA dataset, simulating hardware specs of the NVIDIA GH200 Grace Hopper Superchip.

Key Results

The SA-guided "Oracle" strategy demonstrated a massive performance gap compared to existing methods, achieving up to a 5.87x increase in throughput over standard static placement. It consistently outperformed reactive (LRU-based) and page-granularity heuristics, particularly under high memory pressure.

Throughput comparison of different scheduling strategies across varying token importance patterns.

Key insights from the results include:

  • Temporal Volatility: Token importance fluctuates significantly over time, necessitating dynamic migration strategies.
  • Bandwidth Aggregation: Optimal performance requires utilizing the aggregated bandwidth of both HBM and DRAM links simultaneously.
  • High Hit Rates: The optimized strategy achieved an HBM hit rate of over 91% for important tokens, compared to just ~58% for static placement.

Conclusion and Future Work

The significant throughput gains identified by the Oracle approach highlight a major opportunity for LLM inference optimization. Future research should focus on bridging the gap between the Oracle and real-time systems through predictive modeling using lightweight ML to forecast future token importance, reinforcement learning for adaptive memory scheduling, and hardware-software co-design of memory controllers.

Summary updated

BibTeX
@inproceedings{fang2025accelerating,
  author = {Yunhua Fang and Rui Xie and Asad Ul Haq and Linsen Ma and Kaoutar El Maghraoui and Naigang Wang and Meng Wang and Liu Liu and Tong Zhang},
  title = {{Accelerating LLM Inference via Dynamic KV Cache Placement in Heterogeneous Memory System}},
  booktitle = {IEEE Comput. Archit. Lett},
  year = {2025},
}
Figure