Archived
gemma4: a GPTQ calibration tap and recipe for the 31B's w4a8 container, whose tool calls then close their strings
Rounded to nearest, the 31B's w4a8 trunk leaves streamed tool calls inside their string arguments: after `sku:<|"|>MS-110` it prefers `**,` (58%) to the string's close (41%; bf16 ~1.0), and BetterBench's order request stalled in 10 of 20 tries. This adds what it takes to make the same container (same grid, kernels and size) with the trunk's int4 codes chosen by GPTQ against the bf16 model's own activations. - arch/gemma4: with RADIANCE_CALIB_DIR set, the plugin serving the 31B's bf16 checkpoint sums the Gram of every dense linear's bf16 input over the corpus a server is fed (gram_accum into a PERSIST [K, K] f32 buffer a tap) and writes the files at RADIANCE_CALIB_TOKENS, as arch/gemma3's tap does: q|k|v's and gate|up's input whole from rank 0, o_proj's and down's this rank's columns as `<stem>.part`, which libquant places on the diagonal. The files carry the names the w4a8 container gives the weights (gemma4_bf16's attn_qkv, attn_o, ffn_gate_up, ffn_down), so a GPTQ recipe converting that container reads them with calib=DIR. RADIANCE_G4_CALIB_LAYERS=lo:hi records a slice of layers (the 31B's taps are ~364 MiB a layer a rank at --tp 4, and 60 layers of them do not fit beside the bf16 weights). Under the tap a step runs whole and on one lane; without RADIANCE_CALIB_DIR nothing changes. - data/recipes/gemma4-31b-dense-bf16-w4a8g-df2.recipe: the -df2 recipe with `gptq codes=i4 group=128 scale=f16 rule=search calib=$CALIB` on the trunk's four linears. - docs/GEMMA4-31B-GPTQ.md: the route, the corpus, how to run it, and the measurements. Measured (1.11.0, the same tap and recipe): by GPTQ the close is 99.8% and no try stalls; KL against bf16 on the model's own turns falls from 0.341 to 0.251 (the w8a8 container 0.226), at the same speed. The convert takes 75 minutes with OpenBLAS in the image (#220; an estimated days without). A container made this way is on Hugging Face as Ashlyn4202025/gemma4-31b-w4a8-gptq-dflash2, and with the block-16 drafter as Ashlyn4202025/gemma4-31b-w4a8-gptq-dflash2-b16. Tests: engine_e2e takes the tiny Gemma 4 (shaped like the 31B) through the whole route at --tp 2: the tap's files, by name and width on each rank; rad-convert with the two shipped recipes, every trunk linear fitted and none rounded to nearest; and the GPTQ container's KL against the bf16 model on held-out documents more than three times below the round-to-nearest one's (0.0018 against 0.0105). With rank 0's and rank 1's .part blocks swapped the margin is 2.2 times, which fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
66c86b9f89
commit
d8b9ce3a32
7 files changed
+404
-3
No files matched your search
@@ -0,0 +1,44 @@
|
||||
# gemma4-31b-dense-bf16-w4a8g-df2.recipe -- Gemma 4 31B dense (text) from Google's bf16 checkpoint
|
||||
# at w4a8 with the trunk's int4 codes chosen by GPTQ, and RedHatAI's DFlash2 speculator: the
|
||||
# gemma4-31b-dense-bf16-w4a8-df2.recipe container (same grid, same kernels, same size) with the
|
||||
# rounding fitted to the bf16 model's own activations instead of to the nearest point.
|
||||
#
|
||||
# CALIB=DIR rad-convert <gemma-4-31B-it> --draft-model <gemma-4-31B-it-speculator.dflash2> \
|
||||
# --recipe data/recipes/gemma4-31b-dense-bf16-w4a8g-df2.recipe \
|
||||
# --set quantization_config.quant_method=compressed-tensors -o gemma4-31b-dense-w4a8g-df2-qkv.rad
|
||||
#
|
||||
# DIR holds the trunk's Hessians, recorded from the bf16 checkpoint by arch/gemma4's calibration
|
||||
# tap (RADIANCE_CALIB_DIR; its files carry this container's weight names): every layer's q|k|v and
|
||||
# gate|up input whole, and attn_o's and ffn_down's as one block a rank (`.part`), which libquant
|
||||
# places on the diagonal. The corpus is the GPTQ one in docs/GEMMA4-31B-GPTQ.md: Gemma 4's tool
|
||||
# calls among chat, code, math and reasoning, rendered with the model's own template.
|
||||
#
|
||||
# Why: round to nearest moves the 31B's distribution where a reply is most constrained. After an
|
||||
# argument string in a tool call, `sku:<|"|>MS-110`, the bf16 model closes the string (`<|"|>`, ~1.0)
|
||||
# and the round-to-nearest trunk prefers `**,` (58% against 41%), so a streamed call stalls.
|
||||
#
|
||||
# Everything else is the -df2 recipe's: the drafter, its head and the trunk's int8 lm_head.
|
||||
|
||||
blk.*.attn_qkv.weight gptq codes=i4 group=128 scale=f16 rule=search calib=$CALIB
|
||||
blk.*.attn_o.weight gptq codes=i4 group=128 scale=f16 rule=search calib=$CALIB
|
||||
blk.*.ffn_down.weight gptq codes=i4 group=128 scale=f16 rule=search calib=$CALIB
|
||||
blk.*.ffn_gate_up.weight gptq codes=i4 group=128 scale=f16 rule=search calib=$CALIB
|
||||
|
||||
output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
|
||||
# The drafter's seven linears: block fp8, read at fp8a8 against an E4M3 activation, as the block
|
||||
# declares them (rad_fp8.h's DenseFP8). The convolution projections, the selector and the norms
|
||||
# stay bf16, as the block reads them.
|
||||
dflash.fc.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_q.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_k.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_v.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.ffn_gate_up.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.blk.*.ffn_down.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
|
||||
# The draft head: the trunk's tied table under the block's own name, int8 with an f16 scale per
|
||||
# (row, 128 of K), which the block reads at w8a8 (rad_block_dflash2.h, head_i8). Not the 2-bit
|
||||
# grid the Qwen3.8 recipes use: the selector then ranks the candidates an 8-bit head proposes.
|
||||
# Drafts are verified, so this changes what is proposed, never what is accepted.
|
||||
dflash.draft_head.weight rtn codes=i8 group=128 scale=f16 clamp=sym
|
||||
Reference in new issue
Block a user