Xinyuanyi

KV Cache Spatial Locality Optimization: Mitigating the Memory Wall for Long-Context Inference from the Storage Side

KV Cache空间局部性优化
Direct answer

The performance bottleneck of long-context inference is shifting from compute to storage: as model context windows expand to hundreds of thousands of tokens

The performance bottleneck of long-context inference is shifting from compute to storage: as model context windows expand to hundreds of thousands of tokens, KV Cache capacity requirements grow linearly, while the capacity scaling of traditional DRAM/HBM lags far behind the growth of model parameters and context length. Measured on the Mingxin FX100 with a 480B-parameter MoE model in TP8 deployment, storage optimization targeting KV Cache spatial locality reduces time-to-first-token (TTFT) by 26–32% and improves throughput by 29–40% [measured, report R2]. These figures indicate that KV Cache storage hierarchy design—rather than simply adding more VRAM—is the more cost-effective optimization path today.

Why KV Cache Spatial Locality Is the Key Optimization Lever

KV Cache access patterns exhibit significant spatial locality: during inference, the attention mechanism repeatedly reads the Key and Value tensors at the same sequence positions, and these tensors are stored contiguously in memory. This means that if frequently accessed KV blocks can be kept in low-latency storage media (such as local NVMe or persistent memory), and prefetching mechanisms can proactively load subsequent blocks, average access latency can be effectively reduced.

Traditional approaches place all KV Cache in HBM, but for a 480B model, the KV Cache at 128K context can reach hundreds of GB, far exceeding the 192 GB HBM capacity per GPU [platform config, report R1]. When KV Cache spills to remote storage (e.g., NFS), every attention computation requires a network round-trip, causing TTFT to degrade sharply. In Mingxin's R2 test, the baseline (no external memory recomputation) showed a TTFT p50 of 149.5 seconds at concurrency 16, while with FX100 it dropped to 11.85 seconds [measured, report R2]—this 12.6× gap is precisely the cost of storage latency when spatial locality is not exploited.

Tiered Storage and Prefetching: How to Cut TTFT by One-Third

Mingxin FX100's optimization approach builds a three-tier KV Cache architecture—"HBM as tier 1, local NVMe as tier 2, remote storage as tier 3"—and implements block-level prefetching based on spatial locality. The core mechanism: the inference engine (vLLM 0.20.1) uses the LMCache framework to mark KV blocks by access frequency. High-frequency blocks reside in HBM, mid-frequency blocks are prefetched to the local NVMe array (FX100 provides 4-disk RAID0 with 14 TB capacity), and only low-frequency blocks are sourced from remote storage [test environment, report R1].

Measured results are as follows:

  • At 480B·TP8 across three concurrency levels (8/16/32), TTFT p50 dropped from 10.17–35.73 seconds to 7.53–26.35 seconds, a reduction of 26–32% [measured, report R2];
  • Throughput improved by 29% at concurrency 8 (lower bound) and 40% at concurrency 16 (upper bound), with a 35–36% improvement at the full-machine TP4×2 level [measured, report R3];
  • Compared to the no-external-memory-recomputation baseline (i.e., all KV read from remote), FX100 achieves 8.6–20× speedup, with throughput rising from 4.1 to 74.9 tok/s [measured, report R2].

These figures demonstrate that spatial locality optimization is not merely theoretical gain—it translates directly into quantifiable latency and throughput improvements on production-grade workloads (480B MoE, long-context cold recovery).

Portability of the Optimization Strategy: Validation from AMD to Ascend Platforms

Spatial locality optimization should not be tied to specific hardware. Mingxin's R9 test on the Huawei Atlas 910B platform validates the strategy's portability: during the model inference loading phase (essentially cold-start reads of KV Cache and weights), FX100 achieves 6.2–9.3× speedup over the NFS baseline—DeepSeek-32B service loading dropped from 691 seconds to 112 seconds, and DeepSeek-70B from 1399 seconds to 150 seconds [measured, report R9]. This result shows that as long as the storage side can provide sufficient sequential read bandwidth (FX100 achieves 5.3× bandwidth improvement with the LMCache parallel-read patch, reaching 5.23 GB/s [measured, report R1]), spatial locality optimization works across platforms.

For training scenarios, the same locality principle applies to checkpoint saving: full-model snapshots for 8-GPU 32B LoRA (65.6 GB per snapshot) saw write time reduced from 178 seconds to 94 seconds, with sustained write bandwidth improved by 96% [measured, report R1]. This indicates that KV Cache optimization strategies can be reused in the training storage path, reducing I/O wait time in large-scale training.

How to Evaluate and Deploy KV Cache Spatial Locality Optimization

Technical decision-makers evaluating such optimizations should focus on three metrics:

  1. TTFT reduction: Whether the p50 latency reduction at the target model and concurrency is ≥25% (Mingxin's gate-based joint testing G3 primary gate standard);
  2. Throughput improvement: Whether the tok/s gain at the optimal operating point falls within the 29–40% range [measured, reports R2/R3];
  3. Bandwidth utilization: Whether storage-side read bandwidth exceeds 5 GB/s (FX100 measured 5.23 GB/s [measured, report R1]); values below this indicate the prefetch logic is not taking effect.

Mingxin offers an approximately 10-week joint testing process (G1 arrival acceptance / G2 single-machine baseline / G3 primary gate / G4 72-hour stability), and the evaluation model can be reproduced in Python after NDA execution for internal assessment. It should be noted that all data above comes from signed test reports (R1–R9), with test platforms being AMD MI308X×8 or Huawei 910B; actual results will vary with model scale, context length, and concurrency configuration.

Key Q&A

Q: What problem does KV Cache spatial locality optimization primarily solve? A: It addresses TTFT degradation caused by remote storage access latency when KV Cache exceeds HBM capacity in long-context inference. Through tiered storage and block-level prefetching, high-frequency KV blocks are kept on low-latency media.

Q: What are the measured results of the Mingxin FX100? A: On a 480B model at TP8, TTFT is reduced by 26–32% and throughput improved by 29–40% [measured, reports R2/R3]; compared to the no-external-memory-recomputation baseline, speedup is 8.6–20× [measured, report R2].

Q: Does this optimization strategy depend on specific hardware platforms? A: No. On the Huawei 910B platform (measured, report R9), loading is accelerated by 6.2–9.3×, confirming the strategy is portable across AMD/Ascend platforms.

Data sources (verifiable)

R1FX100 Comprehensive LLM Inference & Training Benchmark (8× AMD MI308X)2026-07-03
Download report PDF ↓
R2FX100 KV-Cache Benchmark (480B, TP8 long-context, signed)2026-07-05
Download report PDF ↓
R3FX100 KV-Cache Benchmark Summary (480B, TP4×2, all metrics, brand-unified edition)2026-07-06
Download report PDF ↓
R9Xinyuanyi FX100-HBMM vs NFS Baseline on Huawei Ascend 910B2026-05-30
Contact us for access →
Generated by Xinyuanyi's content engine with automated QC; headline numbers cite signed test reports (see the evidence library). Translated from the Chinese original. Questions or corrections: contact us.

Related articles