dtype-bits -- the numeric zoo, bit by bit

Every number inside a model is stored in a fixed number of bits, and using fewer of them makes the model smaller and faster, which is how one squeezes onto a phone. The catch is what the bits buy. Cutting them coarsens the values, and the popular "four-bit" formats are not four bits per number at all: they are four bits each plus one shared multiplier for a whole block of them, which averages out at 4.25 a number when a block holds thirty-two and 4.5 when it holds sixteen — smaller blocks follow the values more closely and cost more to store. There is a second catch that is easy to miss: a format is only fast where the chip can multiply it directly, and where it cannot the numbers are expanded back into a format with more bits first, saving memory and buying no arithmetic speed at all.

Interactive page, three views: how a number is stored (23 formats -- 10 scalar floats, 6 block-scaled, 7 integers), what a block-scaled format actually costs (the family every "4-bit" model ships in), and which silicon can multiply each one. Click any bit to flip it and watch the reconstructed value rebuild bit by bit; hover a bit for its field + place value, or a field label to decode it. Anchor: A11 special pre-quant transforms / precision (Family A3 foundational).

The dtype table

Every column of the hardware matrix and every row of the comparison table is one of these keys. Bit counts are what the format costs, which for a block format is amortised over its block.

Familykeybitslayout
floatfp6464E11M52, bias 1023, IEEE binary64
floatfp3232E8M23, bias 127, IEEE binary32
floattf3219 in a 32-bit containerE8M10, bias 127 -- fp32 range, fp16 precision
floatfp1616E5M10, bias 15, IEEE binary16
floatbf1616E8M7, bias 127 -- fp32's exponent, truncated mantissa
floatfp8e4m38E4M3, bias 7 -- no Inf; only mantissa-all-ones at max exponent is NaN, so max finite is 448
floatfp8e5m28E5M2, bias 15 -- IEEE-shaped, has Inf/NaN, max finite 57344
floatfp6e3m26E3M2, bias 3 -- no Inf, no NaN, max finite 28
floatfp6e2m36E2M3, bias 1 -- no Inf, no NaN, max finite 7.5
floatfp4e2m14E2M1, bias 1 -- no Inf, no NaN, 16 codes total, max finite 6
blockmxfp88.2532 × fp8 e4m3 + one E8M0 scale (OCP MX v1.0)
blockmxfp66.2532 × fp6 e3m2 + one E8M0 scale
blockmxfp44.2532 × fp4 e2m1 + one E8M0 scale
blocknvfp44.516 × fp4 e2m1 + one fp8 e4m3 scale (not a power of two)
blockbfp88.516 × (sign + 7-bit magnitude) + one shared 8-bit exponent
blockbfp44.516 × (sign + 3-bit magnitude) + one shared 8-bit exponent
intint32 int16 int8 int4 int232/16/8/4/2two's complement, × a per-tensor scale
intuint88unsigned, × scale with a zero-point (128 here)
intint11unsigned codes 0 and 1, × scale. 0 stays 0; 1 is the absmax

All integer rows share one absmax of 8. The bits hold a code, ×scale is a separate number fitted so those codes reach that absmax (8 / 127 for int8, 8 / 7 for int4, 8 for int1, so its codes are 0 and 8). The scale is not stored in the bit strip. The comparison is about code count: fewer bits means a coarser scale, not a friendlier one.

What each view shows

Bit layout

The focused dtype's bits as sign | exponent | mantissa cells (integers: sign | magnitude), coloured by field. Scrub the transport to reveal bits left→right and rebuild the value: the sign sets ±, the exponent field sets the scale 2^(e−bias) (with the implicit leading 1), and each mantissa bit adds scale·2⁻ⁱ. A comparison table encodes the same chosen value in every visible dtype and shows total bits, decoded value, and rounding error as a log-scaled bar -- with fp64 and int1 in one table a linear bar renders every useful row as a single pixel.

Two formats are drawn specially, because their bit strip alone would mislead:

fp64's 64 cells do fit on one strip -- the cell width shrinks with the format's width (54 px down to a 6 px floor) and the digit is dropped below 7 px rather than the row being wrapped, which would break the single-row hit-test the click-to-flip interaction depends on.

Block-scaled

The view the low-bit era needs. An MXFP4 value is not 4 bits: it is 4 bits of element plus a shared 8-bit exponent across a block of 32, i.e. 4.25 bits per element amortised. The view draws the block itself:

The value slider is element 0 of the block, so the number you are holding actually rides through the block and pays its rounding. Hover any element for the full reconstruction and its error; hover the scale for the block accounting.

Hardware support

A vendor × dtype matrix: for every architecture, whether each dtype is a native matrix-engine operand, vector/SIMD-only, emulated (upconverted to a wider type first), none, or unknown -- the last being a real answer, not a gap, because a closed accelerator often publishes no operand list. A dtype key the catalogue does not carry at all also renders unknown; the column set is owned by the page and the capability facts by the JSON, and neither being ahead of the other may blank a cell or throw.

23 columns do not fit legibly at once, so there are two filters: column family (all / scalar floats / block-scaled / integers) and engine class (GPU matrix engines / GPU vector ALUs / NPUs / CPU SIMD). Below ~44 px of column width the header keys turn on their side rather than ellipsize into uselessness. Drag to scroll, hover a cell for the level, the one-line why, and the public artifact it was read from; click a column header to focus that dtype and see its tally across the visible rows.

The point it makes that a bit-layout diagram cannot: a dtype is only cheap where the silicon has an engine for it. int8 is nearly universal, bf16 splits the field, fp8 is a recent GPU/CPU-tile arrival, and the block-scaled formats -- the ones half the open-weights world now ships in -- are native on strikingly few engines, which is why they are usually unpacked before they are multiplied.

Three things the GPU rows show that a "newer is wider" reading would get backwards:

Data: ../data/dtype-support.json (schema the public-source rule in ../data/README.md), fetched at runtime. Support facts only -- this page carries no performance number, by design. If the fetch fails (opened over file://), the view says so instead of inventing rows.

Numerical honesty

The decode is not decorative, so it is cross-checked against implementations that share no code with it: Python struct for fp64/fp32/fp16, ml_dtypes for bf16/fp8 e4m3/fp8 e5m2, a synthesised fp32→10-bit-mantissa reference for tf32, and an exhaustive nearest-code search over every code for fp6/fp4. Two things that fell out of doing it:

Render tier

T1 (Canvas2D). Bit cells, block grid and bars; no GPU needed.

Wiring

layout.mount + controls (view, dtype, cols, engines, value) + a step Transport over a page-built sequence -- bit reveal, block reveal (scale then each element), or matrix row reveal, depending on the view. IEEE-style decode lives in page.js, not tensor.js. Headless hooks: ?step=N/?play=1, ?flip=i (toggle bit index i; comma-separated, e.g. ?flip=0,5,9), ?hover=x,y (canvas-space), ?view=bits|block|hardware, ?dtype=<key>, ?cols=all|float|block|int, ?engines=<class>, ?hwscroll=N (the headless stand-in for dragging the list). window.__dtypeNum exposes the numeric core so the cross-check above can be run against the real functions. Source: page.js.