groundy
infrastructure & runtime

DeepSeek-V4 FlashMemory: Sparse Attention for Million-Token Context

FlashMemory's learned index compresses DeepSeek-V4's KV cache to 13.5% of baseline at parity accuracy. The project is suspended; per-suite recall breakdowns are not published.

9 min · · · 5 sources ↓

FlashMemory-DeepSeek-V4 treats the KV cache as a retrieval problem: a small learned index decides which compressed memory blocks to page into GPU memory, and the paper reports it cuts the physical KV footprint to 13.5% of the full-context baseline at parity accuracy. Posted June 8 2026, the project is already suspended after its lead left Tencent, so the numbers are real but the maintenance is not.

The memory wall FlashMemory attacks

The per-token key/value tensors a model holds in VRAM so it does not recompute them sit resident on context the query may never read. The paper frames the problem directly: conventional LLMs keep the full KV cache loaded during decoding, causing a severe GPU memory bottleneck for ultra-long context serving. For a million-token sequence served densely, that residency is the dominant cost: every active request holds its full history in GPU memory, and throughput collapses into a memory-bandwidth tax.

FlashMemory is one entry in a crowded line of work attacking that tax. The sotaaz comparison of Flash and Sparse Attention notes that DeepSeek Sparse Attention at 128K context computes only 5-20% of the context while delivering 4-8x time-to-first-token improvement over standard attention, per their analysis. The shared premise is simple: do not attend to everything, attend to what matters, and pay for the rest only on demand. FlashMemory’s specific bet is that “what matters” is predictable enough that a learned index can page it in ahead of time.

How Lookahead Sparse Attention works

LSA is a small, surgical change to the Lightning Indexer that ships inside DeepSeek-V4. According to the paper, there are exactly two architectural departures: ReLU is replaced with a Sigmoid activation in the indexer, and Top-k block selection is replaced with a threshold gate that pulls any block whose indexer score I_{t,s} clears 0.5 (arXiv:2606.09079).

The difference between Top-k and threshold gating is load variability. Top-k always fetches k blocks whether the query needs them or not; a threshold can fetch zero blocks for a locally self-sufficient query, or many for one that genuinely spans the document. The Sigmoid swap matters because it turns the indexer output into something that reads as a calibrated relevance score per block, which is what makes a fixed 0.5 threshold interpretable rather than arbitrary.

Fetched blocks come out of what the paper calls a CPU Cold Pool: compressed KV entries staged in host memory, paged into GPU memory only when the index selects them (arXiv:2606.09079). The index runs ahead of decoding every 64 steps, which is the “lookahead” part. The system predicts which blocks the next 64 tokens will touch and stages them before the model asks.

The indexer is cheap to train. According to the paper, the Memory Indexer is trained via “backbone-free decoupled training,” a standalone dual-encoder over pre-computed representations that never requires loading the massive backbone model into GPU memory (arXiv:2606.09079). That is the detail that makes the technique portable in principle. You are not retraining a 284B-parameter model; you are training a small selector against frozen features.

What the benchmarks report, and what they average over

The headline figures, as reported by the paper: FlashMemory compresses the physical KV cache footprint to 13.5% of the full-context baseline, averaged across LongBench-v2, LongMemEval, and RULER, while posting +0.6% absolute accuracy over standard DeepSeek-V4-Flash. At 500K-token context, the paper reports physical KV overhead suppressed by over 90% “without destabilizing the backbone’s reasoning capacities.” The cache overhead figures were measured via SGLang deployment logs on an 8×H20 GPU server, per the paper.

The caveat that matters is the word “averaged.” Those three suites test different failure modes. LongBench-v2 is multi-task long-context QA, LongMemEval stresses multi-session memory recall, and RULER is explicitly designed to probe retrieval over synthetic needle-in-a-haystack patterns at controllable depths. The published figures are reported as combined averages. The per-suite split that would tell you whether the +0.6% is uniform, or whether gains on synthesis tasks are masking losses on retrieval, is not surfaced in the released summary.

That is not nitpicking. A sparse selector is also a filter: the same mechanism that drops irrelevant context can drop a block the query needed, and a blended benchmark average can stay positive while any single suite goes negative.

Where the index can silently miss

The failure mode for any sparse-attention scheme is recall, and the specific failure mode is silent. The index declines to page in a block the query needed, the model answers confidently from the context it did see, and the user gets no signal that evidence was dropped.

Needle-in-a-haystack retrieval is the canonical stress test, and it is a documented weak spot for sparse attention generally. The sotaaz analysis flags it directly: when the relevant token sits in an otherwise irrelevant block, the indexer has no prior reason to score that block highly. A threshold gate set at 0.5 does not help if the block holding the needle scores 0.49.

The paper’s own motivation cuts both ways. The premise that most long-context queries resolve from recent tokens is the upside case: most of the time the index correctly refuses to load distant context. But some fraction of queries genuinely need earlier material. RULER’s needle tasks live in that fraction. So does multi-document QA that synthesizes a fact from early in the context. The paper reports no scaling tests beyond 500K tokens (arXiv:2606.09079), and the per-suite numbers that would localize the misses are not in the released figures.

The suspended-project problem

The structural caveat on all of this is that the project is no longer being maintained. According to the paper, “Due to organizational realignments, the Project Lead has parted ways with Tencent,” and the authors invite external collaboration, compute sponsorship and scaling tests, via a contact address.

What that means in practice: the 500K-token ceiling is probably the ceiling. There is no production hardening pass, no integration into a maintained serving stack, and nobody on the other end of an issue tracker. The code and model release links are described in the paper but, as of 2026-06-10, their live status is not independently verified here. A team that wants to run this takes on the index training plus the integration tax of wiring CPU Cold Pool paging and the 64-step lookahead into whatever serving framework it uses, with no upstream support.

The baseline efficiency FlashMemory builds on

FlashMemory’s gains stack on a backbone that is already unusually cheap at long context. According to the DeepSeek-V4 technical writeup, V4-Pro (1.6T parameters, 49B activated) requires only 27% of single-token inference FLOPs and 10% of KV cache compared with DeepSeek-V3.2 at the one-million-token context setting. V4-Flash (284B parameters, 13B activated) is the lighter variant. Those are the vendor’s own figures, as of June 2026.

The FlashMemory paper reports its 13.5% cache footprint relative to the V4-Flash baseline (arXiv:2606.09079). The V4-Flash baseline is itself already compressed relative to V3.2 through the hybrid attention architecture, so the absolute saving is layered: the backbone buys most of the long-context efficiency, and the sparse index buys the rest by shedding the cache the backbone still holds resident.

What a team running V4-Flash on H20s actually gains

The honest takeaway is conditional. If your workload looks like the paper’s motivation data, long contexts where most queries resolve from recent tokens, then FlashMemory’s reported 13.5% cache footprint at parity accuracy is a real capacity win (arXiv:2606.09079). Fewer bytes per sequence means more concurrent sequences fit per H20, less VRAM is held on inactive history, and the indexer’s decoupled training keeps the adoption cost low. The SGLang-measured cache reductions on the 8×H20 server are the paper’s own numbers and the closest thing to a deployment-grounded figure in the release.

If your workload is retrieval-heavy, finding a specific clause in a contract, a specific line in a trace, a specific fact in a long document, the documented sparse-attention weakness on needle tasks applies, and the paper does not publish the per-suite breakdown that would quantify the regression on your specific failure mode. Combine that with a suspended project and no scaling data past 500K, and the decision is not whether this works but whether you have the retrieval profile for it and are prepared to maintain the integration yourself. For most teams the maintained sparse-serving option, SPIN, gets the architectural benefit without the orphan risk. FlashMemory’s specific contribution is the demonstration that a cheap, threshold-gated learned index can hold parity accuracy at 13.5% cache. Whether anyone ships that into production is now an open question.

Frequently Asked Questions

What does the absolute KV cache saving look like against DeepSeek-V3.2, not just V4-Flash?

V4-Flash already reduces KV cache to 7% of V3.2’s footprint at one-million-token context. FlashMemory compresses that further to 13.5% of the V4-Flash baseline. Stacked, the absolute saving is roughly 0.95% of V3.2’s full KV cache (0.07 multiplied by 0.135). The backbone’s hybrid attention architecture buys the first 93% reduction; the sparse index buys most of the remaining 7%. Teams still on V3.2-era models capture the larger share of the gain from upgrading the backbone alone, before adding a sparse selector.

What fraction of real requests actually need the early context that FlashMemory might drop?

The paper’s own inference-log analysis found that over 90% of user requests with contexts longer than 64K tokens resolve using only the last 8K tokens. The remaining roughly 10% are queries that genuinely require earlier material: multi-document synthesis, contract clause lookup, trace analysis. The threshold gate can decline to page in the relevant block for those queries, and the model answers from what it did see with no warning that evidence was omitted. The paper does not isolate accuracy for this 10% subset.

How does FlashMemory’s index approach differ from what SPIN does at the system level?

SPIN co-designs an execution pipeline with hierarchical GPU-CPU KV storage on top of vLLM, targeting throughput and TTFT gains through sparse-attention-aware scheduling. FlashMemory attacks from the selector side: a learned Sigmoid-threshold index that predicts block relevance 64 decoding steps ahead. The practical distinction is that SPIN is a deployable vLLM framework maintained by an active team, while FlashMemory’s contribution is the index mechanism itself, which requires custom integration into whatever serving stack you run. A team could theoretically layer FlashMemory’s learned index on top of SPIN’s memory management, though no published results test that combination.

Can a team run FlashMemory inference on fewer than the 8 H20 GPUs used in the benchmarks?

The CPU Cold Pool offloads compressed KV entries to host memory rather than GPU VRAM, so the GPU-side memory pressure per sequence is already reduced to 13.5% of the dense baseline. The practical bottleneck shifts to whether host RAM can hold the full compressed context for all concurrent sequences and whether PCIe transfer latency fits your TTFT budget. The indexer trains in a single H20 GPU hour without ever loading the backbone, so the adoption cost for the selector is minimal. GPU count for inference serving depends on your throughput and concurrency targets, not on the Cold Pool architecture itself.

sources · 5 cited

  1. FlashMemory-DeepSeek-V4: Lightning Index Ultra-Long Context via Lookahead Sparse Attention primary accessed 2026-06-10
  2. FlashMemory-DeepSeek-V4 (full HTML) primary accessed 2026-06-10
  3. Flash Attention vs Sparse Attention: The Key to Faster LLM Inference analysis accessed 2026-06-10
  4. Unifying Sparse Attention with Hierarchical Memory for Scalable Long-Context LLM Serving (SPIN) primary accessed 2026-06-10
  5. DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence primary accessed 2026-06-10