Archived
The gemma4_bf16 architecture (sliding and global attention, the proportional RoPE ladder, the assistant head as a drafter that reads the trunk's cache, the vision tower), its w4a8 decode junctions, the h512/gqa8 and h256/gqa2 attention kernels, compressed-tensors int4 import, multi-EOS from generation_config, the call/reasoning reply format, a window group that keeps the keys a prefill chunk still reads, and window snapshots in checkpoint slots so a prefix hit on a sliding-window trunk resumes. Fixes on top: the investigation switches and diagnostic blocks out of the served paths; int4 import through the checkpoint import framework; attention_k_eq_v from the config; the fused junctions only where every reader takes their pair; a shared-KV head binds no group of its own; the compose file without HSA_ENABLE_IPC_MODE_LEGACY (TP2 fails with it on ROCm 10.1); a checkpoint carries a window only where a hit resumes from it; the README says the linked container is keptn42's calibrated GPTQ build and what the in-tree recipe gives.
This commit is contained in:
commit
7c7f755931
84 files changed
+10292
-230
No files matched your search
@@ -0,0 +1,28 @@
|
||||
# gemma4-31b-dense-bf16-w4a8.recipe -- Gemma 4 31B dense (text) from a bf16 checkpoint: Google's
|
||||
# gemma-4-31B-it, or any finetune of it, which ships no QAT form. Same grid and size as the CT
|
||||
# recipe (int4, an f16 scale a 128 columns, ~20 GiB with the assistant head), with the
|
||||
# least-squares scale search instead of absmax.
|
||||
#
|
||||
# rad-convert <gemma-4-31B-it> --recipe data/recipes/gemma4-31b-dense-bf16-w4a8.recipe \
|
||||
# --set quantization_config.quant_method=compressed-tensors \
|
||||
# [--draft-model <gemma-4-31B-it-assistant>] -o gemma4-31b-dense-bf16-w4a8.rad
|
||||
#
|
||||
# The --set selects the gemma4 plugin, which is registered for the quantised form both releases
|
||||
# convert to. The plugin names the same `X.weight` for either: the CT-INT4 release's packed codes
|
||||
# are imported under that name by the checkpoint reader.
|
||||
# Norms, the embedding/lm_head and the assistant head are kept bf16 (no rule matches them).
|
||||
#
|
||||
# Why from bf16 when a QAT release exists: the assistant head was trained against the bf16 trunk.
|
||||
# Served from this container it accepts 0.71/0.62/0.63 of its k=3 drafts on prose, against
|
||||
# 0.49/0.50/0.44 from the QAT container, at the same step time.
|
||||
#
|
||||
# A linear may be kept at int8 on the same grid (gemm_nt_q w8a8), e.g.
|
||||
# blk.*.attn_o.weight rtn codes=i8 group=128 scale=f16
|
||||
# Measured with attention + down_proj at int8: acceptance unchanged, decode 20 % slower.
|
||||
|
||||
blk.*.attn_q.weight rtn codes=i4 group=128 scale=f16 rule=search
|
||||
blk.*.attn_k.weight rtn codes=i4 group=128 scale=f16 rule=search
|
||||
blk.*.attn_v.weight rtn codes=i4 group=128 scale=f16 rule=search
|
||||
blk.*.attn_o.weight rtn codes=i4 group=128 scale=f16 rule=search
|
||||
blk.*.ffn_down.weight rtn codes=i4 group=128 scale=f16 rule=search
|
||||
blk.*.ffn_gate_up.weight rtn codes=i4 group=128 scale=f16 rule=search
|
||||
@@ -0,0 +1,27 @@
|
||||
# gemma4-31b-dense-w4a8.recipe -- Gemma 4 31B dense (text), from its CT-INT4 (w4a16)
|
||||
# checkpoint, as the w4a8 container serves it.
|
||||
#
|
||||
# rad-convert <gemma-4-31B-it-qat-w4a16-ct checkpoint> \
|
||||
# --recipe data/recipes/gemma4-31b-dense-w4a8.recipe -o gemma4-31b-dense-w4a8.rad
|
||||
#
|
||||
# The checkpoint's GEMM weights are CT-INT4 (group-32, a bf16 scale a 32 codes, no zero point),
|
||||
# imported as such (core/format/checkpoint.h); the rules re-quantise them to group-128 int4 with an
|
||||
# f16 scale, the grid the w4a8 kernels read. The norms
|
||||
# (input / post-attention / pre- and post-feedforward layernorms, the q/k head norms) and the
|
||||
# embedding + lm_head are bf16 and are kept as the checkpoint holds them -- a weight no rule
|
||||
# matches is served in its checkpoint form. A rank-1 weight a pattern happens to match is declined
|
||||
# by the quantiser and kept as it is, so the norms stay bf16 even under a broad pattern.
|
||||
#
|
||||
# With the assistant (draft) head merged in -- add `--draft-model <gemma-4-31B-it-assistant>` --
|
||||
# its weights are declared as `mtp.*` and no rule below matches them: the head is served bf16 as
|
||||
# Google ships it (0.9 GB). The patterns are anchored, so `blk.*` never reaches `mtp.blk.*`.
|
||||
# Its lm_head (`mtp.output.weight`, 0.5 GB, read once a draft round) may be made int8 with
|
||||
# mtp.output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
# and the head then reads it through logits_gemm_i8; a draft only proposes, the trunk verifies.
|
||||
|
||||
blk.*.attn_q.weight rtn codes=i4 group=128 scale=f16
|
||||
blk.*.attn_k.weight rtn codes=i4 group=128 scale=f16
|
||||
blk.*.attn_v.weight rtn codes=i4 group=128 scale=f16
|
||||
blk.*.attn_o.weight rtn codes=i4 group=128 scale=f16
|
||||
blk.*.ffn_gate_up.weight rtn codes=i4 group=128 scale=f16
|
||||
blk.*.ffn_down.weight rtn codes=i4 group=128 scale=f16
|
||||
Reference in new issue
Block a user