Numerics Explained

Numerics Explained

How few bits can a number have?

An interactive guide to number formats and quantisation for AI, from FP16 down to FP4, computed by a library that reproduces numpy bit for bit.

FP4 E2M1: 8 values, 0 to 6FP6 E2M3: 32 values, 0 to 7.5FP8 E4M3: 127 values, 0 to 448
Every value of three small formats, to scale: the gaps double at each power of two.

How this is checkedEvery code of every format up to 16 bits is checked against numpy and ml_dtypes, and the TypeScript port in your browser reproduces the Python reference exactly. How it is tested →

What you'll learn

Models are trained in 16-bit formats and served in 8, 6 or 4. An FP8 E4M3 number has 4 significant bits and nothing above 448; FP4 has 2 and stops at 6. This site is about what that costs and the tricks that make it work: rounding, accumulating in wider formats, scales shared by blocks of numbers, and quantisers that choose their integers with care.

Each chapter is built around an animation, and every frame is computed by a small numerics library that reproduces numpy and ml_dtypes bit for bit and follows the IEEE 754 and OCP FP8 and MX specifications.

Every format, its constants and the specification that defines it: the formats.

New to the Inference track? Start here: the four sites in reading order, what you need first, and a glossary of the terms they define.

Part of a family of sixteen companion sites in four tracks, all in the site menu above: Foundations (Decoder, Training), Hardware (Kernels, Systolic, Accelerators, Racks), Inference (Serving, Architectures, Numerics, Trade-offs) and Agents (Harnesses, Protocols, Context, Orchestration, Evals, Security). This site is about the numbers themselves. How it was built, and how to check it: about.