|
| 1 | +# DFlash baseline drafter for `google/gemma-4-26B-A4B-it` (Kakeya-aligned) |
| 2 | + |
| 3 | +Baseline **DFlash block-diffusion drafter** for the Gemma-4 26B-A4B verifier, |
| 4 | +for use in Kakeya inference speculative-decoding development and scenario |
| 5 | +testing. Loadable directly by the native engine: |
| 6 | + |
| 7 | +```python |
| 8 | +import torch |
| 9 | +from inference_engine.v04.dflash_drafter import DFlashDrafter |
| 10 | +drafter = DFlashDrafter.from_pretrained("models/dflash-kakeya-baseline", dtype=torch.bfloat16) |
| 11 | +``` |
| 12 | + |
| 13 | +## What this is |
| 14 | + |
| 15 | +- **Architecture**: the native `DFlashDrafter` (5-layer Qwen3 backbone + `fc` |
| 16 | + aux projection + `hidden_norm` + `norm`), faithful to vLLM PR #41703 |
| 17 | + `qwen3_dflash.py`. Shares the verifier's embeddings (`×sqrt(hidden)`) and |
| 18 | + lm_head (`final_logit_softcapping=30`). Aux layers `(2,7,12,18,23,28)`. |
| 19 | +- **Weights**: the upstream `z-lab/gemma-4-26B-A4B-it-DFlash` checkpoint, |
| 20 | + **alignment-trained** to the Kakeya engine's inference path (see below). |
| 21 | + 0.43 B params, bf16, `model.safetensors` (stored via Git LFS). |
| 22 | + |
| 23 | +## Why alignment |
| 24 | + |
| 25 | +The upstream DFlash forward is defined inside vLLM (custom KV-cache writes, |
| 26 | +fused kernels). The native engine reconstructs the math, but the exact |
| 27 | +aux-hidden-tap semantics live in vLLM internals. Rather than reverse-engineer |
| 28 | +them, we treat the gap as an `f_θ` alignment task (ADR 0008 §11, |
| 29 | +`docs/design/k3-f-theta-training-pipeline.md`): freeze the verifier, train the |
| 30 | +drafter so its drafts match the verifier's greedy tokens. |
| 31 | + |
| 32 | +## Provenance / reproduce |
| 33 | + |
| 34 | +- Base: `z-lab/gemma-4-26B-A4B-it-DFlash` |
| 35 | +- Verifier: `google/gemma-4-26B-A4B-it` |
| 36 | +- Trainer: `scripts/research/k3_dflash_alignment_train.py` |
| 37 | + ``` |
| 38 | + python scripts/research/k3_dflash_alignment_train.py \ |
| 39 | + --steps 6000 --lr 5e-5 --block-size 16 --n-prompts 64 --gen-len 192 \ |
| 40 | + --train-scope full --save dflash_aligned_corpus.pt |
| 41 | + ``` |
| 42 | + (64 diverse prompts, 58 usable; `train_match=0.71`) |
| 43 | + |
| 44 | +## Acceptance (vs the real Gemma-4 verifier, block 16) |
| 45 | + |
| 46 | +| eval | acceptance_rate | acceptance_length | |
| 47 | +|---|---|---| |
| 48 | +| held-out (8 disjoint prompts) | 0.107 | 2.45 | |
| 49 | +| in-domain (small set) | 0.561 | 8.62 | |
| 50 | +| reference (HumanEval, vLLM) | 0.447 | 7.70 | |
| 51 | + |
| 52 | +The in-domain run reaching ≥ the reference proves the integration is correct; |
| 53 | +the held-out number is limited by the small (64-prompt) alignment corpus and |
| 54 | +climbs with more data (10→64 prompts: 1.94→2.45 length). This is a |
| 55 | +**baseline** — scaling the alignment corpus is expected to close the held-out |
| 56 | +gap toward 7.70. |
| 57 | + |
| 58 | +## Status |
| 59 | + |
| 60 | +Research baseline (not GA). Lossless vs greedy AR is preserved by the |
| 61 | +spec-decode accept loop regardless of draft quality; this drafter only affects |
| 62 | +*speedup*, not correctness. |
0 commit comments