DFlash: The Repo That Lets an LLM Draft Its Next 16 Tokens in Parallel

By borrowing hidden-state signals from the target model, DFlash turns speculative decoding into a block-level system that is faster, lighter, and stranger than the usual one-token-at-a-time loop.

10 min read • View on GitHub • More from z-lab

A large target engine feeds a thin stream of hidden states into a smaller sidecar drafting machine, which emits a block of sixteen token tiles in one burst before a verification gate checks them. The scene explains how DFlash borrows internal signals from the target model to draft multiple future tokens in parallel.
DFlash does not replace the target model. It borrows clues from it, drafts a block, then lets the target verify the result.
Key Takeaways

Autoregressive decoding has a brutal habit: every token waits on the last one. DFlash attacks that wait time by treating the target model’s internal state as draft fuel, then asking a smaller block diffusion model to propose several future tokens at once. The target still has the final say, but the draft stage stops behaving like a serial chain.

That is why DFlash is more interesting than a generic speedup repo. It is not just a faster drafter. It is a different way to think about speculation, where the target model helps predict its own next move.

Why DFlash Feels Like a Shortcut Through Decoding

The bottleneck in large language model inference is not always raw math. It is the fact that generation is sequential, so latency compounds one token at a time. DFlash keeps the target model in the loop, but moves the drafting work into a parallel block system that can ask for more than one token per step.

DFlash uses a lightweight block diffusion model to draft an entire block of tokens in a single parallel forward pass, achieving up to 6× lossless acceleration on Qwen3-8B, nearly 2.5× faster than EAGLE-3.

Jian Chen, Yesheng Liang, Zhijian Liu, Authors · DFlash: Block Diffusion for Flash Speculative Decoding - Z Lab

The Trick: Hidden States Become Draft Fuel

DFlash starts with a normal target-model prefill. Then it extracts hidden states from selected layers and converts them into a context feature. That feature is fed into the draft path, where noise embeddings and diffusion-style refinement help assemble a token block in parallel.

The key move is feature transfer. DFlash drafts from the target model’s internal state, not from scratch.

The point of that relay is simple. The draft model is no longer guessing from a blank slate. It is conditioned on internal signals that already encode where the target model is headed, which makes block drafting much more practical than a tiny autoregressive drafter trying to infer everything on its own.

Instead of asking a tiny diffusion model to reason from scratch, DFlash conditions the draft model on context features extracted from the target model, fusing the target’s deep reasoning with the drafter’s parallel speed.

Jian Chen, Yesheng Liang, Zhijian Liu, Authors · DFlash: Block Diffusion for Flash Speculative Decoding - Z Lab
A close-up of sixteen token tiles being assembled from noisy fragments into a single aligned row, with a narrow ribbon of context feature guiding the process and a rejected pile falling away below. The image explains how block diffusion refines a whole draft at once and why acceptance matters.
The draft is not a chain of guesses. It is a block that gets refined, then either accepted or rejected by the target model.

What Block Diffusion Changes Compared With Autoregressive Drafting

DimensionConventional autoregressive draftingDFlash block diffusion
Draft unitOne token at a timeA block of tokens at once
Draft sourceSmall AR model or shallow headsTarget hidden states plus diffusion-style refinement
ParallelismLimited by sequence orderHigh during block assembly
Quality tradeoffCheap draft, weaker signalMore expressive draft with verification
Practical focusSimple to reason aboutThroughput without giving up lossless verification

This is the real break in shape. Most speculative methods still pay sequential cost in the draft stage. DFlash moves that cost into a parallel block, which makes a larger draft window believable without forcing the system to become a giant standalone model.

Why Acceptance Length Is the Metric That Matters

A fast draft is only useful if the target model keeps it. That is why acceptance length matters more than raw draft output. If the verifier accepts more of the proposed block, throughput rises. If it rejects the block, the work was mostly wasted.

DFlash’s benchmarking logic is built around that reality. The question is not just how many tokens it can propose. The question is how many tokens survive verification, because that is what turns a clever draft into a real serving win.

Apple Silicon Is Not an Afterthought

The repo is not only tuned for GPU server stacks. `model_mlx.py` shows a separate path for Apple Silicon, with `DFlashAttention`, `RotatingKVCache`, and `mx.fast.scaled_dot_product_attention` all pointing to a project that cares about unified memory limits and local workflows. That matters because it broadens DFlash from a datacenter idea into a developer tool.

# Core pattern from the repository
hidden_states = target_model(**inputs, output_hidden_states=True).hidden_states
context_feature = extract_context_feature(
    hidden_states,
    build_target_layer_ids(num_target_layers)
)
draft_tokens = dflash_generate(
    context_feature=context_feature,
    noise_embedding=noise_embedding,
    block_size=16,
)
accepted = target_model.verify(draft_tokens)

The Repo Is Built Like an Inference Product, Not a Lab Demo

The code layout is lean and practical. `model.py` handles the PyTorch path, `model_mlx.py` covers Apple Silicon, and `benchmark.py` exists to compare backends rather than just print a happy-path demo. The optional dependencies in `pyproject.toml` also make the package feel designed for integration, not isolation.

That is a meaningful signal. A lot of research repos stop at a paper-shaped prototype. DFlash ships as an inference system with backend support, benchmarking, and model releases that are meant to be consumed.

How DFlash Stacks Up Against EAGLE-3 and Diffusion Alternatives

MethodDraft styleStrengthMain limitation
Conventional autoregressive speculationSequential token draftingSimple implementationDraft stage still pays serial cost
EAGLE-3Autoregressive draft modelStrong speculative baselineStill chained token by token
Diffusion speculative methodsBlock-oriented draftingConceptually aligned with parallel generationOften expensive to serve
DFlashHidden-state-conditioned block diffusionParallel block drafting with lightweight reuse of target featuresAcceptance still depends on the verifier

EAGLE-3 is the obvious foil because it shares the speculative decoding goal, but it still drafts autoregressively. Diffusion-based methods prove the broader idea works, yet they often carry a heavier serving cost. DFlash’s bet is narrower and more practical: keep the draft light, keep the verifier authoritative, and move the expensive guessing work into a block.

This reframes the role of diffusion LLMs entirely. Instead of training massive dLLMs to match autoregressive quality, we can train lightweight diffusion adapters optimized for fast, accurate block prediction, with speculative verification guaranteeing output quality.

Jian Chen, Yesheng Liang, Zhijian Liu, Authors · DFlash: Block Diffusion for Flash Speculative Decoding - Z Lab

Sources and Further Reading