PAPER DEEP DIVE
DFly2: Turbocharging Long-Context Speculative Decoding by Sharing the Target's Sparsity
DFly2 reuses the target model's sparse KV latents and top-k indices to generate block-parallel drafts at constant context cost.
Paper Metadata
- Title: DFly2: Turbocharging Long-Context Speculative Decoding by Sharing the Target’s Sparsity
- Authors: Hong Liu, Rui Cen, Junhan Shi, Lin Niu, Runzhi Fan, Zhaojing Zhou, Haodi Lei, Jiebin Zhang, Saiyong Yang, Junqiang Zheng, Zhenghai Xue, Guanghua Yu, and Jianchen Zhu
- Affiliation: Tencent
- Paper: https://arxiv.org/abs/2611.34776
- Code: Tencent/AngelSpec, inspected at commit
e02ea36e65d44e6e165c4ba73c139d500e12f2d9 - Topics: large language models, speculative decoding, sparse attention, KV cache, long context, inference acceleration
One-Sentence Summary
Core result: DFly2 turns a sparse target model’s per-query top-k attention choice into a reusable drafting resource, so a block-parallel drafter can read a fixed set of query-relevant positions from the target cache without maintaining a context cache or running its own indexer.
Why This Problem Matters
Long-context inference makes speculative decoding more valuable and more difficult at the same time. A target model may need tens of thousands of prompt tokens for an agent trace, a code repository, or a multi-turn conversation, yet each decoding round still revisits state that was computed much earlier. Proposing several tokens and verifying them in one target pass reduces the number of expensive target executions. The apparent gain is straightforward: replace several serial decode steps with one draft pass and one verification pass.
The engineering cost is hidden in the drafter. DFlash-style block-parallel drafters project hidden states from several target layers into their own keys and values, inject that representation into every draft layer, and fill a complete proposal block in one forward pass. The context representation improves draft quality, but it must be built over the whole prompt, transferred in disaggregated serving, and retained per active request. DSpark reduces that burden to a recent window. Neither route changes the basic ownership model: the drafter still carries context state of its own.
That ownership becomes increasingly awkward as target models become natively sparse. A sparse target stores compressed latent state and attends to only a fixed number of positions selected by a trained indexer. The target’s long-context savings therefore make its KV cache smaller, but a conventional drafter still adds a full three-layer cache. On DS-V4.1-Flash, the paper reports that a drafter-owned cache increases total per-token KV from 4.4 KiB to 7.8 KiB. The drafter has become a larger relative fraction of the memory problem precisely because the target became more efficient.
The cost is not limited to memory. Under prefill-decode disaggregation, the drafter must run on prefill instances and build its representation for every prompt position. The extra state competes with target prefixes in the cache pool and may shorten reusable prefix hits. During decode, the cache remains resident for every in-flight request. The paper estimates that removing it allows 1.73 times as many DS-V4.1-Flash requests to fit at 32K tokens. These effects explain why accepted length alone cannot judge a long-context drafter.
A second problem is position selection. A fixed recent window costs a constant amount of attention work, but it cannot adapt to the current query. A new indexer can select relevant old positions from anywhere, but scoring the entire context recreates a context-dependent cost on the drafting side. The authors’ central observation is that a natively sparse target has already solved both problems for every verified token. It owns the compressed cache and has just evaluated a trained indexer. The drafter does not need to infer which context matters if it can reuse the target’s answer.
Background
What limits speculative decoding
Let the drafter propose $\gamma$ tokens and let the target verify the longest acceptable prefix plus one bonus token. If the mean accepted length is $\tau$, the latency per output token can be expressed as:
$$ T_{\mathrm{tok}}= \frac{T_{\mathrm{draft}}+T_{\mathrm{verify}}}{\tau}. $$
The draft cost separates into fixed projections, feed-forward computation, and an output head, plus attention over the $m$ context positions that the drafter reads:
$$ T_{\mathrm{draft}}= T_0+T_{\mathrm{attn}}(m). $$
A good system must increase $\tau$ without allowing $m$, and therefore context attention cost, to grow with the prompt. This decomposition also shows why a very small window can be fast but weak: it minimizes the second term while sacrificing the evidence needed to raise the numerator.
How native sparse attention works
DeepSeek Sparse Attention uses a lightweight indexer to score each query against the cached context, then applies the expensive attention operation to a fixed top-k subset. For a query $h_t$, context latent $c_s$, and score $I_{t,s}$, the selected set and output are:
$$ u_t= \operatorname{Attn}\left(h_t,\{c_s\mid s\in S_t\}\right), \qquad S_t= \{s\mid I_{t,s}\in\operatorname{TopK}(I_{t,:})\}. $$
The set $S_t$ is query-dependent even though its cardinality is fixed. It can include a distant code definition or an earlier instruction that a recent-window drafter would never see. The target already performs the scoring pass during verification. DFly2’s hypothesis is that the resulting set can serve not only the verified token but also several speculative tokens that follow it.
Method
Pairing one draft layer with one sparse target layer
DFly2 has three draft layers and assigns each one a sparse target layer. The pairings are not adjacent copies. DS-V4.1-Flash uses layers 28, 32, and 36. GLM-5.3-Flash uses 35, 39, and 43. Hy4 flash uses 33, 37, and 41. Each chosen target layer has its own indexer and exposes the latent cache needed by the corresponding draft layer.
The spacing matters. In DS-V4.1-Flash, layers 37 to 39 reuse the top-k selected at layer 36, so a drafter paired with those layers would read the same context view three times. Replacing the original 28, 32, and 36 pairing with an adjacent 37 to 39 group lowers every one of the reported twelve cells and costs 4.6% average accepted length. Three independent indexers give the drafter three different views of the prompt at the same read budget.
Reading the target cache, not rebuilding it
For draft layer $i$, the paired target layer $L_i$ supplies latent state at the selected positions $R_i$. The drafter applies its own up-projections to form context keys and values:
$$ (X_i,Y_i)= \left(W_i^{UK}C^{L_i}_{R_i}, W_i^{UV}C^{L_i}_{R_i}\right), \qquad C^{L_i}_{R_i}= \{c_s^{L_i}\}_{s\in R_i}. $$
The current block is still represented by draft-side latents. Context latents and block latents are concatenated before attention, so one attention operation covers both the selected prompt evidence and the speculative slots:
$$ K_i= W_i^{UK}\left[C^{L_i}_{R_i};W_i^D H_{\mathrm{blk}}\right], \qquad V_i= W_i^{UV}\left[C^{L_i}_{R_i};W_i^D H_{\mathrm{blk}}\right]. $$
The target shares runtime cache pages, not its learned projection parameters. Every projection shown above belongs to the trainable drafter. The important deployment property is that DFly2 never allocates a second context cache for those projections. In vLLM, it registers no KV group and reads pages already owned by the target.
Using one selection across the whole block
The draft layer reuses the top-k selected by its paired target layer at row $A-1$, where $A$ is the anchor row. It may also include the target’s near-window latents:
$$ R_i=S_{A-1}^{(L_i)}\cup\mathcal{N}, \qquad m=|R_i|. $$
This one set serves all five draft slots. DS-V4.1-Flash reads 512 selected positions plus 128 near-window positions and six block rows, for 646 positions per draft step. GLM-5.3-Flash uses 512 groups of four positions, producing 2,054 positions including block rows. Hy4 flash selects 2,048 positions and needs no separate near-window term. The drafter inherits these budgets rather than tuning a window per target.
The nontrivial question is temporal: a selection made for the token before the anchor must cover what later block rows would select for themselves. The paper defines top-k mass coverage over the target index-score distribution:
$$ \operatorname{Cov}(t)= \frac{\sum_{s\in S_{A-1}}p_t(s)} {\sum_{s\in S_t}p_t(s)}. $$
Across 158,638 blocks on DS-V4.1-Flash, the one-step-earlier selection covers roughly 0.873 to 0.880 of the score mass that each later row would select. A recent window with the same number of positions covers only 0.147 to 0.175. Coverage declines gradually across slots, and the deepest layer’s final slot still retains about four fifths. The authors attribute this persistence to content rather than absolute position: rotating the query among nearby rows leaves the selected top-k unchanged in all 72 checked slot, layer, and context cells.
Starting draft weights in the target’s representation
Pairing also initializes the draft layer from its target counterpart. Attention uses the target layer’s query, KV, and output projections, together with copied normalization parameters:
$$ O_i= W_i^O\operatorname{Attn} \left( W_i^{UQ}\operatorname{Norm}(W_i^{DQ}H_{\mathrm{blk}}), K_i,V_i \right), \qquad W_i^\star\big|_{\mathrm{init}}= W_{L_i}^\star. $$
This does more than accelerate optimization. On a natively sparse model, the target layer’s query down-projection is also part of the path that feeds its indexer. Copying it places initial draft queries in the same latent space that produced the selected positions. The drafter still learns its own parameters, but it does not begin by searching for the target’s representation.
The feed-forward side follows the same principle. Each draft layer draws a fixed subset of routed experts from its paired target layer and copies their weights, router rows, correction bias, shared expert, and post-attention norm. Only expert ids are sampled uniformly. Ablation shows the two initialization halves contribute similarly: attention-only initialization loses 1.6%, while feed-forward-only initialization loses 1.1%. The value comes from pairing the source of context with weights that already know how to process it.
Injecting the state that the cache cannot provide
The target’s sparse cache does not contain the last-layer hidden state used to generate the anchor. DFly2 therefore fuses that state with the anchor embedding and adds it through a gate initialized at zero. This preserves the original block path at the start of training and lets the model learn how much anchor evidence to inject.
Under disaggregated serving, the state adds only one vector per request to the prefill-to-decode transfer. Broadcasting the same vector to every draft slot performs about as well as injecting it only at the anchor, so the method chooses the smaller single-entry path. The last-layer state complements shared context rather than replacing it: the cache explains what history the anchor attended to, while the hidden state describes how the target summarized that history before producing the anchor.
Sequential correction inside a parallel block
TreeFlash’s hidden-state correction updates slot $k$ from its current hidden state and the token drafted at slot $k-1$. This cannot recover information that was never present in the slot. If the draft has started writing a value from the wrong row, a purely local SwiGLU cannot reopen the prompt and find the correct value. DFly2 therefore adds two attention reads after the parallel backbone while retaining the inherited update:
$$ h_k\leftarrow h_k+ \operatorname{SwiGLU}(z_k)+ W_c^O\operatorname{Attn}\left(q_k,C^{L_i}_{R_i}\right)+ g_k\odot\operatorname{Attn}\left(q_k,h_{0:k}\right), $$
where $z_k=[\operatorname{Norm}(h_k);\operatorname{Norm}(\operatorname{Emb}(y_{k-1}))]$. The context read uses the same shared latents as the draft layer. The prefix read sees only slots up to $k$, preserving the autoregressive relationship without making the main five-slot backbone sequential. Per-head gates and the new output projection start at zero, so correction begins from the inherited path and learns its additional dependencies.
This is the only sequential part of a draft step. Removing both attention reads lowers accepted length from 3.57, 3.62, and 3.75 to 3.47, 3.51, and 3.65 on the general, long-context, and agentic families. The mechanism matters, but it is inexpensive in the tested setting: the two reads consume less than 1% of a decode step on a tensor-parallel engine with eight GPUs.
Training for the serving distribution
Only the drafter is trained. Every slot is matched to the target distribution at that position, and slots are weighted by the expected accepted length remaining after earlier slots. The per-slot loss combines KL divergence and total variation:
$$ \ell_k= \lambda_k\operatorname{KL}(p_k\Vert\hat p_k)+ (1-\lambda_k)\operatorname{TV}(p_k,\hat p_k), \qquad \mathcal{L}= \frac{\sum_{k=1}^{\gamma}w_k\ell_k} {\sum_{k=1}^{\gamma}w_k}. $$
Serving reuses the selection produced by target verification. Training has no online verify pass, so it recomputes the same sparse selection with a frozen copy of the paired target layer’s indexer. This alignment prevents a train-serve mismatch in which the drafter learns from a recent window but is later asked to use a query-dependent candidate set.
Paper-specific execution graph
flowchart LR
V[Target verify pass] --> H[Last hidden state]
V --> K[Paired sparse KV latents]
V --> I[Target indexer top-k]
I --> R[Fixed read set R_i]
K --> A[Paired draft attention]
R --> A
H --> G[Gated anchor fusion]
G --> B[Five-slot parallel block]
A --> B
B --> C[Sequential context and prefix correction]
C --> D[Draft probabilities]
D --> N[Next target verification]
N --> V
The graph clarifies the role of verification. It is not only an accept or reject stage at the end of the loop. It also produces the hidden state, sparse latents, and index selection that seed the next draft step. DFly2 moves work out of the drafter by making that feedback path explicit.
Experiments
The evaluation covers three natively sparse targets: DS-V4.1-Flash, GLM-5.3-Flash, and Hy4 flash. Their sparse layers differ in cache sharing, interleaving with linear attention, and two-stage index compression. The baselines are DFlash with a full draft cache, DFlash† with an equal-sized recent window, and DSpark with a sliding-window cache. All drafters share the same data, training recipe, three-layer mixture-of-experts structure, and five-token block.
DFly2 beats both baselines in all 18 general-purpose cells. On the general family, its average accepted length exceeds the stronger baseline by 3.9% to 10.5%. The advantage grows to 10.0% to 31.5% on long-context and agentic workloads. The pattern appears at both greedy and stochastic temperatures and across all three target architectures.
| Target | Drafter | General average | Long-context average | Agentic average |
|---|---|---|---|---|
| DS-V4.1-Flash | DSpark | 3.81 / 3.51 | 3.23 / 2.79 | 3.35 / 3.08 |
| DS-V4.1-Flash | DFly2 | 4.12 / 3.88 | 3.74 / 3.32 | 4.06 / 3.75 |
| GLM-5.3-Flash | DSpark | 3.68 / 3.35 | 3.05 / 2.64 | 3.10 / 2.99 |
| GLM-5.3-Flash | DFly2 | 3.96 / 3.69 | 3.85 / 3.36 | 4.03 / 3.68 |
| Hy4 flash | DSpark | 3.81 / 3.73 | 3.20 / 3.01 | 3.16 / 2.95 |
| Hy4 flash | DFly2 | 3.96 / 3.95 | 3.63 / 3.46 | 4.11 / 3.88 |
Table 1: Mean accepted length from the paper’s Tables 6 and 7. Values are greedy / stochastic, with temperature 0.9 for stochastic decoding on Hy4 flash. Long and agentic columns average their respective task sets.
The long-context results expose two different baseline failure modes. A recent-window drafter cannot reach old evidence, while a full-cache drafter remains exposed to train-length mismatch. DFlash on Hy4 flash falls to as few as 1.08 accepted tokens per step after 32K, even though it can see the whole context. DFly2 keeps the candidate positions globally reachable but keeps their number constant. The drafter therefore sees the same attention shape in training and at 128K serving.
Figure 1: The paper’s teaser result. DFly2 is compared with three baselines on long-context and agentic tasks spanning 32K to 128K, with accepted length above and decoding speedup below.
The selection coverage study supports the reuse assumption directly. With the same position budget, the previous target selection retains 0.873 to 0.880 score mass on average, while the equal-sized recent window retains 0.147 to 0.175. Coverage is stable as context grows because the target selection can move anywhere in the prompt. A fixed window covers a decreasing fraction of a growing context even when its absolute number of tokens remains efficient.
Figure 2: The paper’s Figure 3. The target selection remains far ahead of a recent window by budget, across draft slots, and across context lengths.
End-to-end service results preserve the single-request advantage. Relative to DSpark, DFly2 improves decode speed by 2% to 6% on general workloads, 6% to 18% on long-context workloads, and 12% to 30% on agentic workloads. Its end-to-end lead is larger than its decode-only lead on long prompts because it adds no prompt-wide cache construction and therefore no additional prefill latency. On DS-V4.1-Flash agentic sets, DFlash variants can end up slower than no speculation because their cache overhead outweighs the accepted tokens.
At high concurrency, DFly2’s curve remains outside the baselines as batch size grows. At matched per-user decode speed on DS-V4.1-Flash, it reaches 28% more throughput on short text, 62% more on CodeSpan 64K, and 81% more on SWE 64K. At matched total throughput, each user decodes 15% to 24% faster. The authors’ explanation is structural: the target cache is already present, while removing the drafter cache releases both memory capacity and repeated context work.
Figure 3: The paper’s Figure 7. DFly2 is measured on short text, CodeSpan 64K, and SWE 64K across concurrency levels. Dashed guides compare DFly2 with DSpark at equal speed and equal throughput.
What the ablations isolate
The largest gain comes from using the target’s selection, not from sharing the KV allocation by itself. Removing the top-k and leaving only the near window lowers accepted length to 3.14, 2.76, and 2.95 on the general, long-context, and agentic families of DS-V4.1-Flash. The full method reaches 3.57, 3.62, and 3.75. The gap is widest on long contexts, exactly where a fixed position rule misses the most globally selected evidence.
Conversely, keeping the selected positions but restoring a private drafter cache changes accepted length only slightly. That setting falls to 3.46, 3.34, and 3.37 because the shorter window cannot preserve the same long-range state. The cost is still much smaller than losing top-k. This result separates the two contributions: selection sharing raises draft quality, while cache sharing removes serving overhead that accepted length cannot reveal.
| Configuration | DS-V4.1 general | DS-V4.1 long | DS-V4.1 agentic | GLM general | GLM long | GLM agentic | Hy4 general | Hy4 long | Hy4 agentic |
|---|---|---|---|---|---|---|---|---|---|
| Full DFly2 | 3.57 | 3.62 | 3.75 | 3.56 | 3.67 | 3.91 | 3.36 | 3.46 | 3.76 |
| Without near window | 3.45 | 3.50 | 3.63 | 3.57 | 3.68 | 3.86 | 3.36 | 3.45 | 3.77 |
| Without target top-k | 3.14 | 2.76 | 2.95 | 3.42 | 3.10 | 3.34 | 3.31 | 3.12 | 3.13 |
| Private drafter cache | 3.46 | 3.34 | 3.37 | 3.46 | 3.18 | 3.43 | 3.32 | 3.14 | 3.17 |
Table 2: The paper’s Table 10. Mean accepted length is averaged over each family’s task sets and four sampling settings. Removing top-k selection causes the largest and most context-sensitive loss.
Other ablations support the pairing design. Changing the DS-V4.1 pairing from layers 28, 32, and 36 to adjacent layers 37 to 39 reduces accepted length by 4.6%, since those layers reuse one context view. Removing the two attention reads in correction lowers the three family averages to 3.47, 3.51, and 3.65. Removing hidden-state injection lowers them to 3.51, 3.56, and 3.68. Attention-only and feed-forward-only initialization each lose about half of the benefit of copying both sides from the paired layer.
Figure 4: The paper’s Figure 4. Three paired draft layers share the target cache and selection, receive the last-layer hidden state at the anchor, and apply correction slot by slot.
Figure 5: The paper’s Figure 5. The left side contrasts full cache injection, a sliding window, and sparse KV plus index sharing. The right side shows the query latent shared with the target indexer while the indexer itself is omitted from the drafter.
Figure 6: The paper’s Figure 6. The block backbone remains parallel; correction runs from left to right so each slot can read shared context and the already corrected prefix.
What the YOCO analysis adds
DS-V4.1-Flash shares one latent cache across layers, so the drafter can explore multiple ways of expanding the reuse set. The baseline read is the target’s top-512 from the row before the anchor. Adding two earlier history rows raises index-score recall from about 0.80 to 0.86 at fewer than 1K positions. The union of five target indexers reaches about 0.85 at 1.4K positions. Reading top-2K per row reaches about 0.89.
A union of selection plus three history rows reaches about 0.91 at 2.6K positions. Even 2K positions add only about 0.19% to a decode step in the reported regime, while reading the full context costs 14% to 23% at 128K. Capped near 2K positions, this expanded read matches the accepted length of reading every first-stage candidate block, which may contain up to eight times as many positions. The result gives a concrete route for future tuning without changing the core cache-sharing model.
Limitations
Applicability is deliberately narrow. The paper has no formal limitations section, but its equations establish a hard prerequisite: the target must expose reusable sparse KV latents and a query-dependent top-k selection. DFly2 is not defined for dense attention models, and it cannot be applied through an API that exposes only logits. A deployment also needs control over the target’s serving path so the drafter can read the target pages without registering duplicate KV state.
Only three related sparse targets were tested. DS-V4.1-Flash, GLM-5.3-Flash, and Hy4 flash differ meaningfully in cache and index structure, which is stronger evidence than a single target. They nevertheless belong to one broad sparse-attention family, and all experiments use Flash-class targets. The paper does not establish behavior on much larger sparse models, different indexer training schemes, or targets without three useful independent sparse layers for pairing.
Evaluation stops at 128K. The fixed read budget should make the method easier to extrapolate, but the experiments do not test prompts beyond 128K. At greater lengths, the target indexer’s selection quality, positional behavior, throughput characteristics, and correction cost could change. The claim that DFly2 inherits the target’s long-context generalization is supported through 128K, not indefinitely.
The correction stage remains sequential. The backbone fills the block in parallel, but context and prefix attention read slots from left to right so later slots can depend on earlier corrected ones. The paper measures this stage below 1% of a decode step on the chosen model and tensor-parallel setup. Larger blocks or slower inter-device communication could change that balance, so the overhead should be re-measured for a different deployment.
Conclusion
DFly2’s contribution is a change in ownership. Instead of asking how a small drafter can reconstruct the context, it asks what the target has already computed and paid for. The answer includes compressed latent KV, a trained query-dependent selection, matching layer weights, and the last hidden state behind the anchor. Those objects serve complementary roles, and reusing all of them removes the drafter’s cache, indexer, and context-growing attention path.
The results show why selection sharing matters most for long context. A target can keep a fixed number of globally reachable positions even as the prompt grows. A drafter trained on that shape does not need to enlarge its input at 64K or 128K. Across three architectures, DFly2 gains more accepted length than DFlash and DSpark, and the advantage expands on the workloads where recent-window and train-length assumptions are weakest.
The method also opens a systems research direction beyond this paper. Serving stacks could expose target sparse selections as a first-class drafting interface, and schedulers could allocate read budgets by request or layer. The YOCO experiments suggest that small additions to the shared selection can recover most of the remaining recall. If those extensions preserve the same zero-copy target cache contract, speculative decoding on sparse models can remain both lossless and economical as contexts continue to grow.
Golden Quote
A sparse target has already paid for a query-aware choice. The fastest drafter does not compute that choice again; it follows the one that is already there.



