Unit 7 of 10 · about 4 hours · derive

Input, product and accumulation precision across FP16, BF16, TF32 and FP8

A low-precision GEMM is a sequence of conversions and arithmetic operations. Its storage dtype alone does not determine either the speed or the error.

You'll be able to

  • Derive format range and spacing for FP16, BF16, TF32, E4M3 and E5M2.
  • Separate input conversion, product precision, accumulation and output conversion errors.
  • Construct boundary and cancellation tests without assuming FP8 tensor-core support.

Covers

Input, product, accumulation and output precisionFP16, BF16 and TF32 range, precision and executionE4M3 and E5M2 encoding, range and exceptional values
1

Read

In this order, only the parts listed

0 of 3 done

  1. Mixed-precision arithmetic pathsAI Systems Performance Engineering - Chapters 9 and 10

    Chapter 9: Mixed Precision and Utilizing Tensor Cores; TF32 and Automatic Mixed Precision (PyTorch); BF16/FP16, FP8, and FP4 Reduced Precision

    Skip FP4, TMEM and TMA. Treat framework defaults as version-dependent and identify conversion, accumulation and output types explicitly.

  2. Alternate input formats and accumulationCUDA 13.0 matrix programming and PTX references

    CUDA 13.0.0 Programming Guide 10.24.2 Alternate Floating Point; 10.24.1 template type combinations

    Read BF16 and TF32. Do not mistake TF32 execution precision for a new ordinary memory-storage dtype.

  3. FP8 encodings and conversionsOCP 8-bit Floating Point Specification

    OFP8 revision 1.1: section 5.1, Tables 1 and 2, printed page 13; section 5.2 and 5.2.1, printed page 14

    Distinguish the OCP formats from variants with different zero/NaN encodings. Test saturating and non-saturating conversion separately.

2

Focus on

  • Near one, FP16 and TF32 have spacing , BF16 , E4M3 , and E5M2 . Range and significand precision are different axes.
  • OCP E4M3 has maximum finite 448, minimum normal , minimum subnormal , NaN and no infinity. E5M2 has maximum finite 57344, minimum normal , minimum subnormal , NaN and infinity.
  • Compare an original-input double reference with a double product of converted inputs, then compare that converted-input reference with the actual kernel. The differences isolate input quantization from later arithmetic and output rounding.
  • FP32 accumulation cannot prevent overflow during an earlier FP16 input conversion or undo input rounding. Exact product and accumulation behavior is instruction-specific, not implied solely by the output dtype.
Common mistakes · 3
  • Assuming E4M3's all-ones exponent always denotes infinity, as it would in many IEEE formats.
  • Calling BF16 more accurate than FP16 because it has a wider exponent range.
  • Assuming a software FP8 cast means the GPU supports native FP8 matrix multiplication.
3

Try it yourself

Closed-book, before checking anything

Decode all 256 OCP FP8 bit patterns from sign, exponent and fraction fields, and verify both format boundary tables. With nearest-even conversion, show that 1.0625 is an E4M3 midpoint rounding to 1, whereas 1.1875 rounds to 1.25. For a dot product, convert the inputs [1.0001, -1] and [1, 1] to FP16 before evaluating in double: the original product is approximately 0.0001, but the converted-input product is zero. Record that as input-conversion error, not accumulation error.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Which has finer spacing near one, FP16 or BF16?Answer

    FP16. Its ten explicit fraction bits give finer spacing than BF16's seven; BF16 has a wider normal exponent range.

  2. 2.Can E4M3 represent positive infinity?Answer

    Not in the OCP E4M3 format. Out-of-range conversion must follow the selected saturation policy; non-saturating overflow produces NaN.

  3. 3.Why use both original-input and converted-input references?Answer

    The first measures total approximation error; the second isolates arithmetic and output error after input conversion.

You're done when

The enumerated FP8 extrema and midpoint tests match revision 1.1, and your cancellation example distinguishes input loss from accumulation precision.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 9 more in the section
  • AI Systems Performance Engineering - Chapters 9 and 10Chris Fregly · primary

    Read Chapter 9 on arithmetic intensity, tiling and fusion, and Chapter 10 on intra-kernel pipelining, warp specialization and thread-block clusters. Separate what applies to every NVIDIA GPU from what needs Hopper or Blackwell.

  • OCP 8-bit Floating Point SpecificationOpen Compute Project · required

    Study E4M3 and E5M2 encodings, exceptional values and conversion behavior. Build value-boundary tests and separate format correctness from the scaling policy chosen by a framework or kernel.

  • CUDA 13.0 matrix programming and PTX referencesNVIDIA · reference

    Coverage and correctness gap: the pool lacks a precise WMMA contract, and Lab 6 relies on TF32 conversion and register behavior the PTX ISA leaves unspecified. Use Programming Guide 10.24 and PTX ISA 9.0 mma.m16n8k8 fragments, mma and cvt, archived with CUDA 13.0.0; also consult cp.async completion semantics.

Also in this section

  • AI Systems Performance Engineering companion code - Chapters 9 and 10Chris Fregly · required

    Inspect and run compatible baseline and optimized paths from code/ch09 and code/ch10. Verify whether each path is a custom kernel, compiler selection or library dispatch, then add an independent correctness and timing wrapper.

  • MIT 6.S894 Accelerated Computing (Fall 2025) - Lectures 6 and 8 and Labs 4 to 6MIT · required

    Use Lecture 6 for tensor cores and arithmetic intensity and Lecture 8 (Evolving Ampere to Hopper) for the production GEMM schedule. Do Lab 4 (tiling and reuse), Lab 5 (scheduling and problem sizes) and Lab 6 (tensor cores through inline PTX) built for your own GPU; each harness checks results against bundled test data. Lab 6 needs sm_80 or newer.

  • How to Optimize a CUDA Matmul Kernel for cuBLAS-like Performance: a WorklogSimon Boehm · support

    Read kernels 1 to 6, 9 and 10 with the companion repository. Its numbers come from an RTX A6000 (Ampere); remeasure on your GPU before comparing your kernels with them.

  • CuTe GEMM TutorialNVIDIA CUTLASS · required

    Work through tiling, layouts, copy atoms and MMA atoms. Draw the logical and physical ownership for one tile, then modify a shape or layout and verify both generated mapping and numerical output.

  • LeetGPU - GEMM and Quantized Matmul ChallengesAlphaGPU · required

    Solve 2 Matrix Multiplication and 22 GEMM, then choose 30 Batched Matrix Multiplication or 57 FP16 Batched Matmul. Attempt 32 INT8 Quantized Matmul or 81 INT4 Matmul only after scale and accumulator tests pass. Preserve local baselines and shape matrices.

  • GPU MODE - CUTLASS, Tensor Cores and CuTeGPU MODE · support

    Use Lectures 15, 23, 36, 57, 86, 103 and 114 selectively. Pair each chosen lecture with one implemented layout, instruction or pipeline change and compare it against a vendor-library baseline.

  • DeepGEMMDeepSeek · depth

    After the portable GEMM passes, reconstruct one Hopper FP8 path from source, identify its hardware, layout and scaling assumptions, and test a bounded modification only on supported hardware. Do not generalize repository benchmarks to other shapes or GPUs.

  • Modern GPU Programming for MLSysMLC · depth

    Read the performance, data-layout, tensor-core, TMA, tensor-memory, barrier and GEMM chapters for a Blackwell-depth route. Execute only with sm_100a and the pinned TIRx toolchain; otherwise use it for derivation and code reading.

  • TensorRT quantization schemes and workflowsNVIDIA · reference

    Coverage gap: the existing pool does not derive scale granularity and reconstruction conventions precisely. Read INT8/FP8 equations, per-tensor/per-channel/block quantization and dynamic quantization in documentation dated October 5, 2026. Skip engine building and replace the block pseudocode's floor-divided scale count with ceiling division.