On this page
Feed the number 500 through a scaled FP8 conversion and it can come back as 10, with zero exceptions, zero infinities, and zero NaN flags. An older batch's scale factor (10 / 448) left 500 far above the E4M3 ceiling of 448, so saturating conversion quietly clamped it to 448 and reconstructed 448 × (10 / 448) = 10 (a 98% error). Even an FP32 accumulator downstream happily multiplies and sums that corrupted 10 without ever knowing 490 vanished.

Low-precision GPU programming is therefore about four explicit choices, never just flipping a dtype: encoding (bitfields and special values), scaling architecture (what shares a scale and when it is measured), arithmetic and accumulation (input vs. product vs. accumulator precision), and kernel ABI (layouts, alignment, and vendor conventions).
A tensor-core kernel accepts FP8 inputs and accumulates into FP32 registers. Does FP32 accumulation guarantee a correct answer?
Answer
No. Wider accumulation reduces rounding error during the dot product, but it cannot recover information already flushed to zero or clipped during FP8 input conversion.
Format taxonomy: range, spacing, and bitfields
Exponent bits control dynamic range; fraction (mantissa) bits control spacing inside each binary octave (binade):
| Format | Bits (S / E / M) | Bias | Max finite | Smallest normal | Typical GPU role |
|---|---|---|---|---|---|
| FP32 | 1 / 8 / 23 | 127 | Reference math, accumulation | ||
| TF32 | FP32 storage (8E / 10M read) | 127 | Fast FP32 Tensor Core matmuls (no storage savings) | ||
| BF16 | 1 / 8 / 7 | 127 | Wide-range activations, weights, gradients | ||
| FP16 | 1 / 5 / 10 | 15 | 65,504 | Higher precision, narrow range | |
| FP8 E4M3 | 1 / 4 / 3 | 7 | 448 | Forward activations and weights | |
| FP8 E5M2 | 1 / 5 / 2 | 15 | 57,344 | Backward gradients and wide-range tensors |
The OCP OFP8 specification[1] pairs E4M3 forward (spacing 0.125 in , no infinities, 0x7F/0xFF reserved for NaN) with E5M2 backward (wider range up to 57,344, spacing 0.25 in ).[2][3] Below 8 bits, block-scaled formats attach a tiny shared scale to small element groups:
- OCP Microscaling (MX): 32-element blocks sharing one 8-bit E8M0 power-of-two scale ( for ,
255= NaN): MXFP8 (8.25 bits/elem), MXFP6, and MXFP4 (E2M1, max6).[4] - NVIDIA NVFP4: E2M1 elements with an E4M3 scale per 16-element block plus an FP32 tensor scale (
40 bytesfor 64 values vs.34 bytesfor MXFP4).[5]

Scale ownership and the GEMM dataflow
In (, ), where can scales be applied? If each row of shares scale and each column of shares scale , neither depends on the contraction index , so both factor straight out into the GEMM epilogue:
By contrast, when scales vary along (as in 32-element MX blocks), the scale product cannot leave the outer sum:
For two blocks with partial sums [2, 3] and scale products [5, 8], the true block-scaled dot product is , whereas mistakenly pulling scale 5 outside gives .[4][6]

Numerical hazards: subnormals, saturation, and rounding
Three encoding behaviors silently alter numbers before the accumulator ever runs:
- Subnormals and RNE ties: OCP E4M3's smallest normal is and its smallest subnormal is . Under round-to-nearest-even (RNE),
0.75 drounds up tod, while exact tie0.5 drounds to signed zero (±0.0). Some GPU modes also flush denormals to zero (FTZ).[7] - Saturation cliffs: Saturating conversion (
__NV_SATFINITE) clamps500and50,000identically to448; non-saturating conversion turns overflow into E4M3NaNor E5M2±inf.[8] - Stochastic rounding (SR) vs. RNE: Repeated small weight updates can stall under RNE when . Stochastic rounding rounds to neighboring representable values with probabilities (up) and (down), making unbiased for any finite inside range (for between
1.0and1.125,p(1.125) = 0.08, expected value1.01).[5] Also verify internal MMA precision: even an FP32 accumulator register can use narrower internal product or accumulation precision inside Tensor Core MMA instructions.[9]


Hands-on: inspecting FP8 conversion thresholds and ABI bytes
Run this PyTorch check on CPU to see E4M3 subnormal rounding, saturation, and a notorious cross-vendor trap: the exact same raw byte 0x38 decodes to 1.0 in OCP E4M3 (bias 7) and 0.5 in AMD CDNA3 FNUZ E4M3 (bias 8), while 0x80 decodes to -0.0 in OCP and NaN in FNUZ![10][11]
import torch
d = 2.0 ** -9
vals = torch.tensor([0.5 * d, 0.75 * d, -0.5 * d, 1.0625, 1.1875, 500.0])
cast = vals.clamp(-448.0, 448.0).to(torch.float8_e4m3fn).float()
print("E4M3 round-trip:", cast.tolist())
print("negative tie preserves -0.0:", bool(torch.signbit(cast[2])))
raw_bytes = torch.tensor([0x38, 0x80], dtype=torch.uint8)
print("OCP E4M3 (0x38, 0x80):", raw_bytes.view(torch.float8_e4m3fn).float().tolist())
print("FNUZ E4M3 (0x38, 0x80):", raw_bytes.view(torch.float8_e4m3fnuz).float().tolist())E4M3 round-trip: [0.0, 0.001953125, -0.0, 1.0, 1.25, 448.0]
negative tie preserves -0.0: True
OCP E4M3 (0x38, 0x80): [1.0, -0.0]
FNUZ E4M3 (0x38, 0x80): [0.5, nan]
Scaling architectures: granularity and delayed scaling
Watch the reciprocal convention in every library: here is the reconstruction scale (), while many APIs store (). For an all-zero block, set an explicit positive scale like 1.0 instead of dividing by zero.
- Current scaling: Reads the tensor twice during quantization (once for
amax, once to cast) so scales never lag.[12] - Delayed scaling: Picks from prior steps, cutting quantization to one read while recording the new
amaxfor next step, at the risk of saturation cliffs whenever an activation suddenly spikes.[13] - Online block scaling: DeepSeek-V3 measures
amaxonline for1×128activation tiles and128×128weight blocks, promoting partial FP8 GEMM sums to CUDA-core FP32 accumulation every 128 elements to overcome H800 internal precision limits.[14][15]
![Two schematic device timelines comparing current and delayed FP8 scaling. Current scaling performs two tensor passes: Read X, compute amax_t and S_t, Read X again, cast and write Q, then GEMM. Delayed scaling reads X in one pass, splitting into an upper branch (compute amax_t, record a_t into future history H_{t+1}) and a lower branch (cast with historical S_t = max(H_t)/448 from the 3-step history ring [a_{t-3}, a_{t-2}, a_{t-1}], write Q, then GEMM) with zero crossing paths.](https://assets.leetllm.com/v1/b40d87b7113f/fundamentals/low-precision-gpu-programming/illustrations/_generated/scaling_device_timeline_dark.png)
Microscaling: the two-row experiment
What happens when a small activation (0.001) shares one tensor-wide scale with a spike (500.0) versus getting its own 32-element MX block scale? Let's run it in PyTorch, and then expose a subtle cancellation trap:
import math
import torch
x = torch.tensor([
[0.001, 0.03, 0.117, 0.5, 1.0, -0.25, 0.0625, -0.015625] * 4,
[4.0, 16.0, 64.0, 500.0, -2.0, -8.0, -32.0, -250.0] * 4,
], dtype=torch.float32)
w = torch.tensor([0.5, -0.25, 0.125, -0.0625, 0.03125, -0.5, 0.25, -0.125] * 4).reshape(32, 1)
fp8_max = torch.finfo(torch.float8_e4m3fn).max
def quant_rt(t, s):
return (t / s).clamp(-fp8_max, fp8_max).to(torch.float8_e4m3fn).float() * s
def mx_scale(block):
r = block.abs().max().item() / fp8_max
return 1.0 if r == 0 else 2.0 ** max(-127, math.ceil(math.log2(r)))
# Tensor-wide vs 32-element power-of-two block scaling
x_ten = quant_rt(x, x.abs().max() / fp8_max)
w_ten = quant_rt(w, w.abs().max() / fp8_max)
s_mx = torch.tensor([mx_scale(row) for row in x]).reshape(2, 1)
x_mx = quant_rt(x, s_mx)
w_mx = quant_rt(w, torch.tensor(mx_scale(w)))
ref_y, ten_y, mx_y = (x @ w).squeeze(), (x_ten @ w_ten).squeeze(), (x_mx @ w_mx).squeeze()
print(f"x[0,0]=0.001 -> tensor={x_ten[0,0]:.6f} (WIPED!), MX={x_mx[0,0]:.6f}")
print(f"x[1,3]=500.0 -> tensor={x_ten[1,3]:.1f}, MX={x_mx[1,3]:.1f}")
print(f"dot y: ref={ref_y.tolist()}, tensor={[round(v, 4) for v in ten_y.tolist()]}, MX={mx_y.tolist()}")
# Cancellation hides the 500 -> 512 error in mx_y[1]=7.75; a one-hot selector exposes +12.0 error!
sel = torch.zeros_like(w); sel[3, 0] = 1.0
print(f"spike-only dot: ref={(x @ sel)[1].item():.1f}, MX={(x_mx @ sel)[1].item():.1f}")x[0,0]=0.001 -> tensor=0.000000 (WIPED!), MX=0.000977
x[1,3]=500.0 -> tensor=500.0, MX=512.0
dot y: ref=[0.6008124947547913, 7.75], tensor=[0.5831, 7.5684], MX=[0.6015625, 7.75]
spike-only dot: ref=500.0, MX=512.0Look at two sharp lessons from those four lines of output:
- Under tensor-wide scaling (),
0.001falls below half of the smallest scaled E4M3 step (0.5 × 0.00218 = 0.00109) and vanishes to zero! Under MX block scaling (),0.001survives cleanly at0.000977(2.3% error), with just 1 E8M0 byte per 32 elements (66 Bvs.68 Bfor a 64-element activation).[16] - On row 1,
500.0rounds to512.0under , yetmx_y[1]still matches7.75identically because positive and negative rounding errors cancel (184 - 176.25 = 7.75). Swap to a one-hot selector and the hidden12.0error jumps right out!




Hardware support and troubleshooting numerical failures
Always check target microarchitecture and toolkit tables before shipping: NVIDIA Hopper/Ada support FP8, Blackwell (SM 10.x) adds hardware MXFP8/NVFP4 block-scaled MMA, AMD CDNA3 uses FNUZ FP8 while CDNA4/RDNA4 adopt OCP FP8, and PyTorch exposes modern torch.backends.cuda.matmul.fp32_precision = "tf32" | "ieee" controls.[7][16][5][11]
| Symptom | Likely root cause | Fix |
|---|---|---|
Many FP8 codes equal ±448 | Saturation clipping from stale or tight scale | Inspect pre-cast scaled magnitudes; widen margin or switch to current/block scaling. |
Entire row flushes to 0.0 | Shared scale dominated by an outlier in another row | Move from tensor-wide to row-wise or 32-element MX block scaling. |
| Output collapses when porting NVIDIA → AMD | OCP (bias 7) vs. FNUZ (bias 8) byte mismatch | Check hex byte 0x38; explicitly transcode between OCP and FNUZ. |
| Backward pass turns to noise after transpose | Scale orientation mismatch | Quantize row-major and column-major views from the wider source tensor. |