Archived
66 lines
4.2 KiB
Plaintext
66 lines
4.2 KiB
Plaintext
# qwen4exp-w4-hc8m-pe.recipe -- qwen4exp-w4-hc8m.recipe with the routed experts quantised by GPTQ
|
|
# against the bf16 model's own Hessians -- each expert's own for `down`, the layer's for `gate_up` --
|
|
# and the ten experts that carry the most of their layer's output kept plain bf16
|
|
# (docs/MOE-W4.md, "Protected experts").
|
|
#
|
|
# CALIB=DIR rad-convert <Qwen3.8-Flash-Next checkpoint> \
|
|
# --recipe data/recipes/qwen4exp-w4-hc8m-pe.recipe --reuse q38-flashnext-w4-mtp-hc8m.rad \
|
|
# -o q38-flashnext-w4-mtp-hc8m-pe.rad
|
|
#
|
|
# DIR holds those Hessians, recorded from the bf16 model (docs/MOE-W4.md, "Calibration"); --reuse
|
|
# copies every weight whose rule is the same as in qwen4exp-w4-hc8m.recipe. Everything not named
|
|
# here is served as the checkpoint holds it; the first rule that matches a weight decides it.
|
|
|
|
# The protected experts, from a 1M-token recording of the bf16 model on the calibration corpus:
|
|
# an expert whose share of its layer's down-input energy is at least 3% and at least three times its
|
|
# share of the routing, and on each rank's half of the layer an even count -- the four-bit GEMM takes
|
|
# the rest as two equal tables by parity -- by adding that half's next most energetic expert
|
|
# (407/496, 350/292, 290/392 and 445,143/399,122 below). Layer 47's expert 445 alone carries 64% of
|
|
# its layer's down-input energy from 0.4% of the routing.
|
|
blk.34.ffn_*_exps.407.weight cast dtype=bf16
|
|
blk.34.ffn_*_exps.496.weight cast dtype=bf16
|
|
blk.44.ffn_*_exps.292.weight cast dtype=bf16
|
|
blk.44.ffn_*_exps.350.weight cast dtype=bf16
|
|
blk.46.ffn_*_exps.290.weight cast dtype=bf16
|
|
blk.46.ffn_*_exps.392.weight cast dtype=bf16
|
|
blk.47.ffn_*_exps.122.weight cast dtype=bf16
|
|
blk.47.ffn_*_exps.143.weight cast dtype=bf16
|
|
blk.47.ffn_*_exps.399.weight cast dtype=bf16
|
|
blk.47.ffn_*_exps.445.weight cast dtype=bf16
|
|
|
|
# Every other routed expert, trunk and MTP layer alike: int4, a bf16 scale a group of 128, rotated
|
|
# by the 128-wide Hadamard, chosen by GPTQ against $CALIB. The MTP layer has no recording and is
|
|
# rounded to nearest, which libquant says on stderr.
|
|
blk.*.ffn_*_exps.*.weight gptq codes=i4 group=128 scale=bf16 transform=fwht128 calib=$CALIB
|
|
|
|
# Every connection's two mixing matrices -- the 96 trunk connections, the final mixer and the MTP
|
|
# head's three -- as E4M3 rows with an f32 scale a group of each row. A 128x128 block cannot cover
|
|
# them: lowrank is 320, 2.5 blocks. Down is [320, 10240] and takes a scale every 128 columns; up is
|
|
# [10240, 320] and takes four scales a row, 80 columns each.
|
|
*_hc_down.weight rtn codes=fp8_e4m3 group=128 scale=f32
|
|
*_hc_up.weight rtn codes=fp8_e4m3 group=80 scale=f32
|
|
|
|
# The MTP head's fc_hidden and fc_embedding, the same rows. They only ever change the drafts.
|
|
mtp.fc_hidden.weight rtn codes=fp8_e4m3 group=128 scale=f32
|
|
mtp.fc_embedding.weight rtn codes=fp8_e4m3 group=128 scale=f32
|
|
|
|
# The block-scaled fp8 linears. The QSA indexer's projection is not one of them: its top-k is a
|
|
# hard choice between blocks, and keeping it as the checkpoint holds it costs 20 MB.
|
|
blk.*.attn_qg.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
|
blk.*.attn_k.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
|
blk.*.attn_v.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
|
blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
|
blk.*.ssm_inz.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
|
blk.*.ssm_out.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
|
blk.*.ffn_gate_up_shexp.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
|
blk.*.ffn_down_shexp.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
|
|
|
# The lm_head, block fp8.
|
|
output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
|
|
|
# The n-gram table at one fixed E4M3 scale; qwen4exp-w4.recipe says where the value comes from.
|
|
blk.*.ple_ngram.weight rtn codes=fp8_e4m3 block=*x* scale=bf16 rule=fixed scale_value=1.99317932128906e-4
|
|
|
|
# The MTP head's 2-bit draft head.
|
|
mtp.draft_head.weight rtn codes=u2 zero=u8 group=128 scale=f16
|