Trending › Paper
HySparse2: how sharing the cache lets prefill stop halfway
Xiaomi’s HySparse2 lets the second half of a model borrow the cache built by the first half, so reading a long prompt can stop halfway. The paper reports a 1M-token cache of 2.69 GB instead of 12.09 GB and about 5× less prefill compute.
Watch it move. This is an animated lesson on Gradient Lab.
Start the animated lessonStep by step
Agents read far more than they write
An agent keeps feeding a model long tool outputs, files and logs, then gets back a short action. Reading that input is called prefill: every layer of the transformer runs over the whole prompt and stores its keys and values in the KV cache. With 1M-token prompts, prefill and the cache dominate the cost.
Each slab is a layer. In a normal model, every layer runs over the full prompt during prefill.
Split the model into two halves
Following the YOCO idea, HySparse2 splits the stack into a self-decoder (bottom half) and a cross-decoder (top half). The bottom half works like a normal model. The top half doesn’t build its caches from the prompt directly.
Teal: the self-decoder. Purple: the cross-decoder.
KV bridging: build the top caches from the bottom
The full-attention layers in the top half get their caches by projecting hidden states that the bottom half already computed. The paper calls this KV bridging. Because every top cache comes from the bottom half, prefill can stop once the bottom half is done.
Grey slabs never run during prefill. Arrows: bottom-half states projected into top-half caches.
KV reuse: sparse layers borrow too
Inside each block, a full-attention layer is followed by cheaper sparse attention layers. They reuse the full layer’s cache and its list of which tokens matter, instead of keeping their own. HySparse2 also picks individual tokens rather than whole blocks of them.
One full layer (bright) feeds the sparse layers above it.
The reported result
On an 80B-parameter mixture-of-experts test model with 3B active, the authors report that a 1M-token cache takes 2.69 GB, against 6.72 GB for the original HySparse and 12.09 GB for the hybrid sliding-window design Xiaomi used before. Prefill compute falls about 5×, and long-context retrieval scores improve. The paper notes it doesn’t lift general reasoning everywhere.
Bar heights to scale: KV cache at 1M tokens (FP8 storage), as reported in the paper.
Quick check: Why can HySparse2 stop prefill halfway through the model?
- It skips the second half of the prompt
- The top half’s caches are built from states the bottom half already computed (correct)
- It stores the cache in 1-bit numbers
Pseudocode
# prefill: read the whole prompt once, fill every layer's KV cache
for layer in all_layers: # usual model: every layer runs
cache[layer] = keys_values(prompt)
# HySparse2: two halves
for layer in self_decoder: # first half runs on the prompt
h = layer(h)
for full_layer in cross_decoder: # second half's caches are built
cache[full_layer] = project(h) # from first-half states: "KV bridging"
# prefill can stop here
# inside each block, sparse layers reuse the full layer's cache
# and its choice of important tokens: "KV reuse"