quantwiki

Weight quantization formats and trellis codebooks, each with a live figure. The figure on every page is drawn by a short JavaScript model in the editor beside it: change the model and the figure follows.

Formats

INT4Uniform integers with an fp16 scale per block of 32. FP8E4M3 and E5M2 with one scale per tensor. MXFP4E2M1 in blocks of 32 under a power-of-two scale. NVFP4E2M1 in blocks of 16 under an E4M3 scale.

Trellis quantization

Tail-biting trellisA tile as a ring of bits, a sliding window per weight, and the Viterbi search that picks the bits.

Trellis codebooks

1MADQTIP: multiply-add, then a byte sum. 3INSTQTIP: multiply-add, mask, two fp16 halves. mcgexllamav3: 3INST without the addend. mul1exllamav3: multiply, dp4a byte sum, fp16 FMA. pmcgxEXLR8: one 20-bit state, two crossed products, two weights.

How the pages work

Each figure is an SVG drawn by a fixed view. The view asks a model for the numbers: how to quantize a block, or how to decode a trellis state. The model is plain JavaScript in the editor; it recompiles a moment after you stop typing, and errors show under the editor while the last good model keeps running. Your edits are saved in this browser, Reset code restores the original, and Copy link puts your version in the URL.

Helpers such as fp16, f16round, E4M3, E2M1, mul32, byteSum, gauss and normInv are in scope in every model. They are defined in lib/num.js.