gemma-4-12B-it-DFlux
gemma-4-12B-it-DFlux is a DFlux speculative draft model for google/gemma-4-12B-it, trained with LEGOSpec (LEGOSpec: A Composable and Efficient Framework for Speculative Draft Design and Training).
DFlux is a balanced general-purpose speculative draft architecture that combines:
- SWA–GQA Hybrid Backbone with Block-Local Convolution: 5 Sliding-Window Attention layers followed by 1 dense GQA full-attention layer, each equipped with a block-local grouped convolution to preserve within-block dependencies across both short and long contexts while bounding historical KV cache growth.
- Residual Corrector (R-Corrector): Computes parallel predecessor–successor residual corrections over the top-16 candidates while retaining full-vocabulary base logits, preserving the exact target distribution under rejection sampling.
- Hierarchical Supervision: Jointly trains the backbone with forward KL for candidate coverage and the final output with D-PAL loss to directly optimize block-level acceptance length.
Training Data & Setup
- Dataset (1.4M samples total):
- 900K samples from Open-PerfectBlend
- 300K samples from Nemotron-Post-Training-Dataset-v2
- 200K samples from WildChat
- Supervision: Prompts are retained and responses are regenerated by
google/gemma-4-12B-itatT = 1. - Optimization: Trained on 16 NVIDIA H800 GPUs with global batch size 128, Adam (
lr = 6e-4) and Muon (lr = 0.01), max length 4096.
Evaluation Results
Mean Acceptance Length (τ) at T = 1
Evaluated with block size 8, maximum generation length 1,024 tokens, and rejection sampling, averaged over 5 random seeds. Long-context benchmarks (LongBench-v2 MD-QA, L-ICL, SD-QA, and SWE-bench) use 32K–64K-token inputs.
| Method | Alpaca | MT-Bench | GSM8K | MATH-500 | MBPP | LCB | MD-QA | L-ICL | SD-QA | SWE |
|---|---|---|---|---|---|---|---|---|---|---|
| DFlash | 3.36 | 3.69 | 5.94 | 5.54 | 4.80 | 4.14 | 2.72 | 2.78 | 2.65 | 3.39 |
| DFlash2 | 3.72 | 4.05 | 6.33 | 6.01 | 5.28 | 4.65 | 2.60 | 2.81 | 2.58 | 3.44 |
| DSpark | 3.60 | 3.97 | 6.21 | 5.92 | 5.19 | 4.50 | 3.00 | 3.05 | 3.01 | 4.00 |
| DFlux (Ours) | 4.12 | 4.43 | 6.65 | 6.42 | 5.77 | 5.14 | 4.02 | 4.09 | 3.85 | 4.52 |
High-Concurrency Throughput with SGLang (T = 0)
Throughput reported as TPS / Speedup over AR across batch sizes 1, 8, 32, and 64, along with mean acceptance length (Avg. τ).
| Task | Method | BS = 1 | BS = 8 | BS = 32 | BS = 64 | Avg. τ |
|---|---|---|---|---|---|---|
| Alpaca | AR | 47 / 1.00× | 381 / 1.00× | 1480 / 1.00× | 3168 / 1.00× | — |
| DFlash2 | 109 / 2.32× | 943 / 2.48× | 3195 / 2.16× | 4122 / 1.30× | 3.02 | |
| DSpark | 123 / 2.61× | 1011 / 2.65× | 3408 / 2.30× | 4393 / 1.39× | 3.41 | |
| DFlux (Ours) | 137 / 2.91× | 1151 / 3.02× | 3833 / 2.59× | 4963 / 1.57× | 3.61 | |
| GSM8K | AR | 47 / 1.00× | 382 / 1.00× | 1492 / 1.00× | 3253 / 1.00× | — |
| DFlash2 | 212 / 4.50× | 1838 / 4.81× | 6394 / 4.29× | 8399 / 2.58× | 5.72 | |
| DSpark | 236 / 5.02× | 1950 / 5.10× | 6741 / 4.52× | 8856 / 2.72× | 6.29 | |
| DFlux (Ours) | 256 / 5.42× | 2149 / 5.62× | 7362 / 4.93× | 9719 / 2.99× | 6.56 | |
| MBPP | AR | 47 / 1.00× | 378 / 1.00× | 1465 / 1.00× | 3114 / 1.00× | — |
| DFlash2 | 160 / 3.43× | 1379 / 3.65× | 4614 / 3.15× | 5876 / 1.89× | 4.51 | |
| DSpark | 190 / 4.06× | 1555 / 4.12× | 5159 / 3.52× | 6561 / 2.11× | 5.25 | |
| DFlux (Ours) | 207 / 4.44× | 1739 / 4.60× | 5689 / 3.88× | 7288 / 2.34× | 5.55 |
Usage
This checkpoint is a speculative draft model and requires its matching target model (google/gemma-4-12B-it) for shared embeddings, output head, and verification.
Install LEGOSpec and load the draft checkpoint:
import torch
from legospec import LegoSpecConfig, LegoSpecModel
checkpoint = "SJTU-DAI-Sys/gemma-4-12B-it-DFlux"
config = LegoSpecConfig.from_pretrained(checkpoint)
draft = LegoSpecModel.from_pretrained(
checkpoint, config=config, dtype=torch.bfloat16
).cuda().eval()
See the LEGOSpec repository for SGLang serving and evaluation scripts.
Citation
@article{wang2026legospec,
title={LEGOSpec: A Composable and Efficient Framework for Speculative Draft Design and Training},
author={Wang, Hanzhen and Xu, Jiaming and Dai, Guohao},
journal={arXiv preprint arXiv:2611.33004},
year={2026}
}