Quantization and Speculative Decoding

Low precision and speculative execution change memory, kernels, quality and request state. Both need a correctness contract and measured crossover region, not a nominal bit width or acceptance-rate headline.

Section 6 of 9 · 12 units · about 48 hours

0/12

By the end you can Show numerical or task-quality correctness for one quantized path and distributional correctness for exact speculation, then identify a measured win and loss region for each mechanism with safe fallback.

Units

Build it

Mini project · about 12 to 18 hours

Quantized and speculative paths with measured win regions

Build blank-file quantization with calibration and method comparisons, plus a seeded speculative simulator with exactness, rollback and drafter evidence. Integrate one path into engine/ behind a versioned config and map measured benefit and loss regions with quality held.

  1. 1Implement symmetric and asymmetric quantize and dequantize maps with per-tensor, per-channel and grouped scales from a blank file, derive served bits per weight with scale overhead, and run the Day 13 number-format and symmetric-pipeline experiments on outlier tensors.
  2. 2Calibrate static ranges on sample data, apply the SmoothQuant migration and activation-aware scaling on a layer with a planted outlier channel, and compare naive rounding against GPTQ, AWQ and SmoothQuant on held-out inputs with Day 14 cells.
  3. 3Derive served bits for your packing layout with alignment and the accumulator contract, then measure a quantized path against its baseline on your GPU for memory, TTFT, TPOT and throughput beside slice quality, with the Chapter 19 cache pair as a second check.
  4. 4Prove the acceptance rule preserves the target distribution, build a seeded speculative simulator with separate draft, accept and residual steps, match the Day 15 acceptance rows, which omit the bonus token, within noise, fail the naive rule visibly, and pass the TensorTonic speculative-sampling cases.
  5. 5Add KV advance with truncate-to-prefix rollback, stop handling and tokenizer checks to the simulator; build yield and speedup tables with the Module 08 lab to pick draft length and the stop regime; and compare the n-gram proposer on repetitive against novel prompts.
  6. 6Integrate one quantized or speculative path into engine/ behind a versioned configuration with a tested fallback, then map benefit and loss regions across batch size and sequence length with quality held, attributing each region to acceptance, cost, kernel coverage or scheduler interaction.
What you hand in
  • Blank-file quantizers with scale proofs, calibration evidence and the method comparison on held-out inputs.
  • The speculative simulator with exactness, rollback, stop and TensorTonic evidence plus yield and drafter tables.
  • The integrated path with versioned config, fallback drill and the benefit and loss map with quality held.
How to check it
How it's graded

Quantization maps

Pass: Blank-file symmetric and asymmetric maps round-trip on outlier tensors, and served-bits math includes scale overhead.

Great: Grouped scales rescue small values in a shown collapse, and block-size error tables defend the layout choice.

Method comparison

Pass: Calibration, smoothing and scaled methods beat naive rounding on held-out inputs with static against dynamic ranges named.

Great: A stale-calibration case shows the drift symptom and the recalibration or dynamic-range fix.

Speculative exactness

Pass: The simulator matches the target within noise, fails the naive control, and rollback leaves entries only for accepted tokens.

Great: Target-only processing and grammar-masked targets stay exact with measured acceptance drops explained.

Measured regions

Pass: Baseline and integrated paths share prompts, sampling and cache state, and benefit and loss regions carry quality evidence.

Great: Each region names its mechanism and bottleneck shift, and fallback flips under load with baseline outputs restored.

Resources