Offloading KV cache to host RAM via QSA: ~1M context on one RTX 3090 at ~5% speed cost

TheActualStudy · reddit · 2026-12-06

Using Qwen4-35B-A3B's trained sparse attention (QSA), the author offloads the full KV cache to pinned host RAM in their Rust engine inference.rs: each query attends only to the top 512 four-token blocks chosen by a compact in-VRAM indexer, so 98% of reads hit VRAM and outputs stay bit-identical. On one RTX 3090 (24GB, 128GB RAM, 4.5-bit GGUF, q8 KV): max context jumps from 192K to 1,048,576 tokens, decode drops only 3-4% (115 tok/s at 32K), 262K prompts prefill in 272s then decode at 86 tok/s, and even a 983K-token prompt runs.

Original post →

More from Infra

Infra channel →