FP4 / FP8 / BF16 / FP16 / TF32 / FP32 / FP64 / MPFR-style high-precision demos
This page lets you explore low precision used in AI, mixed-precision accumulation, scaling, and comparisons with high-precision reference values.
In this single-file version, the reference value is computed in JavaScript double precision. Use the MPFR Arbitrary-precision graph tab to generate tables using true MPFR evaluation.
The input vector \(\mathbf{x}=(x_1,\ldots,x_n)\) is converted into a probability distribution.
However, when \(x_i\) is large, \(\exp(x_i)\) overflows, so implementations subtract the maximum value \(m=\max_j x_j\).
This transformation is mathematically equivalent, but it is much more stable in numerical computation.
The dot product is a fundamental operation in matrix multiplication and neural networks.
AI accelerators often store inputs \(x_i,y_i\) in low precision such as FP8 or FP16, while keeping the accumulated sum \(s\) in a wider format such as FP32.
The aim is to reduce memory bandwidth and arithmetic cost with low-precision inputs while suppressing accumulated rounding error with a higher-precision accumulator.
This view shows positive values representable by small floating-point formats on a number line. It helps explain the trade-off between representable range and significant digits.
A small neural network with two inputs, one hidden layer, and one output is trained by full-batch gradient descent.
The update size \( \lVert\Delta\theta\rVert \) is also shown at each epoch. With lower precision, rounding of weights, activations, and gradients can make the corrections coarser.
This page introduces part of the research conducted by the High Performance Computing Laboratory.
The keywords are AI, high-performance computing, and high-precision computing In AI, massive low-precision computation at roughly 4 to 16 bits is central, while scientific computing mainly relies on high-precision computation of 64 bits or more. To bridge this gap, the High Performance Computing Laboratory explores techniques for accelerating high-precision scientific computing on AI-oriented computing systems.
A floating-point number represents a real number by separating it into a sign, an exponent, and a mantissa. Conceptually, a normal number has the following form.
In low-precision formats, the allocation of bits between exponent and mantissa is important. For example, FP8 E4M3 has more mantissa bits and favors precision, while FP8 E5M2 has more exponent bits and favors range.
The figure below shows the floating-point formats used on this page, using MPFR 128-bit as the maximum width and arranges them with lengths proportional to their actual bit widths. Without horizontal scrolling, you can compare the length difference between FP4/FP8 and FP64/MPFR 128-bit.
The bar length represents the total bit length. Inside each bar, red indicates the sign field, blue the exponent, and green the mantissa. A longer exponent gives a wider representable range, while a longer mantissa distinguishes nearby values more finely. MPFR is shown as an arbitrary-precision format with a specified mantissa precision, not as a fixed-length IEEE format.
| Material viewpoint | Tabs to try | What you can observe |
|---|---|---|
| 4- to 16-bit low-precision AI computation | Function Quantization, Stable Softmax | rounding error, saturation, and the effect of scaling |
| Mixed precisioncomputation | Dot Product and Accumulation | Effect of low-precision inputs plus a higher-precision accumulator |
| high precisioncomputation | MPFR Arbitrary-precision graph | function tables and graphs with MPFR-specified bit precision |
| Understanding formats | format Visualization, material explanation | Exponent/mantissa allocation and the density of representable values |