INT4

Uniform integer codes with one scale per block. The simplest weight format: every block of 32 weights shares an fp16 scale, and each weight stores a signed 4-bit integer.

What the figure shows

The top strip is a row of 128 weights, split into blocks of 32. Below it, the current block sits on a number line with its 16 representable values as vertical lines. Each weight slides to the nearest line, and the red segment is its rounding error.

Watch a block that holds an outlier: the scale grows to fit it, the grid spreads out, and every other weight in that block loses precision. Smaller blocks contain the damage at the cost of more scale bits per weight.

The format

elementsigned 4-bit integer, −8 … 7
scaleone fp16 per block, amax / 7
cost4 + 16/32 = 4.5 bits per weight
decodew = code × scale

llama.cpp's Q4_0 is this layout with a slightly different scale choice (it maps the signed extreme onto −8 to use the extra negative code). GPTQ and AWQ also store uniform INT4 codes and change how the codes are chosen, not how they decode.

Things to try