Archived
radiance 1.0.0
This commit is contained in:
commit
ae74a8aebf
616 files changed
+338692
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,18 @@
|
||||
# minicpm5-2b-bf16-dspark.recipe -- MiniCPM5-2B in bf16 as the checkpoint ships it, with the DSpark
|
||||
# drafter merged in (--draft-model). Every weight of the model itself, the lm_head included, is the
|
||||
# checkpoint's own; the drafter is quantised as in minicpm5-2b-dspark.recipe, because the DSpark
|
||||
# block reads its weights in one form only: block fp8, and the vocabulary head as 2-bit codes (the
|
||||
# head only proposes; the model's own bf16 lm_head scores every token it accepts).
|
||||
#
|
||||
# rad-convert <MiniCPM5-2B checkpoint> --draft-model <MiniCPM5-2B-DSpark checkpoint> \
|
||||
# --tokenizer <MiniCPM5-2B checkpoint>/tokenizer.json \
|
||||
# --recipe data/recipes/minicpm5-2b-bf16-dspark.recipe -o minicpm5-2b-bf16.rad
|
||||
|
||||
dspark.draft_head.weight rtn codes=u2 zero=u8 group=128 scale=f16
|
||||
dspark.fc.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.attn_q.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.attn_k.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.attn_v.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.ffn_gate_up.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.ffn_down.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
@@ -0,0 +1,29 @@
|
||||
# minicpm5-2b-dspark.recipe -- MiniCPM5-2B with the DSpark drafter, as the minicpm5-2b-dspark.rad
|
||||
# container serves it (scripts/convdspark.sh).
|
||||
#
|
||||
# OpenBMB publishes MiniCPM5-2B in bf16 only, so every linear is made block fp8 here: one amax a
|
||||
# 128x128 block, scale = amax/448 rounded to bf16. The checkpoint then serves through llama_dense_fp8
|
||||
# with the graph llama_fp8 declares over an fp8 release. Also:
|
||||
#
|
||||
# - the lm_head, block fp8: the widest GEMM in the model at half the bytes
|
||||
# - the drafter's linears, block fp8 from its bf16 release
|
||||
# - the drafter's 2-bit copy of the target's head (u2 codes, an f16 scale and a u8 zero a group
|
||||
# of 128), read by its draft passes only
|
||||
#
|
||||
# Every norm, the embedding and the drafter's Markov codebooks stay bf16.
|
||||
|
||||
output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.draft_head.weight rtn codes=u2 zero=u8 group=128 scale=f16
|
||||
|
||||
blk.*.attn_qkv.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
blk.*.ffn_gate_up.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
blk.*.ffn_down.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
|
||||
dspark.fc.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.attn_q.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.attn_k.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.attn_v.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.ffn_gate_up.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dspark.blk.*.ffn_down.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
@@ -0,0 +1,15 @@
|
||||
# q36-35b-a3b-fp8.recipe -- Qwen3.6-35B-A3B-FP8 with its MTP head, as the q36-35b-a3b-fp8.rad
|
||||
# container serves it.
|
||||
#
|
||||
# rad-convert <Qwen3.6-35B-A3B-FP8 checkpoint> --recipe data/recipes/q36-35b-a3b-fp8.recipe \
|
||||
# -o q36-35b-a3b-fp8.rad
|
||||
#
|
||||
# The linears -- attention, delta net, shared and routed experts, the MTP layer's -- are
|
||||
# block-scaled fp8 in the checkpoint and kept as they are. What the recipe adds:
|
||||
#
|
||||
# - the lm_head, block fp8: the widest GEMM in the model at half the bytes
|
||||
# - the MTP head's 2-bit copy of the lm_head (u2 codes, an f16 scale and a u8 zero a group of
|
||||
# 128), which the draft rounds read in place of the full head
|
||||
|
||||
output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
mtp.draft_head.weight rtn codes=u2 zero=u8 group=128 scale=f16
|
||||
@@ -0,0 +1,11 @@
|
||||
# q38-27b-bf16.recipe -- Qwen3.8-27B (the bf16 release), as the q38-27b-bf16.rad container serves
|
||||
# it.
|
||||
#
|
||||
# rad-convert <Qwen3.8-27B checkpoint> --recipe data/recipes/q38-27b-bf16.recipe \
|
||||
# -o q38-27b-bf16.rad
|
||||
#
|
||||
# Every weight is served at the checkpoint's own precision except the lm_head, which is block fp8:
|
||||
# the widest GEMM in the model at half the bytes, read through the fp8 logits kernel. Without this
|
||||
# rule the same checkpoint loads directly and the head is read as bf16.
|
||||
|
||||
output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
@@ -0,0 +1,28 @@
|
||||
# q38-27b-fp8-df2.recipe -- Qwen3.8-27B-FP8 with the DFlash2 drafter, as the q38-27b-fp8-df2.rad
|
||||
# container serves it.
|
||||
#
|
||||
# rad-convert <Qwen3.8-27B-FP8 checkpoint> --draft-model <DFlash2 checkpoint> \
|
||||
# --recipe data/recipes/q38-27b-fp8-df2.recipe -o q38-27b-fp8-df2.rad
|
||||
#
|
||||
# The trunk's linears are block-scaled fp8 in the checkpoint and kept as they are; the norms, the
|
||||
# embedding, the delta net's a/b projection and the vision tower are bf16 and kept as they are.
|
||||
# What the recipe adds:
|
||||
#
|
||||
# - the lm_head, block fp8: the widest GEMM in the model at half the bytes
|
||||
# - the drafter's linears, block fp8 from its bf16 release: it is read whole on every decode
|
||||
# step, and a draft is verified, so its precision can move acceptance and never an emitted token
|
||||
# - the drafter's 2-bit copy of the target's head (u2 codes, an f16 scale and a u8 zero a group
|
||||
# of 128), read by its draft rounds only
|
||||
#
|
||||
# The drafter's selector projection, codebooks and convolution weights stay bf16.
|
||||
|
||||
output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
dflash.draft_head.weight rtn codes=u2 zero=u8 group=128 scale=f16
|
||||
|
||||
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
|
||||
@@ -0,0 +1,65 @@
|
||||
# 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
|
||||
@@ -0,0 +1,46 @@
|
||||
# qwen4exp-w4-hc8m.recipe -- Qwen3.8-Flash-Next from its bf16 checkpoint, as the
|
||||
# q38-flashnext-w4-mtp-hc8m.rad container serves it: qwen4exp-w4.recipe, plus the gated-residual
|
||||
# mixing matrices and the MTP head's two entry matrices as E4M3 rows.
|
||||
#
|
||||
# rad-convert <Qwen3.8-Flash-Next checkpoint> --recipe data/recipes/qwen4exp-w4-hc8m.recipe \
|
||||
# -o q38-flashnext-w4-mtp-hc8m.rad
|
||||
#
|
||||
# The uncensored release (orcarouter/Qwen3.8-Flash-Next-Uncensored) takes the same recipe.
|
||||
# Everything not named here is served as the checkpoint holds it; the first rule that matches a
|
||||
# weight decides it. The routed experts' GPTQ form is one rule ahead of this file:
|
||||
# --quant 'blk.*.ffn_*_exps.*.weight=gptq:codes=i4,group=128,scale=bf16,transform=fwht128,calib=$CALIB'
|
||||
|
||||
# The routed experts, trunk and MTP layer alike: int4, a bf16 scale a group of 128, rotated by the
|
||||
# 128-wide Hadamard. qwen4exp-w4.recipe says why.
|
||||
blk.*.ffn_*_exps.*.weight rtn codes=i4 group=128 scale=bf16 transform=fwht128
|
||||
|
||||
# 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
|
||||
@@ -0,0 +1,48 @@
|
||||
# qwen4exp-w4.recipe -- Qwen3.8-Flash-Next from its bf16 checkpoint, as the
|
||||
# q38-flashnext-w4-mtp.rad container serves it: fp8 linears, four-bit rotated experts, the n-gram
|
||||
# table at E4M3, the MTP head with its 2-bit draft head; the gated-residual mixing matrices and the
|
||||
# MTP head's fc matrices stay bf16 (qwen4exp-w4-hc8m.recipe makes those E4M3 too).
|
||||
#
|
||||
# rad-convert <Qwen3.8-Flash-Next checkpoint> --recipe data/recipes/qwen4exp-w4.recipe \
|
||||
# -o q38-flashnext-w4-mtp.rad
|
||||
#
|
||||
# The checkpoint carries no quantization_config, so everything not named here is served as the
|
||||
# checkpoint holds it: every norm gain, A_log, dt_bias, conv1d, the delta net's a/b projections
|
||||
# (48 rows, not a whole scale block), the router and shared-expert gate, the QSA indexer's
|
||||
# projection, the embedding, the PLE projections and the hyper-connection weights. Rank-1 weights a
|
||||
# pattern happens to match are declined by the quantiser and kept as they are. The first rule that
|
||||
# matches a weight decides it.
|
||||
|
||||
# The routed experts, trunk and MTP layer alike: int4 codes, a bf16 scale a group of 128 along K,
|
||||
# each row rotated by the 128-wide Hadamard first. The experts are 112.8 GiB at E4M3 and do not fit
|
||||
# two cards; at four bits they do. Round-to-nearest with absmax scales; the calibrated GPTQ form of
|
||||
# the same encoding is one rule ahead of this file:
|
||||
# --quant 'blk.*.ffn_*_exps.*.weight=gptq:codes=i4,group=128,scale=bf16,transform=fwht128,calib=$CALIB'
|
||||
blk.*.ffn_*_exps.*.weight rtn codes=i4 group=128 scale=bf16 transform=fwht128
|
||||
|
||||
# The block-scaled fp8 linears: E4M3 codes, a bf16 scale a 128x128 block. 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: the widest GEMM in the model at half the bytes.
|
||||
output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
|
||||
# The n-gram table, 51B parameters: E4M3 with ONE scale for all 320 million rows, fixed rather than
|
||||
# measured -- an absmax over the whole table cannot be taken a block of rows at a time, and the
|
||||
# table streams. 1.99317932128906e-4 is bf16 0x3951, the value Qwen3.8-Flash-Next-FP8 ships in its
|
||||
# own `ngram_embedding.weight_scale`; it sits on a three-octave plateau (2^-13..2^-10 give rel_l2
|
||||
# 0.02662 to five digits) with 1.7x headroom over the table's absmax.
|
||||
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 copy of the lm_head -- u2 codes, an f16 scale and a u8 zero a group of 128 --
|
||||
# which the draft rounds read in place of the full head. A draft is verified by the trunk, so this
|
||||
# moves acceptance and never an emitted token.
|
||||
mtp.draft_head.weight rtn codes=u2 zero=u8 group=128 scale=f16
|
||||
@@ -0,0 +1,80 @@
|
||||
# qwen4exp-w4nl64-i8-hc8m.recipe -- Qwen3.8-Flash-Next from its bf16 checkpoint as it is served
|
||||
# (the w4nl64-i8lm.rad container): the routed experts as rotated u4 codes into the w4nl
|
||||
# codebook with one E4M3 scale a (row, 64 of K) under a fixed f32 of 2^-13 (libr4d's w4nl64a8h),
|
||||
# the codes chosen by GPTQ and three sweeps of coordinate descent; ten protected experts plain
|
||||
# bf16; the trunk's block linears and the lm_head int8, served W8A8; the connections' mixing
|
||||
# matrices and the MTP head's fc matrices E4M3; the n-gram table at one fixed E4M3 scale.
|
||||
#
|
||||
# Measured with the engine's KL mode against the bf16 model (docs/MOE-W4.md, "What is served"):
|
||||
# mean KL 0.0789 and top-1 agreement 92.85% over the whole corpus, where a second bf16
|
||||
# implementation scores 0.0399 / 95.13%; 0.0239 / 94.57% on text and assistant turns.
|
||||
#
|
||||
# CALIB=DIR rad-convert <Qwen3.8-Flash-Next checkpoint> \
|
||||
# --recipe data/recipes/qwen4exp-w4nl64-i8-hc8m.recipe -o w4nl64-i8lm.rad
|
||||
#
|
||||
# DIR holds each layer's pooled Grams, recorded from ten million tokens of the bf16 model, and each
|
||||
# expert's own down Gram, from one million tokens with the per-expert tap, side by side; libquant
|
||||
# takes an expert's own wherever it holds at least 4096 rows and the layer's otherwise
|
||||
# (docs/MOE-W4.md, "Calibration"). A variant of this recipe converted with --reuse w4nl64-i8lm.rad
|
||||
# re-quantises only the weights whose rule changed.
|
||||
#
|
||||
# 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: u4 codes into the w4nl table, rotated by
|
||||
# the 128-wide Hadamard, an E4M3 scale a group of 64 under the fixed 2^-13 searched for least error
|
||||
# as stored, the codes chosen by GPTQ against $CALIB and then swept three times by coordinate
|
||||
# descent. The experts' scales sit between 2^-15 and 2^-10.6, inside E4M3's normal range under
|
||||
# 2^-13 with four binades either side; one past its top would be held there and said on stderr.
|
||||
# The MTP layer has no recording and is rounded to nearest, which libquant says on stderr.
|
||||
blk.*.ffn_*_exps.*.weight gptq table=w4nl group=64 scale=fp8_e4m3 scale2=f32 block2=*x* scale2_value=0.0001220703125 transform=fwht128 rule=search cd=3 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 trunk's block linears as int8, a scale per 128 columns of a row searched for least error.
|
||||
# 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=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.attn_k.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.attn_v.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.attn_output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.ssm_inz.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.ssm_out.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.ffn_gate_up_shexp.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.ffn_down_shexp.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
|
||||
# The lm_head, int8 with a bf16 scale a row per 128 columns (logits_gemm_i8): at E4M3 it costs
|
||||
# ~0.6 points of top-1 on its own.
|
||||
output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
|
||||
# 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
|
||||
@@ -0,0 +1,79 @@
|
||||
# qwen4exp-w5dn64-i8-hc8m.recipe -- qwen4exp-w4nl64-i8-hc8m.recipe with every routed expert's DOWN
|
||||
# projection at five bits: u5 codes into libquant's 32-level w5nl table at the same E4M3 scale a
|
||||
# (row, 64 of K) under the fixed 2^-13 (libr4d's w5nl64a8h), GPTQ and three sweeps of coordinate
|
||||
# descent. gate_up stays w4nl64a8h. Down is a third of an expert's weights and the larger share of
|
||||
# its output error (held-out relative error 0.094 against gate_up's 0.064), so the fifth bit goes
|
||||
# there first: +8% of the experts' bytes for 72% less of down's error energy.
|
||||
#
|
||||
# Against the served recipe, qwen4exp-w4nl64-i8-hc8m.recipe (docs/MOE-W4.md): mean KL 0.0789 ->
|
||||
# 0.0717, top-1 92.85% -> 93.34%; and decode +4%, prefill -19% at two cards, the larger experts
|
||||
# leaving fewer of them resident. It is not the served recipe because of that prefill cost.
|
||||
#
|
||||
# CALIB=DIR rad-convert <Qwen3.8-Flash-Next checkpoint> \
|
||||
# --recipe data/recipes/qwen4exp-w5dn64-i8-hc8m.recipe --reuse w4nl64-i8lm.rad \
|
||||
# -o w5dn64-i8lm.rad
|
||||
#
|
||||
# DIR is the served recipe's calibration directory; --reuse copies the trunk and the gate_up
|
||||
# projections. 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: its down projection as u5 codes into the
|
||||
# w5nl table and its gate_up as u4 codes into the w4nl table, both rotated by the 128-wide
|
||||
# Hadamard, an E4M3 scale a group of 64 under the fixed 2^-13 searched for least error as stored,
|
||||
# the codes chosen by GPTQ against $CALIB and then swept three times by coordinate descent. The
|
||||
# experts' scales sit between 2^-15 and 2^-10.6 under w4nl's top level of 22, and half a binade
|
||||
# lower under w5nl's 30 -- inside E4M3's normal range under 2^-13 either way, with binades to
|
||||
# spare; one past its top would be held there and said on stderr. The MTP layer has no recording
|
||||
# and is rounded to nearest, which libquant says on stderr.
|
||||
blk.*.ffn_down_exps.*.weight gptq table=w5nl group=64 scale=fp8_e4m3 scale2=f32 block2=*x* scale2_value=0.0001220703125 transform=fwht128 rule=search cd=3 calib=$CALIB
|
||||
blk.*.ffn_*_exps.*.weight gptq table=w4nl group=64 scale=fp8_e4m3 scale2=f32 block2=*x* scale2_value=0.0001220703125 transform=fwht128 rule=search cd=3 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 trunk's block linears as int8, a scale per 128 columns of a row searched for least error.
|
||||
# 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=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.attn_k.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.attn_v.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.attn_output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.ssm_inz.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.ssm_out.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.ffn_gate_up_shexp.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
blk.*.ffn_down_shexp.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
|
||||
# The lm_head, int8 with a bf16 scale a row per 128 columns (logits_gemm_i8): at E4M3 it costs
|
||||
# ~0.6 points of top-1 on its own.
|
||||
output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
|
||||
|
||||
# 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
|
||||
Reference in new issue
Block a user