Views
No views yet
google/gemma-4-12B-it, built specifically to be a
DSpark speculative-decoding target
(draft head: deepseek-ai/dspark_gemma4_12b_block7).google/gemma-4-12B-it-qat-w4a16-ct —
drifts far enough that draft acceptance collapses and speculation makes the model slower:| target (same W4A16 format) | DSpark per-token accept | outcome |
|---|---|---|
| QAT w4a16-ct (retrained) | 2.1% | slower than no speculation |
| this model (post-training GPTQ) | 35.6% | 1.73× speedup |
| fp8 (post-training, reference) | 34.4% | 1.9× over its own native |
| bf16 (reference) | 39.5% | 2.7× (eager) |
| config | tok/s | vs native int4 |
|---|---|---|
| this model + DSpark k=7 + CUDA graphs + FlashInfer autotune | 198.2 (peaks 239) | 1.73× |
| this model + DSpark k=7 + CUDA graphs | 193.8 | 1.69× |
| this model + DSpark k=14 (2 draft blocks) | 178.6 | don't — accept dies at block boundary |
| this model, native (no speculation), CUDA graphs | 114.7 | 1.0× |
| fp8 (online) + DSpark k=7 (13 GB weights) | 165 | — |
| bf16 + DSpark k=7 (eager; graphs OOM on 32 GB) | 144 | — |
| official QAT w4a16-ct, native | 118 | speculation hurts this one |
| llama.cpp Q4_0 GGUF, native (reference) | 156 | its DSpark port is slower than native |
1from vllm import LLM, SamplingParams
2from transformers import AutoTokenizer
3
4MODEL = "Danny-Dasilva/gemma-4-12B-it-W4A16-GPTQ-g32-DSpark"
5DRAFT = "deepseek-ai/dspark_gemma4_12b_block7"
6
7llm = LLM(
8 model=MODEL,
9 max_model_len=8192,
10 attention_backend="FLASHINFER", # gemma-4 full-attn layers have head_dim 512
11 enable_flashinfer_autotune=True, # +2% in our runs
12 speculative_config={
13 "method": "dspark",
14 "model": DRAFT,
15 "num_speculative_tokens": 7, # = draft block size; k<7 or k=14 are both slower
16 "attention_backend": "TRITON_ATTN",
17 },
18)
19
20tok = AutoTokenizer.from_pretrained(MODEL)
21prompt = tok.apply_chat_template(
22 [{"role": "user", "content": "Explain transformers step by step."}],
23 add_generation_prompt=True, tokenize=False,
24)
25print(llm.generate([prompt], SamplingParams(temperature=0.0, max_tokens=256))[0].outputs[0].text)<|turn>-style tokens and
add_bos_token=False; raw prompts produce garbage on any backend.num_speculative_tokens must be ≤ 7 or a multiple of 7 (draft block size). 7 is optimal.kv_cache_dtype="fp8" measured slower (−3%) at short context on this card.HuggingFaceH4/ultrachat_200k (train_sft), chat template applied,
max_seq_length 2048pack-quantized format —
mirrors the official QAT checkpoint's config so every vLLM kernel path is identicalsequential_targets=["Gemma4UnifiedTextDecoderLayer"]; lm_head and vision/audio embedder
projections kept in bf16 (same 17-entry ignore list as the official QAT release, spelled so both
HF and vLLM module names match)processor_config.json included (vLLM's multimodal processor init requires it)google/gemma-4-12B-it @ 5926caa4 (bf16, untouched — no finetuning)