Unit 8 of 10 · about 3 hours · explain

Strong baselines and the correctness contract

A speedup against a weak baseline, or with unchecked outputs, is marketing. Strong baselines plus a correctness contract are what make a later kernel claim believable.

You'll be able to

  • Choose a strong baseline (library, compiler or engine) at a matched workload and state why a weaker one would flatter the result.
  • Reconcile prediction with measurement by naming each residual (bandwidth efficiency, intermediates, comms, launches) with its size.
  • Write the correctness contract for an optimization: independent reference, tolerance policy, fallback path and consumed outputs.

Covers

Framework, vendor library, compiler and existing engine baselinesNumerical correctness, output quality and semantic-equivalence contract
1

Read

In this order, only the parts listed

0 of 3 done

  1. Model versus FasterTransformer reconciliationTransformer Inference Arithmetic

    comparing against real benchmarks (the 1-GPU 76% and 2-GPU 62% accounting; the prefill shortfall with 72% and 54% skinny-GEMM efficiency)

    The benchmark totals cover the context (prefill) time plus 10 generated tokens: ms per token is the 1-GPU run and ms the 2-GPU run. Several intermediate values are rounded loosely (18.5, 20.7 and 9.5 ms); recompute them.

  2. Expected-versus-observed profile checksHow to Scale Your Model - Inference

    Looking at a real(ish) example profile (95.6 ms expected against 96 ms observed; the 128 MB ReduceScatter check)

  3. Reference and fallback contractsGPU Microbenchmark and Kernel Suite

    Architecture constraints (independent references, output consumed before any speed claim, fallback for every custom path); Correctness requirements

2

Focus on

  • Predict first in bytes and operations (8.4 ms on 2 GPUs, 16.8 on 1), then account the gap: 90% versus 87% bandwidth, 2.2 versus 2.0 ms intermediates, 1.7 ms unparallelized comms.
  • Prefill shortfalls diagnose differently from decode: 72% and 54% of peak on skinny GEMMs is an efficiency finding, not a bandwidth one.
  • The reference never shares the target's logic, outputs are consumed before any speed claim, and every custom path keeps a fallback.
Common mistakes · 3
  • Comparing predictions with the benchmark totals. The 180.86 and 283.60 ms runs include the context time and 10 output tokens; subtract the context and divide by 10 before reconciling per-token steps.
  • Fitting constants after the fact. Each residual needs an independent line (profiled bandwidth, counted passes, timed comms); unexplained remainder stays unexplained.
  • Skipping output consumption. An unmaterialized or unchecked output can delete the very work you claim to time; the harness constraint exists for this.
3

Try it yourself

Closed-book, before checking anything

Closed-book, reconcile the 1-GPU case: ms plus 2.2 ms of intermediates gives about 20.9 ms against 22.0 measured, leaving about 1.1 ms of named sub-millisecond residuals (the article rounds to 18.5, 20.7 and 1.4). Then reconcile the 2-GPU case at 87% bandwidth.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.What do the 76% and 62% figures mean, and what closes each gap?Answer

    Prediction over measurement per token. 1 GPU: 90% bandwidth plus 2.2 ms intermediates closes to about 20.9 of 22.0. 2 GPUs: 87% bandwidth, 2.0 ms intermediates and 1.7 ms comms close to 13.4 of 13.5.

  2. 2.Why is the prefill shortfall not a bandwidth finding?Answer

    Prefill there is compute-bound, yet GEMMs reach only 72% and 54% of peak; skinny shapes underuse the matmul units, matching the cited paper's Figure 14 pattern.

  3. 3.Why must the reference avoid sharing the target's logic?Answer

    A shared bug passes both sides. Independence is what lets agreement mean correctness instead of coincidence.

  4. 4.When is an exact match required, and when is a tolerance the contract?Answer

    Exact where the math is exact (integer counts, layouts); dtype, order and conditioning set the tolerance everywhere else.

5

Practice

You're done when

Your hand reconciliation lands within a millisecond per case with every residual named, and you can state the baseline and contract for your unit-4 sweep.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 6 more in the section
  • How to Scale Your Model - InferenceJAX Scaling Book · primary

    Work through the single-request, batching, key-value memory and parallelism arithmetic. Recompute every quantity for the small model and workload used by the track project, keeping symbols, units and assumptions visible.

  • Transformer Inference ArithmeticKipply · required

    Reproduce the FLOP, parameter-byte, key-value-byte and communication estimates for dense transformer inference. Compare the formulas with an instrumented framework trace and explain model residuals instead of fitting constants after measurement.

  • GPU Microbenchmark and Kernel SuiteRoadmap-Final · support

    Adopt the project harness schema, architecture constraints and hardware tiers now. Implement only the environment manifest, independent references, raw-trial storage and the initial operation and byte models in this stage.

Also in this section

  • AI Performance Engineering - Start HereWafer · reference

    A curated, dated index. Its Start Here list names the readings this section already assigns; use the later sections only to find a primary source for a later section, never as the reading itself.

  • Efficiently Scaling Transformer InferenceMLSys · required

    Study the latency, memory and parallelism model. Use the paper to derive a batch and parallelism crossover for your workload, while reserving distributed execution for GPU-9.

  • EtalonEtalon Authors · support

    Read the latency metric definitions, their pitfalls and fluidity-index. Add TTFT and TPOT SLOs to a small load generator, and show why peak token throughput can rank two systems differently from an SLO-qualified rate.

  • How to Scale Your Model - TrainingJAX Scaling Book · required

    Work Some Problems to Work Questions 1 to 3 for training-step parameters, Adam and activation bytes and step time; read Data Parallelism and Fully-Sharded Data Parallelism for the comms-bound batch rule.

  • Amdahl's lawWikipedia · reference

    Read Definition and Derivation for the overall-speedup formula with the worked share examples; apply it to kernel time shares at fixed workload.

  • DistServe: Disaggregating Prefill and Decoding for Goodput-optimized LLM ServingZhong et al. (OSDI 2024) · support

    Read Section 1 with Figure 1 for per-GPU goodput: the highest request rate served while a target share of requests meets the TTFT and TPOT SLOs.