↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

What FP8 is

The GPTQ, AWQ and GGUF tabs shrink only the weights. W8A8 also casts the activations to 8 bits, so the matrix product itself can run on 8-bit hardware. SmoothQuant does that with 8-bit integers; recent GPUs (NVIDIA's Hopper and later) add tensor cores for 8-bit floating-point numbers instead, at twice the throughput of bf16 and half its bytes.

An FP8 number is a sign bit, an exponent and a mantissa. Two layouts are standard: E4M3 (4 exponent bits, 3 mantissa bits, bias 7) for weights and activations, and E5M2 (5 and 2, bias 15), the wider and coarser one, used mostly for gradients. A code with exponent field and mantissa is worth

The Eight bits as a float panel draws all 256 codes of either format, row by the first four bits and column by the last four; hover a code for its bits and value. E5M2 keeps IEEE's infinities and NaNs. E4M3 is the "fn" variant (finite, NaN only): it spends the all-ones exponent on numbers, keeps only S.1111.111 as NaN, and so reaches 448 instead of 240. E4M3 spans 17.8 binades with 8 values in each; E5M2 spans 31.8 binades with 4.

One scale, then the cast

A tensor is first divided by a scale so that its largest value lands on E4M3's largest, then cast to the nearest code (ties to even, saturating at ), and multiplied by again after the product:

The Where the values land panel plots for the 4,358,144 weights of layer 12's down_proj and for the inputs it receives over a 512-token WikiText-2 pass, under one tick per representable value. Because the codes are spaced by powers of two, every value keeps about the same relative precision, three mantissa bits, until it falls below , where subnormals thin out, and below , where it rounds to zero. With one scale per tensor only 3,102 weights (0.07 %) are subnormal and 213 round to zero; of the 19.9 million held-out inputs, 0.59 % are subnormal and 0.06 % round to zero. int8's 127 levels at the same top are evenly spaced, so anything below about of the largest value is left with 0 or one step.

That is FP8's advantage over int8 at one scale per tensor. On this matrix the inputs move by 2.65 % () in E4M3 but 12.4 % in int8, and the layer's output by 3.6 % against 12.1 %. E5M2 never underflows here, but its two mantissa bits double every error (5.3 % on the inputs).

Finer scales

The toolbar switches the Scale, cast, scale back panel between one scale per tensor, one per row (per output channel for the weights, per token for the activations, as vLLM's dynamic FP8 does) and the blocks DeepSeek-V3 trained with: one scale per block of weights and per tile of each token's inputs. Finer scales follow the data more closely, so a little less of it sits low on the grid: down_proj's output error drops from 3.61 % per tensor to 3.54 % per channel and token and 3.35 % with blocks.

The scales also decide when they are computed. Weights are quantized once. Activations are quantized at every call: dynamic scales come from each forward pass's own maximum (the page's per-tensor input scales range over 0.0106 – 0.0176 across the eight held-out windows), static ones are fixed once from calibration text, here 32 WikiText-2 training sequences, and save the reduction at serving time. Counted from tensor sizes, a 32-bit scale costs 0.000007 bits per weight per tensor, 0.0066 per channel and 0.002 per block.

The FP8 product

An FP8 GEMM multiplies the 8-bit codes, sums the products and rescales once:

A product of two E4M3 values has at most 8 significant bits, so it is exact; only the sum rounds. The One output panel follows down_proj's row 490 at the last prompt token: the exact sum of the 4,864 FP8 products is 268,778.1309, the float32 sum 268,778.125, and times the two scales the output is 1.63993 against 1.65338 from the float32 inputs.

There is no FP8 hardware on this Mac, but PyTorch's FP8 GEMM, torch._scaled_mm, runs on its CPU and gives exactly the numbers of the matmul on dequantized values (largest difference 0 over the whole matrix, per tensor and per row). A GPU's tensor cores add the same products in a different order and, on Hopper, with limited accumulator precision, which is why DeepSeek-V3 copies partial sums to float32 every 128 inputs; such differences live in the last bits of each sum, like the between float32 and float64 sums here for outputs up to 4.20. The page therefore reports accuracy, not speed: all of it runs in float32.

Every layer and the whole model

The Every linear layer strip measures the output error of all 168 linear layers on one held-out pass. E4M3 per tensor stays at or below 5.1 % on every layer. int8 per tensor does better on 27 of the 168 layers, but its error is more than twice E4M3's on 67 and collapses where a few input channels dwarf the rest: layer 3's up_proj gets inputs up to 116 times its median channel and loses 75 % with int8, 3.7 % with E4M3. With a scale per token, int8 beats per-tensor E4M3 on 121 of the 168 layers (median 2.4 % against 3.1 %), since its 255 levels are finer than E4M3's 8 per binade near the top of the range: FP8's gain is range, not precision.

What the model says runs Qwen2.5-0.5B-Instruct on the GPTQ tab's question and on the same 4,096 WikiText-2 tokens with all seven linear layers of every block in FP8, embeddings and the output head left in 16 bits as FP8 checkpoints keep them. Perplexity goes from 19.93 (bf16 weights, float32 compute) to 20.03 with bf16 compute, 20.24 with E4M3 per tensor, 20.26 with static input scales, 20.25 per channel and token, 20.31 with blocks, 20.88 with E5M2 and 20.08 with FP8 weights only; every version still answers Canberra. On the same tokens the SmoothQuant tab's int8 W8A8 with one scale per tensor gives 91.03 and with per-token scales after smoothing 20.21, and the 4-bit weight-only releases 23.20 (GPTQ), 23.46 (AWQ) and 21.00 (GGUF).

Where it came from

Micikevicius et al. (2022) proposed E4M3 and E5M2 as a common interchange format for NVIDIA, Arm and Intel hardware, showing that models trained or post-trained in FP8 match 16-bit quality across vision and language tasks. Shen et al. (2023) studied post-training FP8 quantization across many models, and van Baalen et al. (2023) compared it with int8 at equal bits, finding int8 just as accurate or better once outliers are handled, which the per-token comparison above echoes. DeepSeek-V3 (2024) trained a 671B-parameter model with FP8 matrix products, introducing the 128-wide fine-grained scales and float32 promotion this page's block option follows. The sibling tabs cover the integer route: SmoothQuant for W8A8, GPTQ, AWQ and GGUF for 4-bit weights, and the Pretraining explainer's Mixed precision tab trains in reduced precision.

Papers

  1. FP8 Formats for Deep Learning Paulius Micikevicius et al. · arXiv 2022 Defines E4M3 (finite, NaN only, up to 448) and E5M2, the two formats on this page.
  2. DeepSeek-V3 Technical Report DeepSeek-AI · arXiv 2024 FP8 training at scale with 1 × 128 activation tiles and 128 × 128 weight blocks, and float32 promotion of partial sums: the block option.
  3. FP8 versus INT8 for efficient deep learning inference Mart van Baalen et al. · arXiv 2023 Compares the two 8-bit routes: floating point buys range, integers precision, as the every-layer strip shows.
  4. Efficient Post-training Quantization with FP8 Formats Haihao Shen, Naveen Mellempudi, Xin He, Qun Gao, Chang Wang, Mengni Wang · arXiv 2023 Post-training FP8 quantization of weights and activations across many models, with static and dynamic scales.
  5. SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models Guangxuan Xiao, Ji Lin, Mickael Seznec, Hao Wu, Julien Demouth, Song Han · ICML 2023 The int8 W8A8 the page compares with, recorded on the same model in the SmoothQuant tab.
  6. Qwen2.5 Technical Report Qwen Team · arXiv 2024 The model whose layers are cast to FP8 here.

See also