Gemma 4 31B-it, W4A8, with a block-16 DFlash2 speculator (radiance)
Gemma 4 31B-it in one file for the radiance inference engine on AMD RDNA4 cards (Radeon AI PRO R9700, gfx1201), with a DFlash2 speculator that drafts 15 tokens a pass instead of 7: gemma-4-31B-it-speculator.dflash2-b16, RedHatAI's speculator fine-tuned from block 8 to block 16.
The trunk is the same as in gemma4-31b-w4a8-dflash2; only the speculator differs:
- the trunk's linears at int4 (round-to-nearest with a per-group scale search, from Google's bf16 checkpoint), q, k and v as one linear, read against int8 activations;
- the lm_head at int8;
- the DFlash2 speculator (five layers on a 2048-token window, a grouped dynamic convolution, a candidate selector; block 16) at block fp8, and its draft head at int8;
- the bf16 vision tower.
| file | size |
|---|---|
gemma4-31b-dense-w4a8-df2b16-qkv.rad |
23.2 GiB |
gemma4-31b-dense-bf16-w4a8-df2.recipe |
the recipe it was converted with |
For tool calls, use the GPTQ version: gemma4-31b-w4a8-gptq-dflash2-b16 is this file with its int4 trunk fitted by GPTQ, at the same size and speed. This file's rounded trunk can leave a streamed tool call stuck inside a string argument: BetterBench's order request stalled in 10 of 20 tries over it, and in none over the GPTQ trunk.
Needs
radiance with tree verification: each step grows the speculator's candidates into a 15-node tree, and the trunk verifies the whole tree at once. That is what makes block 16 pay, and it is not in a radiance release yet. It is in review on Perire/radiance:
- #26: tree verification.
- #27: block-16 trees, stacked on #26. Its branch is
pr/tree-b16, and it addsdeploy/compose/gemma4-31b-w4a8-df2b16-tp4.yamland-tp2.yaml.
Without tree verification (radiance main today), the file still runs, but as a 15-draft chain. That is faster than block 8 on code and math, and slower on prose and under load: use gemma4-31b-w4a8-dflash2 there.
Quick start
On four cards, with the file in /srv/models, build radiance from #27's branch and serve:
hf download Ashlyn4202025/gemma4-31b-w4a8-dflash2-b16 gemma4-31b-dense-w4a8-df2b16-qkv.rad --local-dir /srv/models
git clone -b pr/tree-b16 https://codeberg.org/Perire/radiance.git && cd radiance
docker buildx build --load --build-arg GPU_TARGETS=gfx1201 -t radiance:tree .
docker run -d --name radiance --network host \
--device /dev/kfd --device /dev/dri \
--group-add "$(getent group render | cut -d: -f3)" --group-add "$(getent group video | cut -d: -f3)" \
--security-opt seccomp=unconfined --ulimit memlock=-1 \
-v /srv/models:/models:ro radiance:tree \
--model /models/gemma4-31b-dense-w4a8-df2b16-qkv.rad --host :: --port 8000 \
--tp 4 --max-num-seqs 16 --max-model-len 65536 --kv-cache-dtype fp8 \
--num-speculative-tokens auto --max-num-batched-tokens 8192 \
--busy-prefill-chunk 512 --prefill-interleave 1
The server speaks the OpenAI API on port 8000. On two cards, the same command with --tp 2 works.
Everything below turns itself on for this file:
--num-speculative-tokens autoserves a 15-node tree a step.- From two users on, each tree keeps its first 7 nodes, and the speculator's pass runs over half its block. The trunk then verifies no more rows than block 8's tree did, and the speculator computes no more than it did either.
Speed
Radeon AI PRO R9700 cards (PCIe 4.0) with the quick start's flags, and BetterBench with thinking off and sampling at temperature 0.7 (code 30%, reasoning 20%, prose 15%, JSON 15%, file edits 10%, summaries 10%). The images are built from #26 and #27.
| four cards | single-stream decode, weighted | 1 / 2 / 4 / 8 / 16 users, aggregate tok/s |
|---|---|---|
| this file, block 16 | 436.0 tok/s | 368 / 554 / 730 / 914 / 1073 |
| block 8, verified as a 7-node tree (#26) | 366.6 | 336 / 548 / 725 / 910 / 1062 |
| block 8, verified as a chain (radiance main) | 344.5 | 311 / 510 / 676 / 821 / 987 |
| two cards | single-stream decode, weighted | 1 / 2 / 4 / 8 / 16 users, aggregate tok/s |
|---|---|---|
| this file, block 16 | 239.5 tok/s | 206 / 316 / 509 / 569 / 775 |
| block 8, verified as a 7-node tree (#26) | 193.0 | 174 / 307 / 500 / 551 / 755 |
Against the block-8 tree that is +19% single-stream on four cards and +24% on two. Under load (2 to 16 users) it is +0.5 to +1% on four cards and +2 to +3% on two.
Most of the gain is where the trunk agrees with long runs of drafts. For one user on four cards: JSON 787 against 577 tok/s, math 636 against 491, code 491 against 416, file edits 444 against 378. Prose (233 against 220) and reasoning (286 against 269) gain little.
How it was made
rad-convert google/gemma-4-31B-it --draft-model Ashlyn4202025/gemma-4-31B-it-speculator.dflash2-b16 \
--recipe gemma4-31b-dense-bf16-w4a8-df2.recipe \
--set quantization_config.quant_method=compressed-tensors -o gemma4-31b-dense-w4a8-df2b16-qkv.rad
The recipe is the block-8 file's, unchanged: the converter reads the block size from the speculator's config. No calibration data: the trunk's quantisation is round-to-nearest, with a scale search per 128-column group. The speculator's card says how it was trained.
Quality
The trunk is the same as the block-8 file's. Speculative decoding is exact: the trunk verifies every node, and the path it accepts is always the trunk's own tokens, its greedy choices or its own samples at temperature. So the speculator changes the speed, never what the model says.
Limits
- AMD RDNA4 only (radiance's kernels are built for gfx1201).
- Measured at
--tp 4and--tp 2, on R9700 cards. - The speculator was fine-tuned on replies with thinking off. With thinking on, its acceptance was not measured.
Credits
- Gemma 4 31B-it and its vision tower: Google.
- The DFlash2 speculator it was fine-tuned from: RedHatAI, trained with vLLM's speculators library. The DFlash2 architecture: z-lab. Block extension with a weighted tail: DBloom.
- radiance: StillDeadcode. Gemma 4 support in radiance: sfjes and keptn42.
License
Apache 2.0, the license of Gemma 4 and of RedHatAI's speculator.
Model tree for Ashlyn4202025/gemma4-31b-w4a8-dflash2-b16
Base model
google/gemma-4-31B