Archived
M2XFP4 (MXFP4v2): quantiser, gfx1201 WMMA kernels, host rows, df2 wiring, .rad packer (Import::ParoM2), stability fixes (counters-in-scratch x3, aql publish fences), kbench rows, runbook (REMAINING.md)
This commit is contained in:
1 parent
9eaf10da6e
commit
ea0908596b
60 files changed
+4619
-193
No files matched your search
+100
-8
@@ -2,14 +2,15 @@
|
||||
|
||||
Every flag of every tool, with examples. Start with [GUIDE.md](GUIDE.md).
|
||||
|
||||
Six binaries and the `rad-export` script are installed beside `radiance`; the shell harnesses
|
||||
live in `scripts/`:
|
||||
Six binaries and the `rad-export` and `rad-pack-m2xfp4` scripts are installed beside `radiance`;
|
||||
the shell harnesses live in `scripts/`:
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| [`rad-info`](#rad-info) | print what a `.rad` container holds. Loads no plugins |
|
||||
| [`rad-convert`](#rad-convert) | safetensors or GGUF in, `.rad` out, quantised by a recipe |
|
||||
| [`rad-export`](#rad-export) | a finetune (merged checkpoint or LoRA adapter) to a `.rad`, with the base model's own recipe |
|
||||
| [`rad-pack-m2xfp4`](#rad-pack-m2xfp4) | a ParoQuant M2XFP4 fine-tune to a `.rad`, its packed planes imported rather than re-quantised |
|
||||
| [`rad-kbench`](#rad-kbench) | correctness, completeness and speed of every kernel library |
|
||||
| [`rad-tune`](#rad-tune) | benchmark each kernel's tunable space at this model's shapes, on this machine |
|
||||
| [`rad-schemas`](#rad-schemas) | print and diff the op schemas plugins declare |
|
||||
@@ -167,6 +168,14 @@ output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf1
|
||||
blk.*.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
|
||||
```
|
||||
|
||||
A checkpoint whose `quantization_config` names a form rad-convert imports (a ParoQuant release at
|
||||
`int5-bitplane`, AWQ int4, MXFP4 or M2XFP4, Quark's MXFP4, GPTQ/`auto-round`, compressed-tensors'
|
||||
int4, NVFP4, ModelOpt) is written plane by plane instead: the codes, scales and metadata bytes as
|
||||
they ship, the learned rotations as the encoding's `givens` tables, nothing dequantised or
|
||||
re-quantised. Those weights need no rule -- a rule that matches one would ask a quantiser to read
|
||||
codes as floats, and is refused -- so a recipe beside them covers only what the checkpoint does
|
||||
not ship in a form the architecture declares.
|
||||
|
||||
A pattern is a glob over the whole name: `*` crosses dots, `?` is one character. `$NAME` (or
|
||||
`${NAME}`) in an option is taken from the environment; an unset variable is refused. `--quant`
|
||||
adds rules ahead of the file's:
|
||||
@@ -185,10 +194,11 @@ also matches a norm leaves the norm as it is.
|
||||
| `autoround` | sign-gradient descent on a rounding offset per value and a range factor per block, against the Hessian; `iters` steps of N·K² multiply-adds each |
|
||||
| `paroquant` | a channel scaling and `stages` rounds of Givens pair rotations, learned against the Hessian, then AutoRound on the rotated weight; the encoding's `givens` transform |
|
||||
| `ggml` | `type=` one of llama.cpp's formats (q4_0, q4_1, q5_0, q5_1, q8_0, q2_K..q6_K, iq4_nl, iq4_xs, iq2_xxs, iq2_xs, iq2_s, iq3_xxs, iq3_s, iq1_s, iq1_m), chosen by llama.cpp's own search, imatrix-weighted; the codes are byte for byte llama.cpp's, stored as each type's affine planes. iq2_xxs, iq2_xs and iq1_s need `--imatrix` |
|
||||
| `m2xfp4` | M2XFP: MXFP4 whose group of 32 also carries one metadata byte of four 2-bit subgroup extra mantissas, each a subgroup of 8 columns refining the shared exponent to (1 + k/4) . 2^E; the subgroups' k and the exponent's bias in {-1, 0, 1} (`adaptive=1`, the default; `adaptive=0` pins the bias at 0) are the least squared error choices, the OCP exponent rule, rounding, zero groups and short final groups otherwise the MXFP4 grid's; 4.5 bits an element, weights only, decoded by the quantiser itself (arXiv 2601.19213) |
|
||||
| `cast` | a float weight in another float dtype (`dtype=` f32, bf16, f16, fp8_e4m3, fp8_e5m2), no scale |
|
||||
| `import` | rad-convert's own, not a plugin: the numbers a quantised release ships, in the spelling the kernels read, instead of quantising again. `codes=uN` makes a symmetric grid's signed codes unsigned under a zero point of 2^(N-1); `zero=` is the zero plane's dtype (u4, u8); `scale=` the scale's (f16, bf16, f32), each shipped scale rounded to nearest; `block=RxC` repeats an FP8 scale shipped per row or per tensor over that block grid. It reads an imported integer grid (GPTQ, CT-INT4) or an FP8 weight with a scale per row or per tensor, refuses any other quantised form by name, and keeps a plain float weight as it is. The run reports per rule how many weights it re-expressed and how many scales the new dtype rounded |
|
||||
|
||||
Every quantiser except `ggml`, `cast` and `import` takes the grid options:
|
||||
Every quantiser except `ggml`, `m2xfp4`, `cast` and `import` takes the grid options:
|
||||
|
||||
| option | |
|
||||
|---|---|
|
||||
@@ -204,7 +214,8 @@ Every quantiser except `ggml`, `cast` and `import` takes the grid options:
|
||||
| `clamp` | a signed code's range, `full` or `sym` |
|
||||
|
||||
Examples: MXFP4 is `codes=fp4_e2m1 group=32 scale=e8m0`; NVFP4 is `codes=fp4_e2m1 group=16
|
||||
scale=fp8_e4m3 scale2=f32`; NF4 is `table=nf4 group=64`; a K-quant-like grid is `codes=i4
|
||||
scale=fp8_e4m3 scale2=f32`; its metadata-augmented cousin is the `m2xfp4` quantiser itself; NF4 is
|
||||
`table=nf4 group=64`; a K-quant-like grid is `codes=i4
|
||||
group=32 scale=u6 scale2=f16 group2=256`; a ternary BitNet weight is `table=ternary`.
|
||||
|
||||
A container can hold only what some kernel reads. The converter checks every planned encoding
|
||||
@@ -388,6 +399,84 @@ is `UNSLOTH_HOOK_OUTPUT=<path of the .rad>`, which a trainer UI can list with th
|
||||
|
||||
---
|
||||
|
||||
## rad-pack-m2xfp4
|
||||
|
||||
```
|
||||
rad-pack-m2xfp4 SRC [-o OUT.rad] [--recipe FILE] [--draft DIR] [--rad-convert PATH]
|
||||
[--home DIR] [--jobs N] [--convert-with 'CMD {model} {result_dir} {out}']
|
||||
[--model BASE] [--hf-out DIR] [--convert-path FROM=TO ...]
|
||||
[--verify-only] [--list] [--skip-tables]
|
||||
|
||||
SRC a converted ParoQuant M2XFP4 checkpoint, or a `paroquant.cli.optimize`
|
||||
result directory (quant_grid.json + per-module .pt)
|
||||
-o, --out FILE the container (default: SRC's folder name + .rad, beside SRC)
|
||||
--convert-with C run `paroquant.cli.convert --mode real` through C first, with {model}
|
||||
{result_dir} {out} substituted; a result directory needs it and --model
|
||||
--model BASE the donor checkpoint convert loads (the fine-tune's weights are in the
|
||||
result directory, not in BASE)
|
||||
--hf-out DIR where --convert-with writes (default: SRC/hf), as this machine sees it
|
||||
--convert-path FROM=TO a prefix the convert runtime spells differently (docker exec of a
|
||||
container whose /models is this machine's ~/models), applied to {model},
|
||||
{result_dir} and {out}. Repeatable
|
||||
--recipe FILE rad-convert's recipe for the weights the checkpoint does not ship quantised
|
||||
(data/recipes/q38-27b-paro-m2xfp4-df2.recipe)
|
||||
--draft DIR a drafter merged as dflash.*
|
||||
--verify-only skip rad-convert and check the container at -o against the checkpoint
|
||||
--list print the container's m2xfp4 entries and stop
|
||||
--skip-tables check the three code planes only, not the rotation tables
|
||||
```
|
||||
|
||||
A ParoQuant M2XFP4 fine-tune is a set of `paroquant.cli.optimize` per-module files: trained
|
||||
weights, the learned rotation and the grid's exponent bias, not packed planes. Two steps turn it
|
||||
into a container, and this script owns the seam:
|
||||
|
||||
1. `paroquant.cli.convert --mode real` re-derives each module's codes under the M2XFP4 grid the
|
||||
optimizer trained with and writes an ordinary Hugging Face checkpoint: `X.weight` (e2m1
|
||||
nibbles `[N, K/2]`), `X.weight_scale` (e8m0 `[N, K/32]`), `X.weight_meta` (u8 `[N, K/32]`, four
|
||||
2-bit subgroup multipliers a byte) and the rotation (`X.theta`, `X.pairs`, `X.channel_scales`),
|
||||
with `quantization_config.quant_method = "paroquant_m2xfp4"`. It needs a GPU; the script runs it
|
||||
when it is handed a result directory and `--convert-with`.
|
||||
2. `rad-convert` imports those planes -- `Import::ParoM2` in core/format/checkpoint.cpp: the codes,
|
||||
exponents and metadata bytes become the weight's three planes byte for byte, the rotation
|
||||
becomes the encoding's `givens` tables, and the GEMM is the plain M2XFP4 one over an activation
|
||||
`givens_dense_quant` rotates first. It is CPU-only, so it runs beside a serving GPU.
|
||||
|
||||
Then it reads the container back and proves the seam: every `m2xfp4` entry's three planes are
|
||||
byte-identical to its checkpoint tensors, and the rotation tables are the checkpoint's
|
||||
(`t.scale` = 1/channel_scales in f32, `t.pairs` offset to whole-row columns, `t.angle` widened,
|
||||
`t.dense` the stages composed over groups of 128 in f64 and rounded once).
|
||||
A mismatch exits non-zero; it is not a warning. Loading the container also deserves
|
||||
`rad-kbench -m`: its cases run over the container's own bytes in the layout the kernel asked for.
|
||||
|
||||
```bash
|
||||
# the full model, once the fine-tune lands (convert needs a GPU; the rest does not). The
|
||||
# container's mounts are spelled differently from this machine's; -u keeps the checkpoint's files
|
||||
# this user's, and every path the script hands it is translated by --convert-path.
|
||||
rad-pack-m2xfp4 /media/zee/ai/paro-out-ft-m2xfp4/Qwen3.8-27B-fp16 \
|
||||
--model /media/zee/ai/paro-stage/Qwen3.8-27B-fp16 \
|
||||
--convert-with 'docker exec -u 1000:1000 paro_stage2 python3 -m paroquant.cli.convert \
|
||||
--model {model} --result-dir {result_dir} --output-path {out} --mode real' \
|
||||
--convert-path /media/zee/ai/paro-out-ft-m2xfp4=/out \
|
||||
--convert-path /media/zee/ai/paro-stage=/staging \
|
||||
--convert-path /home/zee/models=/models \
|
||||
--hf-out /home/zee/models/paro-ft-m2xfp4-hf --draft /home/zee/models/hf/Qwen3.8-27B-DFlash2 \
|
||||
--recipe data/recipes/q38-27b-paro-m2xfp4-df2.recipe \
|
||||
-o /home/zee/models/rad/q38-27b-paro-m2xfp4.rad
|
||||
|
||||
# and the pack alone, from the checkpoint the convert left, plus its check
|
||||
rad-pack-m2xfp4 /home/zee/models/paro-ft-m2xfp4-hf \
|
||||
-o /home/zee/models/rad/q38-27b-paro-m2xfp4.rad \
|
||||
--recipe data/recipes/q38-27b-paro-m2xfp4-df2.recipe --draft /home/zee/models/hf/Qwen3.8-27B-DFlash2
|
||||
rad-pack-m2xfp4 --list -o /home/zee/models/rad/q38-27b-paro-m2xfp4.rad
|
||||
```
|
||||
|
||||
The recipe (`data/recipes/q38-27b-paro-m2xfp4-df2.recipe`) covers what the checkpoint does not ship
|
||||
in a form the architecture declares -- f32 norm casts, the bf16 embedding, the head, the drafter's
|
||||
own linears -- and names no trunk linear, which are imported. The alternative shortcut, `convert
|
||||
--mode pseudo` (dequantised fp16 weights) then a `m2xfp4` recipe rule, re-quantises every weight in
|
||||
the unrotated basis: it needs no import, but it is a second lossy step and its planes are not the
|
||||
fine-tune's.
|
||||
|
||||
## rad-kbench
|
||||
|
||||
Checks every kernel every loaded library supplies against the reference library's answers,
|
||||
@@ -467,10 +556,13 @@ on an eighth of the rows.
|
||||
|
||||
`--rerecord FILE` writes the replayed fixtures' cases again with the reference's current answers
|
||||
in the current format, each case keeping the laws it was recorded with. `--record-rows FILE`
|
||||
moves the fixtures' cases into the constraints of every row of the libraries under test (another
|
||||
band, tuned point or dtype) and records the reference there, described afresh: a fixture that
|
||||
reaches rows no container selects, to replay with `--all-rows`. A row whose geometry would change
|
||||
a weight's shape needs a container, and is listed.
|
||||
moves the fixtures' cases into the constraints of every row of the libraries under test and
|
||||
records the reference at every distinct geometry that lands there -- one case serves every row
|
||||
sharing it, so a band's whole M ladder is covered -- described afresh: a fixture that reaches
|
||||
rows no container selects, to replay with `--all-rows`. The gemm_nt_q mx/m2 pair re-encodes
|
||||
between the two families (codes and exponents are the same planes; the meta plane is drawn
|
||||
beside them), so an m2xfp4 recording can drive the OCP rows and vice versa. A row whose
|
||||
geometry would change a weight's shape needs a container, and is listed.
|
||||
|
||||
### Verdicts
|
||||
|
||||
|
||||
Reference in new issue
Block a user