Unit 4 of 12 · about 4 hours · explain, derive
Packing overhead, accumulator precision and fused dequantization kernels
Nominal width is not served width, and unpacked weights are not faster weights. The kernel decides whether quantization pays; the packing decides what it costs.
You'll be able to
- Compute served bits per weight from code width, group scales, zero points and alignment for one layout.
- Explain why INT8 products accumulate in INT32 and where overflow would first appear.
- Distinguish fused dequantization-free kernels from dequantize-then-compute paths, and check support on your GPU.
Covers
Read
In this order, only the parts listed
0 of 4 done
- Packing, fusion and on-the-fly dequantizationAWQ: Activation-Aware Weight Quantization for LLM Compression and Acceleration
AWQ arXiv:2306.00978v6, Section 4.2 Deploy AWQ with TinyChat: on-the-fly weight dequantization, SIMD-aware weight packing with the reordered layout figure, and kernel fusion of QKV and position embeddings
- Mixed-precision kernels and quantization hardware notesHands-On LLM Serving and Optimization - Quantization (Chapter 6) and Speculative Decoding (Chapter 7)
Chapter 6 (printed pp. 211 to 213): the Marlin kernel for Ampere and Machete kernel for Hopper paragraph, the W4A16 with GPTQ or AWQ versus W8A8 table entries, and FP8 Is Not Always Applicable with the E4M3 and E5M2 table
The FP8 Is Not Always Applicable box names only Hopper and Blackwell; Ada GPUs (compute capability 8.9) also have FP8 Tensor Cores, and the vLLM v0.31.0 table lists FP8 W8A8 for Ada and Hopper.
- Fusing dequantization into the execution graphAI Systems Performance Engineering - Chapters 15 and 16, speculation and quantization
Chapter 16, Quantization Approaches for Real-Time Inference: Fusing Quantization-Dequantization Steps into the Execution Graph, with weight packing and the CUDA and Triton kernel notes
- Day 13 Part 4: microscaled block overhead100 Days of LLM Inference - Days 13, 14 and 15
Notebook
day13/quantization-number-formats.ipynb, Part 4 NVFP4:quantize_nvfp4_blockwith block size 16 and the effective-bits accounting
Focus on
- Packing reorders sub-byte codes so vector loads stay aligned; the layout in the AWQ figure exists so one instruction feeds many lanes. Count the scale bytes beside the code bytes.
- An INT8 product reaches , and a dot product over thousands of terms overflows INT16 quickly. Accumulate in INT32, then scale once at the end.
- Fused kernels multiply INT4 or FP8 weights against FP16 activations in one pass. Dequantize-then-compute paths pay full high-precision arithmetic plus conversion overhead.
- Hardware support is a table lookup, not a trend. In the vLLM v0.31.0 table FP8 W8A8 needs Ada or Hopper (compute capability 8.9 and up), Marlin covers Turing through Hopper, and GGUF, built for CPU and Apple Silicon runtimes, is listed on GPUs.
Common mistakes · 3
- Benchmarking unpacked reference code and calling it the quantized result. Without the packed layout and fused kernel the numbers describe dequantization overhead, not the method.
- Accumulating in the quantized width. Saturation looks like a quality regression but is an arithmetic bug; widen the accumulator first.
- Assuming an FP8 model runs anywhere. The weights load but the Tensor Core path is missing, so execution falls back or fails; check the support table before planning a run.
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.Group-64 INT4 stores one FP16 scale and one INT8 zero point per group. What is the served rate?Answer
bits per weight, before any alignment padding.
2.Why must INT8 products accumulate in INT32?Answer
One product already reaches 16,129, and a 4096-term dot product can approach , beyond INT16 range. INT32 holds it; scale back after the sum.
3.What distinguishes the Marlin and Machete kernels from a naive dequantize-then-multiply path?Answer
They fuse quantized weight access into the matrix multiplication, so low-bit weights meet FP16 activations in one pass without materializing a full-precision copy.
4.NVFP4 reports about 4.5 effective bits. Where does the half bit come from?Answer
Each block of 16 values shares an FP8 scale: bits per value on top of 4 code bits.
Practice
- 100 Days of LLM Inference Day 13: block-scale accounting
Part 4 NVFP4 cells: vary the block size in
quantize_nvfp4_block, measure error and effective bits per weight, and state which block size your error budget allowsKeep the error tensor and the bit accounting in the same table; one without the other proves nothing.
You're done when
You compute served bits for any group layout without notes and can say for a stated GPU whether the INT4 and FP8 paths are fused, emulated or absent.
Only when you can do this without notes.
Leads to
Notes
Resources · 4 for this unit, 9 more in the section
- Hands-On LLM Serving and Optimization - Quantization (Chapter 6) and Speculative Decoding (Chapter 7)Chi Wang and Peiheng Hu (O'Reilly) · primary
Read "Model Compression" in Chapter 6 for quantization and "Speculative Decoding" in Chapter 7, with its hands-on example. For each method write its correctness contract, the engine support it needs and a predicted winning and losing workload before running it.
- AWQ: Activation-Aware Weight Quantization for LLM Compression and AccelerationMIT Han Lab · required
Focus on salient-weight protection, group scaling and the distinction between simulated quality and real kernel speed. Compare one supported AWQ path with the same unquantized workload.
- AI Systems Performance Engineering - Chapters 15 and 16, speculation and quantizationChris Fregly (O'Reilly) · support
Read "Speculative Decoding and Parallel Token Generation Techniques" in Chapter 15 (draft models, EAGLE, self-speculation, Medusa) and "Quantization Approaches for Real-Time Inference" in Chapter 16.
- 100 Days of LLM Inference - Days 13, 14 and 15Elizabeth Thomas · support
Use the numeric-format, quantization-algorithm and speculative-decoding notebooks as compact preparation. Keep their synthetic demos separate from production-engine and hardware evidence.
Also in this section
- MIT 6.5940 TinyML and Efficient Deep Learning Computing - Quantization LecturesMIT Han Lab · required
Use Lectures 5 and 6 for quantization fundamentals and Lecture 13, Efficient LLM Deployment, for SmoothQuant and AWQ with TinyChat. Implement a small affine quantizer and an outlier experiment before using a pre-quantized checkpoint.
- SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language ModelsMIT and NVIDIA · required
Study activation outliers and the offline smoothing transformation. Reproduce the algebra on one linear layer and compare calibration-sensitive quality with an unmodified reference.
- Fast Inference from Transformers via Speculative DecodingDeepMind · required
Derive acceptance and correction probabilities and implement the exact categorical simulator. Prove distributional equality on tiny distributions before adding a model or engine.
- vLLM Speculative Decoding and Quantization (v0.31.0)vLLM Project · required
Use the speculative decoding page for the supported proposers (draft model, n-gram, EAGLE, MTP) and its losslessness notes, and the quantization page for the hardware support table. Check every method against your GPU's compute capability before planning a run.
- AI Systems Performance Engineering companion code - Chapters 16, 18 and 19 labsChris Fregly · required
Use Chapter 16 AWQ, GPTQ and SmoothQuant pairs, Chapter 18 speculation sweeps and Chapter 19 dynamic quantized cache. Run one family at a time, require quality or numerical parity, and regenerate results on available hardware.
- TensorTonic Language Modeling from Scratch - Perform Exact Speculative SamplingTensorTonic · support
Solve after the acceptance-rule unit, then check your implementation's output distribution against the target by exact enumeration on a tiny vocabulary.
- LLM Inference: From scratch, one token at a time - Module 08Tushar Amrit · support
Work the Speculative Decoding module's acceptance arithmetic and checkpoint before the speedup-model unit.
- AI Performance Engineering - Quantization and Speculative DecodingWafer · reference
A curated index. Use Section 4 only to find a quantization or speculation paper the other entries lack.
- Inference Engineering - Section 5.1, QuantizationPhilip Kiely (Baseten Books) · support
Read 5.1.1 Number Formats for the format table and Precision/Type/Scale-factor with Dynamic range/Granularity, 5.1.2 for PTQ versus QAT and the what-to-quantize decisions, and 5.1.3 for the perplexity, benchmark and custom-eval quality checks.