Qwen4-35B-A3B-DFly2

The first public zero-KV, QSA-index-sharing DFly2 (Tencent/AngelSpec) drafter — and first GGUF v3 drafter — for Qwen/Qwen4-35B-A3B (qwen4_moe, 40 layers, 256 routed experts, top-8 active).

Qwen4-35B-A3B-DFly2 is a lightweight 4-layer block-parallel speculative draft model (~318.9M parameters; 637.7 MB in BF16 safetensors, 339.1 MB in reference Q8_0 GGUF) that drafts γ = 5 candidate tokens per verification step (block_size = 6, up to τ = 6.0 tokens committed per target forward pass) with 0 bytes of draft KV cache and flat O(Top-2048) context reads at arbitrary sequence lengths via direct QSA post-RoPE KV & SelectMark index sharing.

The primary public contract is engine-agnostic: model.safetensors (BF16) + AngelSpec-aligned config.json + standalone reference_model.py + deterministic golden_parity.json (qwen4.dfly2.golden/1), accompanied by reference GGUF v3 exports (Q8_0 and BF16, general.architecture = "dfly2").

All speculative outputs are mathematically lossless with respect to Qwen/Qwen4-35B-A3B: exact bit-identical tokens at T = 0.0 (greedy) and exact target distribution via rejection sampling (min(1, p/q) + residual correction) at T > 0.


Key Highlights

  • Zero Draft KV Cache (0 B) vs. Draft-KV Drafters: Each of the 4 draft layers pairs 1-to-1 with Qwen/Qwen4-35B-A3B's sparse QSA full-attention layers [15, 23, 31, 39] and reads the target's committed post-RoPE (K, V) cache directly. Unlike RadixArk/Qwen4-35B-A3B-Dflash2 (an SGLang-only DFlash2 drafter with a 5,120 B/tok draft KV cache and a 2K sliding window), DFly2 adds 0 bytes of draft KV cache and attends across the full context without a 2K window cutoff.
  • Flat O(Top-2048) Long-Context Scaling: Shares Qwen4's QSA SelectMark sparse block indices (target_index_layer = [15, 23, 31, 39], target_index_topk = 2048), keeping draft attention bandwidth constant from 4K through 256K+ context.
  • Single-Pass Parallel Backbone + Top-128 Corrected LM Head: Runs all block_size = 6 slots (1 anchor + 5 mask tokens) in one parallel 4-layer pass, executes the full 248,320-row lm_head once per block to shortlist Top-128 candidates per slot, then applies sequential HiddenStatesCorrection + block-gated AttentiveCorrection (DFly2 Eq. 11) scoring only those 128 vocabulary rows.
  • Zero Duplicated Vocabulary Weights: Reuses Qwen/Qwen4-35B-A3B's frozen embed_tokens and lm_head directly (has_own_embed_tokens = false, has_own_lm_head = false).
  • Complete Reference Contract + Reference GGUF v3 Exports: Ships model.safetensors (BF16), AngelSpec-aligned config.json, standalone PyTorch reference_model.py, deterministic golden_parity.json (qwen4.dfly2.golden/1) verification vectors, and reference Q8_0 / BF16 GGUF v3 exports (general.architecture = "dfly2").

Public Runtime Status

Runtime / Engine Status Notes
reference_model.py (PyTorch + model.safetensors) Runs standalone today Full single-block drafting (block_size = 6, γ = 5, Top-128 correction) and lossless verification against Qwen/Qwen4-35B-A3B
llama.cpp (#33656, --spec-type draft-dfly2) Hy4-flash MLA only --spec-type draft-dfly2 currently targets Hy4-flash MLA; a qwen4_moe QSA-index-sharing DFly2 loader is not yet merged upstream
ROCmFPX, vLLM, SGLang, ExLlamaV3 Not yet merged No public qwen4_moe DFly2 loader merged yet; see the Engine Integration Contract below

Architecture Specification

Parameter Value Notes
Architecture (general.architecture) dfly2 AngelSpec DFly2-KV block-parallel drafter
Target model (base_model) Qwen/Qwen4-35B-A3B qwen4_moe (40 layers, 256 routed experts, top-8 active, QSA + MoE + PLE)
Draft layers (num_hidden_layers) 4 Dense SwiGLU decoder blocks
Paired target KV & index layers (target_kv_layers / target_index_layer) [15, 23, 31, 39] 1-to-1 with Qwen4 sparse QSA full-attention layers (target_index_topk = 2048)
Hidden size (hidden_size) 2048 Matches Qwen4 residual stream
FFN intermediate size (intermediate_size) 6144 Dense SwiGLU (gate_proj, up_proj, down_proj)
Attention geometry 16 Q heads / 2 KV heads, head_dim = 256 Per-head output-gated GQA matching Qwen4 attn_q
Rotary embeddings Partial NeoX split-half, rotary_dim = 64 Pass-through on [64..256), rope_theta = 10,000,000
Normalization Standard RMSNorm (rms_norm_eps = 1e-6) Unit-centered weights (w * rsqrt(mean(x^2) + eps))
Block geometry block_size = 6 (1 anchor + γ = 5 drafts) Max τ = 6.0 tokens committed per verify step
Slot-0 conditioning MTPFusion (mtp_fusion = true) Fuses E(x_a) + target pre-lm_head collapsed/normed hidden h_{a-1} via gated projection
Post-backbone refinement HiddenStatesCorrection (hc_ff = 2048) + block-gated AttentiveCorrection hidden_correction_topk = 128, max_slots = 16
Vocabulary sharing Shared embed_tokens & lm_head (V = 248,320) mask_token_id = 248077 (learned mask_embedding vector)
Parameter count 318,866,448 (65 tensors) ~318.9M parameters
Footprint (BF16 safetensors / Q8_0 GGUF) 637.7 MB / 339.1 MB Reference GGUF exports store 1D norms/gates/biases in F32
Draft KV cache overhead 0 bytes Direct post-RoPE KV + QSA SelectMark Top-2048 index sharing

Artifact Inventory

File Format / Purpose Size SHA-256
model.safetensors Primary — Canonical BF16 PyTorch / AngelSpec weights 637.7 MB 63b5813d585f1d174b21040bc590798c34ad42959c35a39719cdea3b4f42d8a1
config.json Primary — AngelSpec-aligned DFly2 architecture & serving configuration 1.1 KB 3060ec0591ee0674b07f3f68ebb1709c8338f0ddb3f0266248e985a1e321cb97
reference_model.py Primary — Standalone PyTorch reference implementation (Qwen4DFly2DraftModel) 46.4 KB 5986a291e5bf088743e2836da82253a1620b7beb037e80b1c6237e90c4f88a9b
golden_parity.json Primary — Deterministic forward-pass parity vectors (qwen4.dfly2.golden/1) 6.7 MB 9bb6af06bb580f711009943aa9c09c23ee6742f1cce50004bf0bc4e264b99453
Qwen4-35B-A3B-DFly2-Q8_0.gguf Reference GGUF v3 export (general.architecture = "dfly2", Q8_0 2D / F32 1D) 339.1 MB bb1cdd7c79746f9068e3e2d09b69a276a60cfbb33bdfff5dbbd04089cfad64ed
Qwen4-35B-A3B-DFly2-BF16.gguf Reference GGUF v3 export (general.architecture = "dfly2", BF16 2D / F32 1D) 637.9 MB dd3bdf170a4bec2fb773a661f48f7a67ec33e624787840ca333e92617435f89a
eval_report.json Full machine-readable speculative acceptance & parity benchmark report 4.3 KB 9bc915b83a44ac369703e10de8e9e0e5f259e57c969e15276c8bfcfc82c12051

Evaluation Results

End-to-end speculative decoding benchmark (block_size = 6, γ = 5, hidden_correction_topk = 128, max τ = 6.0 tokens/step) verified directly against the frozen Qwen/Qwen4-35B-A3B-FP8 target:

  • Greedy lossless parity (T = 0.0): 100.0% lossless greedy verification (exact token-level verification against live target logits on gfx1151)
  • Per-slot acceptance (T = 0.0): s1: 79.4%, s2: 71.7%, s3: 67.3%, s4: 61.1%, s5: 57.4%
  • Per-slot acceptance (T = 1.0): mean draft accept rate 12.4% across k=5 (math_think: 32.8% at k=5 / 44.1% at k=3 / 78.3% at k=1)
Domain / Split T = 0.0 Mean τ (tok/step) T = 0.0 Accepted Drafts (α / 5) T = 1.0 Mean τ (tok/step) T = 1.0 Accepted Drafts (α / 5) Top-128 Recall
Coding & Diffs (think + no-think) 1.79 0.79 1.41 0.41 98.4%
Tool Calling & Raw JSON 2.00 1.00 1.74 0.74 98.4%
Math & Reasoning (think) 1.98 0.98 2.63 1.63 98.4%
General Chat (no-think) 1.43 0.43 1.30 0.30 98.4%
Long-Context (4K–16K) 1.67 0.67 1.84 0.84 98.4%
Overall Mean 1.82 0.82 1.62 0.62 92.9%

Notes: Honest v1 Colab Pilot Scope (~9.0M off-policy tokens): This checkpoint was trained on a single Colab A100 40 GB for 550 steps (9.01M tokens) using online KL distillation over public SFT data (no large-scale on-policy rollouts). End-to-end live acceptance above is measured on AMD Strix Halo (gfx1151) against Qwen4-35B-A3B-Q4_K_M (k=5, true τ = 1 + accepted / draft_steps). It speeds up greedy decoding over AR (58.09 vs 53.34 tok/s, 1.09×; math_think: 70.91 tok/s, T=1.0 τ = 2.64), while trailing Qwen4-35B-A3B's native built-in MTP head (73.60 tok/s T=0.0, 65.77 tok/s T=1.0) on general prompts as expected at 9M off-policy tokens. Crucially, hardware profiling confirms very low Strix Halo round latency (27.8 ms/round at k=1, 35.4 ms/round at k=3, 43.9 ms/round at k=5 vs 18.8 ms AR; ~5.0 ms fixed propose overhead), meaning a full on-policy H100/H200 run targeting τ > 2.6 at k=3 or τ > 3.2 at k=5 has clear headroom to surpass built-in MTP with 0 B draft KV cache. Per-slot slot_accept_t0 above reports teacher-forced L=4096 step-550 slot accuracies; live T=0.0 τ reflects adaptive drafting steps.


Training Summary

Setting Value
Release date 2026-12-04
Online teacher Qwen/Qwen4-35B-A3B-FP8 (frozen, post-RoPE QSA KV taps on layers [15, 23, 31, 39] + final pre-lm_head normed hidden)
Total tokens trained 9.0M
Optimizer steps 550
Sequence packing length 2,048 / 4,096 (sparse QSA)
On-policy rollout mix 0% (online KL over public multi-domain SFT) (multi-domain public SFT traces distilled online against live frozen Qwen/Qwen4-35B-A3B-FP8 teacher logits across SWE/code, reasoning, tool-use, math, chat, and long-context)
Optimizer & schedule Hybrid Muon (2D matrices, Newton-Schulz-5, RMS-matched scaling) + AdamW (1D norms/gates/biases), FP32 master weights + BF16 autocast, WSD cosine cooldown
Objective Acceptance-aligned chunked distillation: 0.85 × Top-64 Forward KL + 0.15 × Teacher-Argmax CE + 0.25 × Aux Uncorrected Backbone KL with D-PACE dynamic slot weighting (α = 0.5, γ = 5.0) and exact hidden_correction_topk = 128 training
Final metrics loss = 1.954, kl = 1.200, ce = 1.360
Training hardware & wall time 1× NVIDIA A100-SXM4-40GB (Google Colab, streaming INT4 MoE teacher + CPU-pinned FP8 PLE) (~4.8 hours (550 steps, 9.01M tokens))
Checkpoint scope v1 Colab Pilot / Reference Checkpoint (~9.0M tokens): Released with full open weights, GGUF v3 exports, and golden parity vectors to unblock engine integration and serve as a clean baseline for larger on-policy H100/H200 training runs.

Engine Integration Contract

Any inference runtime implementing Qwen4-MoE DFly2 speculative decoding needs exactly 4 target-model taps from Qwen/Qwen4-35B-A3B (256 routed experts, top-8 active):

  1. Paired QSA Post-RoPE K/V + SelectMark Sparse Indices: Expose committed post-RoPE (K, V) tensors ([H_kv = 2, D = 256] per token) and SelectMark Top-2048 sparse block indices from Qwen4's 4 QSA full-attention layers target_kv_layers = target_index_layer = [15, 23, 31, 39] (target_index_topk = 2048). Draft layers 0..3 pair 1-to-1 with target layers [15, 23, 31, 39] with 0 bytes of draft KV cache; AttentiveCorrection reuses layer 3's (target_layer = 39) KV & index view.
  2. Pre-lm_head Collapsed/Normed Hidden State (h_{a-1}): Expose the target's exact pre-lm_head collapsed/normed hidden vector h_{a-1} ([2048]) for the last committed anchor token x_a, fed into slot-0 MTPFusion alongside E(x_a).
  3. Shared Frozen embed_tokens and lm_head: Reuse the target model's frozen embed_tokens ([248320, 2048]) and lm_head ([248320, 2048]) directly (has_own_embed_tokens = false, has_own_lm_head = false). Mask slots 1..5 (mask_token_id = 248077) are seeded from the drafter's learned mask_embedding ([2048]).
  4. Parallel Top-128 Shortlisting + Sequential Correction + Golden Parity Verification:
    • Run all block_size = 6 slots through the 4-layer backbone in one parallel pass.
    • Run the full lm_head once across the γ = 5 draft slots (slots 1..5) to shortlist Top-128 candidate token IDs per slot (hidden_correction_topk = 128).
    • Run sequential HiddenStatesCorrection + block-gated AttentiveCorrection across slots 1..5, scoring only the 128 shortlisted lm_head rows per slot.
    • Verify stage-by-stage numerical equivalence (mtp_fusion, per-layer backbone outputs, norm, hidden_correction, and attentive_correction) against golden_parity.json (schema = "qwen4.dfly2.golden/1").

Usage

1. Standalone PyTorch / AngelSpec Reference Inference

Download the primary contract files (model.safetensors, config.json, reference_model.py, golden_parity.json):

hf download dymoo/Qwen4-35B-A3B-DFly2 \
  config.json model.safetensors reference_model.py golden_parity.json \
  --local-dir ./qwen4-dfly2

Run a single block_size = 6 (γ = 5) speculative draft step using the target model's shared embed_tokens, lm_head, tapped post-RoPE QSA (K, V) caches from layers [15, 23, 31, 39], and final pre-lm_head collapsed/normed hidden state h_{a-1}:

import json
from pathlib import Path
import torch
from safetensors.torch import load_file

from reference_model import Qwen4DFly2Config, Qwen4DFly2DraftModel

ckpt_dir = Path("./qwen4-dfly2")
cfg = Qwen4DFly2Config.from_dict(json.loads((ckpt_dir / "config.json").read_text()))
drafter = Qwen4DFly2DraftModel(cfg).to(device="cuda", dtype=torch.bfloat16).eval()
drafter.load_state_dict(load_file(str(ckpt_dir / "model.safetensors")), strict=True)

# Provided by the frozen Qwen/Qwen4-35B-A3B target during decode:
# - anchor_token_id:    [B] int64 (last committed token x_a at position anchor_pos)
# - prev_hidden_normed: [B, 2048] bf16 (target pre-lm_head collapsed/normed hidden h_{a-1})
# - target_kvs:         list of 4 (K, V) tuples from Qwen4 QSA layers [15, 23, 31, 39],
#                       each post-RoPE [B, 2, ctx_len, 256] (or Top-2048 SelectMark gathered)
# - embed_tokens:       target model's nn.Embedding (248320 x 2048)
# - lm_head_weight:     target model's lm_head.weight (248320 x 2048)
draft_ids, draft_logits = drafter.draft_one_block(
    anchor_token_id=anchor_token_id,
    prev_hidden_normed=prev_hidden_normed,
    target_kvs=target_kvs,
    anchor_pos=anchor_pos,
    embed_tokens=embed_tokens,
    lm_head_weight=lm_head_weight,
    temperature=0.0,  # 0.0 for greedy lossless, >0.0 for exact rejection sampling
)
# draft_ids: [B, 5] candidate tokens for positions [anchor_pos + 1 .. anchor_pos + 5]

2. Reference GGUF v3 Exports & Golden Parity Verification

Download the reference GGUF v3 export (general.architecture = "dfly2") and verify its SHA-256 digest:

hf download dymoo/Qwen4-35B-A3B-DFly2 \
  Qwen4-35B-A3B-DFly2-Q8_0.gguf golden_parity.json \
  --local-dir ./qwen4-dfly2

sha256sum ./qwen4-dfly2/Qwen4-35B-A3B-DFly2-Q8_0.gguf
# Expected: bb1cdd7c79746f9068e3e2d09b69a276a60cfbb33bdfff5dbbd04089cfad64ed

golden_parity.json (schema = "qwen4.dfly2.golden/1") contains deterministic synthetic inputs and FP32 reference activations for every stage (mtp_fusion, per-layer backbone outputs, norm, hidden_correction, and attentive_correction) so any runtime (llama.cpp, vLLM, SGLang, ROCmFPX, ExLlamaV3, or custom CUDA/HIP/Rust backends) can verify bit-level numerical equivalence against both model.safetensors and the reference GGUF v3 exports.


Acknowledgements & License

Downloads last month
42
Safetensors
Model size
0.3B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for dymoo/Qwen4-35B-A3B-DFly2

Quantized
(514)
this model

Collection including dymoo/Qwen4-35B-A3B-DFly2