Unit 8 of 10 · about 4 hours · derive, measure
Scale granularity and quantization error against task tolerances
Low-precision range becomes useful only with a scaling policy. Its granularity changes both error and where scale factors can be applied in GEMM.
You'll be able to
- Derive quantization and reconstruction with an explicit positive scale convention.
- Compare per-tensor, per-channel and reduction-block scales including metadata and tail costs.
- Measure clipping and output error against a predefined numerical tolerance rather than accepting speed alone.
Covers
Read
In this order, only the parts listed
0 of 2 done
- Scale convention and representable rangeTensorRT quantization schemes and workflows
Quantization Schemes: INT8, FP8 and Table 14, documentation dated October 5, 2026
Read symmetric INT8 and E4M3 formulas. Separate these framework-supported schemes from a general affine zero-point exercise.
- Granularity and dynamic scale selectionTensorRT quantization schemes and workflows
Quantization Granularities: numbered per-tensor and per-channel definitions and Block Quantization example; Dynamic Quantization, documentation dated October 5, 2026
Skip calibration implementation and FP4. In block pseudocode use ceiling division for the number of scales;
ceil(R//B)loses a partial block.
Focus on
- Define a reconstruction scale : symmetric INT8 uses and . FP8 rounds to its nonuniform representable set, not to integers.
- With one scale per row of the first operand and per column of the second, . Scales varying along the reduction require scaled partial sums inside the reduction, not one final factor.
- Specify zero-block handling, scale dtype, nearest-even ties, clipping and nonfinite-input policy. Dynamic scales cost a reduction and metadata traffic; calibration scales can fail on unseen outliers.
- Measure maximum absolute error, relative error only away from zero, normalized Frobenius error and clipping count against an original-input double reference. A converted-input reference tests implementation but does not establish task accuracy.
Common mistakes · 3
- Multiplying by a forward quantization multiplier when the API expects the inverse reconstruction scale.
- Pulling reduction-block scales outside the full dot product when those scales vary with the reduction block.
- Using LeetGPU Challenge 32's FP32 matmul reference as an arbitrary-range exact integer oracle. Its large products can exceed exact FP32 integer range.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.What happens to an all-zero block under amax-based scaling?Answer
Naively it produces a zero scale and division by zero. Choose a defined positive scale and emit zero codes.
2.When can scales move to the epilogue?Answer
When each output's scale product is constant over its entire reduction. Reduction-dependent scales require scaled partial products.
3.Why is relative error alone a poor gate near cancellation?Answer
The reference can be almost zero, making a tiny absolute error produce a huge or undefined relative error. Use an absolute tolerance there.
You're done when
Your scale policies pass zero, outlier and partial-block tests, and a numerical acceptance table rejects at least one inaccurate policy regardless of its speed.
Only when you can do this without notes.
Leads to
Notes
Resources · 1 for this unit, 11 more in the section
- 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.
Also in this 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.
- AI Systems Performance Engineering companion code - Chapters 9 and 10Chris Fregly · required
Inspect and run compatible baseline and optimized paths from
code/ch09andcode/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.
- 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.
- 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.
- 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.m16n8k8fragments,mmaandcvt, archived with CUDA 13.0.0; also consultcp.asynccompletion semantics.