# DFly2: Turbocharging Long-Context Speculative Decoding by Sharing the Target's Sparsity

> DFly2 shares a natively sparse target's KV cache and attention selection with its drafter, boosting speculative decoding speedups by up to 31.5% on long-context workloads.

- **Source:** [arXiv](https://arxiv.org/abs/2611.34776)
- **Published:** 2026-11-28
- **Permalink:** https://picx.dev/p/XLjalH
- **Whiteboard:** https://picx.dev/p/XLjalH/image

## Summary

# Summary of DFly2: Turbocharging Long-Context Speculative Decoding by Sharing the Target's Sparsity

## Summary (Overview)

- **Core contribution**: DFly2 is a block-parallel speculative decoding drafter that shares both the KV cache *and* the sparse attention selection of its natively sparse target model, eliminating the need for a drafter-owned context cache and scoring pass.
- **Key insight**: A natively sparse target (e.g., DeepSeek-V4, GLM-5, Hy4) already computes a query-aware position selection for every token via its trained indexers; this selection, made one step early, covers ~90% of what later tokens in a draft block would select, far exceeding a sliding window of the same size.
- **Mechanism**: Each DFly2 draft layer reads the KV cache of a paired target layer (KV sharing) at the positions that layer's indexer selected (Index sharing), and initializes its weights from that same paired layer.
- **Results**: DFly2 consistently outperforms DFlash and DSpark baselines (trained on the same recipe) in accepted length and end-to-end speedup across three targets with different sparse attention architectures, with margins growing from 3.9%–10.5% on general workloads to 10.0%–31.5% on long-context and agentic workloads (up to 128K tokens).
- **Serving efficiency**: On DS-V4.1-Flash at high concurrency with matched per-user decode speed, DFly2 delivers 62% and 81% more throughput on long-context and agentic sets at 64K, plus 28% more on short text.

## Introduction and Theoretical Foundation

### Background and Motivation

The paper addresses the growing cost of decoding long contexts in large language models. Recent long-context models (DeepSeek-V4, GLM-5, Hy4) have adopted **natively sparse attention** (e.g., DeepSeek Sparse Attention, DSA), where each layer attends only to a fixed budget of positions selected by a trained indexer. This reduces both compute and KV cache memory. However, speculative decoding drafters—which propose tokens for the target to verify—were designed for dense targets and still maintain their own context caches, creating several inefficiencies.

### Key Theoretical Foundations

**Speculative decoding latency model**: The latency per generated token is

$$T_{tok} = \frac{T_{draft} + T_{verify}}{\tau}$$

where $\tau$ is the mean accepted length (1 ≤ τ ≤ γ+1), and drafting time splits into

$$T_{draft} = T_0 + T_{attn}(m)$$

with $m$ being the number of context positions the drafter reads.

**Sparse attention formulation**: In a DSA layer, each query token $h_t$ attends only to a set $S_t$ of positions selected by an indexer:

$$u_t = \text{Attn}\left(h_t, \{c_s | s \in S_t\}\right), \quad S_t = \{s | I_{t,s} \in \text{Top-}k(I_{t,:})\}$$

### The Three Costs of a Drafter's Own Cache

1. **Prefill**: The drafter must run on prefill instances, projecting and transferring its cache, delaying first token.
2. **Prefix caching**: The drafter's cache (projected from target hidden states, which prefix caching doesn't keep) must be stored or rebuilt, reducing cache hits.
3. **Decode concurrency**: A full drafter cache adds significantly to per-token KV memory. For a memory pool of $M$ bytes, concurrency is $M/(bL + f)$ where $b$ is per-token KV, $L$ is context length, and $f$ is fixed per-request state.

## Methodology

### DFly2 Architecture

DFly2 consists of three draft layers, each paired with a target DSA layer. The design has four key components:

**1. KV Sharing**: Each draft layer reads the target's cached latents directly:

$$(X_i, Y_i) = \left(W^{UK}_i C^{L_i}_{R_i}, W^{UV}_i C^{L_i}_{R_i}\right), \quad C^{L_i}_{R_i} = \{c^{L_i}_s\}_{s \in R_i}$$

where $c^{L_i}_s$ is the latent cached by target layer $L_i$ at position $s$, and $R_i$ is the set of positions read. The block's own hidden states are compressed and appended:

$$K_i = W^{UK}_i [C^{L_i}_{R_i}; W^D_i H^{blk}], \quad V_i = W^{UV}_i [C^{L_i}_{R_i}; W^D_i H^{blk}]$$

**2. Index Sharing**: The read positions come from the target's own selection:

$$R_i = S^{(L_i)}_{A-1} \cup \mathcal{N}, \quad m = |R_i|$$

where $S^{(L_i)}_{A-1}$ is the top-$k$ selected by layer $L_i$'s indexer at row $A-1$ (the anchor's preceding token), and $\mathcal{N}$ is the target's near window before the anchor (if not already covered by top-$k$).

**3. Weight Initialization**: Each draft layer starts from its paired target layer's weights:

$$O_i = W^O_i \text{Attn}\left(W^{UQ}_i \text{Norm}(W^{DQ}_i H^{blk}), K_i, V_i\right), \quad W^\star_i \leftarrow W^\star_{L_i}$$

The feed-forward side draws a random subset of the target layer's routed experts:

$$\theta^{exp}_i \leftarrow \theta^{exp}_{L_i}[E_i], \quad E_i \sim \text{Unif}\{B \subseteq E_{L_i}: |B| = E\}$$

**4. Intra-Block Correction**: A sequential correction per slot combines an inherited SwiGLU update with attention reads of the context and the block:

$$h_k \leftarrow h_k + \text{SwiGLU}(z_k) + W^O_c \text{Attn}(q_k, C^{L_i}_{R_i}) + g_k \odot \text{Attn}(q_k, h_{0:k})$$

where $z_k = [\text{Norm}(h_k); \text{Norm}(\text{Emb}(y_{k-1}))]$, and $g_k$ is a per-head gate starting at zero.

**Training objective**: Single-stage distillation loss with D-PACE weights:

$$\mathcal{L} = \frac{\sum_{k=1}^\gamma w_k \ell_k}{\sum_{k=1}^\gamma w_k}, \quad \ell_k = \lambda_k \text{KL}(p_k \| \hat{p}_k) + (1-\lambda_k) \text{TV}(p_k, \hat{p}_k)$$

### Target-Specific Configurations

| Target | Paired Layers | Top-k | Near Window | Positions/step |
|--------|--------------|-------|-------------|----------------|
| DS-V4.1-Flash | [28, 32, 36] | 512 | 128 | 646 |
| GLM-5.3-Flash | [35, 39, 43] | 512 pools of four | – | 2,054 |
| Hy4 flash | [33, 37, 41] | 2,048 | – | 2,054 |

## Empirical Validation / Results

### Key Measurement: Coverage of Shared Selection

The paper measures **top-k mass coverage** on DS-V4.1-Flash:

$$\text{Cov}(t) = \frac{\sum_{s \in S_{A-1}} p_t(s)}{\sum_{s \in S_t} p_t(s)}$$

- The shared selection (made one step early) achieves **0.873–0.880 coverage** vs. only 0.147–0.175 for a window of the same size.
- Coverage declines gradually along the block: the deepest layer's last slot still retains ~0.80 coverage.
- The advantage over a window **widens with context length** (0.873 → 0.880 as context grows from 16-32K to 64-128K).

### Accepted Length Results (τ)

**General-purpose benchmarks** (Table 6): DFly2 accepts more tokens than both baselines in all cells.

| Target | DSpark Avg. | DFly2 Avg. | Gain |
|--------|------------|------------|------|
| DS-V4.1-Flash | 3.81/3.51 | 4.12/3.88 | +8.1%/+10.5% |
| GLM-5.3-Flash | 3.68/3.35 | 3.96/3.69 | +7.6%/+10.1% |
| Hy4 flash | 3.81/3.73 | 3.96/3.95 | +3.9%/+5.9% |

**Long-context & agentic benchmarks** (Table 7): The margin widens substantially.

| Target | DSpark Avg. (Long/Agen.) | DFly2 Avg. (Long/Agen.) | Gain |
|--------|--------------------------|--------------------------|------|
| DS-V4.1-Flash | 3.23/3.35 | 3.74/4.06 | +15.8%/+21.2% |
| GLM-5.3-Flash | 3.05/3.10 | 3.85/4.03 | +26.2%/+30.0% |
| Hy4 flash | 3.20/3.16 | 3.63/4.11 | +13.4%/+30.1% |

### Speedup Results

- **Decoding speedup** (Tables 8-9): DFly2 achieves the highest average speedup on every target and family. Over the stronger baseline: +2-6% on general, +6-18% on long-context, +12-30% on agentic.
- **Critical failure modes of baselines**: On Hy4 flash, DFlash collapses at >32K contexts (τ falls to 1.08), and DFlash variants on DS-V4.1-Flash end agentic sets *slower* than no speculation due to prefill overhead.
- **High concurrency** (Figure 7): At matched per-user decode speed, DFly2 delivers +28% throughput on short text, +62% on CodeSpan 64K, +81% on SWE 64K vs. DSpark.

### Ablation Findings

- **Removing the target's top-k** (leaving only near window) is the largest loss, 2-6× more costly on long contexts than general.
- **Near window** alone adds ~3% on DS-V4.1-Flash, ~0% on others.
- **Pairing matters**: Adjacent layers 37-39 (which reuse layer 36's latents) cost 4.6% vs. layers 28/32/36 (each with own indexer).
- **Weight initialization**: Attention copy and FFN expert draw each contribute ~1-1.6% independently.
- **Intra-block correction** adds 2.8%; **last-layer hidden injection** adds 1.6%.

## Theoretical and Practical Implications

### Theoretical Implications

1. **Selection reuse is viable**: The paper provides quantitative evidence that a sparse target's attention selection, made one step early, covers ~90% of what subsequent tokens would select—validating that drafting can follow the target's own choices without additional scoring.

2. **Cost structure of drafters**: The analysis formalizes the three costs of a drafter's own cache (prefill, prefix caching, decode concurrency) and shows that sharing the target's KV eliminates all three by design.

3. **Length generalization**: Because the target's selection is a fixed-size top-k that can reach anywhere in the context, DFly2 inherits the target's length generalization—its accepted length stays within 4% of its general average on agentic workloads, while DSpark's falls 11-21%.

### Practical Implications

1. **Deployment simplification**: DFly2 needs no place on prefill instances, inherits every prefix-cache hit of the target, and costs no decode concurrency—making it substantially easier to deploy in disaggregated serving.

2. **Memory savings**: Removing the drafter's own cache increases max concurrency 1.73× on DS-V4.1-Flash at 32K tokens (vs. a full own cache).

3. **Universal design**: The same DFly2 design works across three targets with different sparse attention variants (shared latent cache, interleaved linear attention, two-stage index compression) with nothing to tune in what it reads.

## Conclusion

DFly2 demonstrates that a natively sparse target's own choices—its KV cache layout and its per-query attention selection—can serve as the complete context specification for a block-parallel drafter. The drafter keeps no cache of its own, runs no scoring pass, and reads a fixed number of positions at any prompt length. This yields consistently higher accepted lengths and end-to-end speedups across three architecturally different targets, with gains that *grow* with context length—precisely where speculative decoding is most needed. The work opens a design space (e.g., using YOCO-style shared caches to explore cross-layer unions, history rows, and larger per-row budgets) for further improving drafter context selection at minimal cost.

---

_Markdown view of https://picx.dev/p/XLjalH, served by PicX — AI-generated visual whiteboard summaries of research papers._
