From ccb5071228eb35f3ecbfd46f67158792931794e4 Mon Sep 17 00:00:00 2001 From: keptn42 Date: Sat, 31 Oct 2026 09:46:43 +0000 Subject: [PATCH] data/recipes: ling3-w4a8-rtn and ling3-w4a8-gptq -- Ling-3.0's routed experts at four bits The routed experts as int4 codes with a bf16 scale per 128 of K, everything else as the checkpoint holds it: rounded to nearest, or chosen by GPTQ against a calibration run of the first container. One format, so the same kernels serve both. --- data/recipes/ling3-w4a8-gptq.recipe | 18 ++++++++++++++++++ data/recipes/ling3-w4a8-rtn.recipe | 14 ++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 data/recipes/ling3-w4a8-gptq.recipe create mode 100644 data/recipes/ling3-w4a8-rtn.recipe diff --git a/data/recipes/ling3-w4a8-gptq.recipe b/data/recipes/ling3-w4a8-gptq.recipe new file mode 100644 index 00000000..cef55bea --- /dev/null +++ b/data/recipes/ling3-w4a8-gptq.recipe @@ -0,0 +1,18 @@ +# ling3-w4a8-gptq.recipe -- Ling-3.0-flash or a fine-tune of it (Ling-3.0-flash-Sante) from the bf16 +# checkpoint: the routed experts at four bits, an int4 code and a bf16 scale per 128 of K, chosen by +# GPTQ against the Hessians of a calibration run (docs/MOE-W4.md "Calibration"); everything else as +# the checkpoint holds it. The format is ling3-w4a8-rtn.recipe's, so the same kernels serve both. +# +# 1. rad-convert --recipe data/recipes/ling3-w4a8-rtn.recipe -o ling3-w4a8-rtn.rad +# 2. RADIANCE_CALIB_DIR= radiance --model ling3-w4a8-rtn.rad ... (a calibration run: +# whole experts per rank; push a corpus that looks like the traffic through prefill) +# 3. CALIB= rad-convert --recipe data/recipes/ling3-w4a8-gptq.recipe \ +# --reuse ling3-w4a8-rtn.rad -o ling3-w4a8-gptq.rad +# +# A routed expert's down projection takes its own Hessian where the calibration routed it enough rows, +# the layer's pooled one otherwise (libquant says which on stderr). +# +# Measured on Ling-3.0-flash-Sante as ling3-w4a8-rtn.recipe is: mean KL 0.036, top-1 agreement +# 92.96%, from 1.26M calibration tokens of medical text, documents, code, tool calls and chat. + +blk.*.ffn_*_exps.*.weight gptq codes=i4 group=128 scale=bf16 calib=$CALIB diff --git a/data/recipes/ling3-w4a8-rtn.recipe b/data/recipes/ling3-w4a8-rtn.recipe new file mode 100644 index 00000000..ea0b4f1b --- /dev/null +++ b/data/recipes/ling3-w4a8-rtn.recipe @@ -0,0 +1,14 @@ +# ling3-w4a8-rtn.recipe -- Ling-3.0-flash or a fine-tune of it (Ling-3.0-flash-Sante) from the bf16 +# checkpoint: the routed experts at four bits, an int4 code and a bf16 scale per 128 of K, rounded to +# nearest; everything else as the checkpoint holds it (the KDA and MLA projections, the dense layers, +# the shared expert, the router, the embedding and lm_head in bf16). +# +# rad-convert --recipe data/recipes/ling3-w4a8-rtn.recipe -o ling3-w4a8-rtn.rad +# +# It is the container to calibrate in: served with RADIANCE_CALIB_DIR set, its experts' Grams feed +# the GPTQ recipe. +# +# Measured on Ling-3.0-flash-Sante with the engine's KL mode against the bf16 model (wikitext-2, +# 100 chunks of 512 tokens, the second half of each scored): mean KL 0.038, top-1 agreement 92.54%. + +blk.*.ffn_*_exps.*.weight rtn codes=i4 group=128 scale=bf16