Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

XM-Sparse Offloads KV & Index to External Memory, Doubling 128K Batch to 209/GPU

XM-Sparse moves both hot KV buffer and K-index cache from HBM to a scale-up memory pool, using a fused kernel for KV fetch-attention overlap and GPU-initiated DMA for index prefetch, raising per-GPU batch size from 109 to 209 and throughput 29% at 128K context on GLM-5.3.

Sparse attention offloads the full KV history to external memory, yet decode throughput remains bound by on-chip HBM capacity. The paper demonstrates this on a simulated scale-up memory pool (X-Mem) with 900 GB/s per-GPU bandwidth and 24 TB capacity. At 128K context, expanding CXL capacity from 1 TB to 24 TB raises per-GPU batch size from 36 to 109 (3.03× throughput). The pool at the same batch achieves 1.71× CXL throughput, reaching 94.2% of the compute-only ceiling — yet only ~3 TB of the 24 TB pool is used. The bottleneck shifts to the GPU: the 60 GiB resident budget is consumed by the hot KV buffer and the K-index cache.

01 HBM Bottleneck Despite Massive External Memory

Four memory-extension paths are compared: PCIe 5.0×16 (64 GB/s, 2 TB host), CXL 2.0 (similar bandwidth, tens of TB), NVLink-C2C (225 GB/s, 480 GB LPDDR5X shared by two chips), and scale-up pool via NVSwitch (900 GB/s, 24 TB DDR5 per X-Mem node, aggregate ~4 TB/s). At 16K context, 1 TB external memory already saturates batch at 241/GPU; further capacity adds nothing, and the pool's advantage comes purely from bandwidth (1.92×). At 128K, CXL 24 TB lifts batch to 109 (3.03× over 1 TB), and the pool at that batch delivers 1.71× CXL throughput. However, the pool at batch 109 already hits 94.2% of the no-transfer ceiling while using only ~3 TB of 24 TB. The remaining headroom is blocked by on-chip caches.

02 Two Small Caches Consume ~40% of HBM

Even with 288 GB/GPU estimated, the hot KV buffer and K-index cache together with model weights occupy ~40% of HBM at 128K. The hot buffer is typically sized 2–4× the Top-K (2048), i.e., 4K–8K entries, to reuse recently selected tokens across steps. The paper finds this over-provisioned on the high-bandwidth pool: cutting to 2K saves 50–75% buffer HBM, raising miss rate from ~4–10% to 25%. At 128K, batch 64, miss rises from 5% to 30%, but step latency increases only 10.0% and throughput drops 9.1% — fetching more on the fast fabric is cheaper than reserving HBM.

The K-index stores compact keys for all historical tokens, organized in fixed-size pages. Systems like HiSparse keep all pages permanently in HBM. For GLM-5.3 at 128K, full index offload requires ~363 MB transferred per step per request, while 15% KV miss traffic is only 15.7 MB — a 20× difference. KV misses are dynamic, latency-sensitive, and must precede attention; K-index access is predictable, sequential, and bandwidth-hungry. Sharing one fabric with a single I/O strategy inevitably penalizes one path.

03 Fused Kernel: Fetch KV and Compute Attention Without Swap-In Phase

XM-Sparse builds on SGLang (~8K lines Python/C++/CUDA), modifying FlashMLA and adding a GPU-initiated DMA library. The decode GPU SMs run the indexer and a fused kernel; HBM holds only resident K-index pages, staging buffers, and the hot KV buffer; the pool stores full KV history and offloaded index pages. One decode step: prefetch index pages → select tokens → fused fetch KV and compute attention.

Existing swap-in kernels (e.g., HiSparse) launch one thread block per request, serializing fetches with warps. Scaling batch from 1 to 32 increases data 32× but average kernel latency only 74.1→78.9 μs (+6.5%), proving the bottleneck is launch overhead, not bandwidth. Fetched entries also land in HBM then shared memory — an extra copy.

The fused kernel merges fetch and compute. It uses online softmax to accumulate attention over selected tiles, traversing HBM-resident tiles first while hiding missing-tile fetches in that compute window. Split-K reorders tiles: hits first, misses later. Producer warps use TMA to move data directly into shared memory; consumers compute attention on the current tile while the next tile arrives. Dequantization happens mid-pipeline, and fetched quantized bytes are written back to the hot buffer to refill evicted slots (LRU policy). The buffer is sized to hold the full Top-K.

I/O path choice is empirically grounded. For 656 B reads, GPU load/store with 96 copy blocks hits 483 GB/s but cuts concurrent decode throughput 45.2% (latency 3.8 μs). TMA with 16 blocks achieves 394 GB/s, throughput drop only 6.3% (latency 1.9 μs). TMA at 32 blocks reaches 612 GB/s but throughput falls 29.4% (latency 4.3 μs). TMA suits low-latency KV fetch but consumes SM resources, making it unattractive for bulk prefetch.

The fused kernel alone reduces average TBT at 16K, batch 1 from 25.93 ms to 21.86 ms (15.7%) — measured with K-index offload disabled. Enabling index offload moves the bottleneck to prefetch scheduling; the two gains are not additive.

04 Index Prefetch: GPU-Generated DMA, CPU Batched Submit, Copy Engine Execution

Submitting 16 KiB pages via CPU DMA achieves only 22.9 GB/s; pre-queued copy engine reaches 632 GB/s. Descriptor generation and doorbell writes limit CPU submission to ~1.4M ops/s. For 656 B blocks, CPU submit is 0.92 GB/s vs. 58.8 GB/s pre-queued. CPU submit-to-complete latency averages 26.2 μs vs. 8.5 μs pre-queued. This startup cost rules out fine-grained on-demand fetch but fits page-level prefetch.

XM-Sparse moves command generation to the GPU: a single thread block on one SM reads the cache manager's copy list, writes DMA commands to pinned host memory, and increments a ready counter. A CPU worker polls the counter, batches submissions to the copy engine, and rings the doorbell. CPU work drops from per-page to per-batch; data movement runs on the copy engine without occupying SMs.

The cache manager allocates index pages within the HBM budget, evicting full older pages (preferring later pages, shared across indexer layers) when over budget, then gradually prefetching back. Before each decode step it checks: (1) HBM usage after new requests arrive, (2) whether transfer volume fits in the previous step's decode time. If either exceeds budget, requests queue. Dual staging buffers alternate; a layer's buffer is reusable once that layer's indexer finishes.

DMA itself doesn't use SMs, but concurrent 1 GiB, ~808 GB/s bulk transfers cut decode throughput 11.8%, primarily slowing MoE dispatch/combine NCCL kernels (+46.2%) while compute kernels only +4.1%. The fabric is shared. The scheduler protects three phases — fused attention, MoE dispatch, MoE combine — by modifying a semaphore via GPU kernel; the copy engine reads the semaphore at checkpoints in its command stream and pauses prefetch without CPU round-trip. In-flight segments complete. Checkpoint spacing ensures each segment's transfer time is far shorter than the protected operation.

05 Disentangling Hardware vs. Software Gains

Testbed: dual Xeon 6767P, 2 TB host RAM, eight B300 (268 GiB HBM each). Four GPUs run decode, four serve as memory nodes. Models: FP8 DeepSeek-V3.2 (671B, 61 layers) and GLM-5.3 (744B, 78 layers), DP4 attention, EP4 MoE. Requests from LongBench v2 (16K–1M input), fixed 128-token output. Default 4K hot buffer (~15% miss), 60 GiB resident budget.

vs. ECHO and HiSparse (PCIe), XM-Sparse achieves 1.72–2.50× / 3.14–4.98× (DeepSeek) and 1.57–1.75× / 2.05–4.52× (GLM) throughput gains. TBT drops 30–56% / 39–67% vs. ECHO and 7–36% / 9–46% vs. HiSparse.

Most gain comes from the hardware path: HiSparse + X-Mem already reaches 1437.9 tokens/s/GPU (batch 109) on GLM-5.3 128K. XM-Sparse on the same platform hits 1849.3 (batch 209) — the extra 1.29× is the software contribution (1.10–1.34× on DeepSeek). The 4.98× figure is the total system gain over PCIe, not attributable to the new kernel alone.

Ablation: fused kernel gives 15.7% TBT reduction at 16K batch 1 (no index offload). K-index offload adds 28.6% throughput at 128K. GPU-initiated DMA for 16 KiB pages achieves 624 GB/s vs. CPU submit 22.4 GB/s; at 1 MiB both approach 830 GB/s as submission overhead amortizes.

Hot buffer 4K→2K: XM-Sparse throughput +34.4% (16K) and +32.7% (32K), batch 278→507; HiSparse drops 23.2% and 19.5% — same change, opposite direction because XM-Sparse converts saved HBM into higher concurrency on the fast fabric. Miss sensitivity: at 16K batch 192, miss 0→40% raises XM-Sparse TBT 17.9% (72.09→84.98 ms) but HiSparse TBT 245% (72.36→250.17 ms). At 40% miss, XM-Sparse TBT is 66% lower than HiSparse. The buffer shrink trades per-request latency for batch throughput, amortizing extra fetch cost over more requests on the high-bandwidth path.

06 Where the Approach Breaks Down

Hardware simulation: The scale-up pool is emulated with four B300s as memory nodes via NVLink; capacity beyond 1 TB physical uses duplicate mapping. No real X-Mem device end-to-end numbers are provided. Lower fabric bandwidth or heavier model-communication sharing would shrink prefetch gains.

Narrow workload: Fixed 15% miss rate, round-robin expert routing, 128-token output, decode-only, FP8 weights. Real traces only align batch-level TBT. Changing any default (60 GiB budget, 4K buffer, Top-K 2048) requires re-evaluation.

Model differences: GLM-5.3 reuses keys across indexer layers; DeepSeek-V3.2 does not, affecting staging savings. Both tested only in FP8. Implementation is tied to SGLang (modified FlashMLA, custom GPU DMA library); porting to another framework requires re-integration.

Index transfer volume: At 128K, full index offload moves ~363 MB/step/request. Prefetch must finish before token selection, bounded by the previous step's compute window and fabric bandwidth. Longer contexts tighten this constraint further.

Admission criteria shift: In the PCIe era, a 4K hot buffer was justified — each miss was expensive. At 900 GB/s, fetching a little more is cheaper than reserving HBM. Batch admission now depends on two gates: HBM headroom and fabric time budget; checking only HBM capacity is insufficient.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

LLM inferencesparse attentionfused kernelGPU-initiated DMAindex offloadKV cache offloadscale-up memoryXM-Sparse

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion