Unit 2 of 12 · about 3 hours · measure

Warmup, compilation, allocator and cache state

First-use overhead and repeated-buffer reuse answer different questions from steady-state work on changing inputs. Neither should silently enter the other result.

You'll be able to

  • Separate compilation, autotuning and allocator initialization from warm execution.
  • Choose and record an application-relevant cache and buffer-reuse policy.
  • Use a bounded warmup rule and retain evidence when steady state does not settle.

Covers

Warmup convergence, JIT compilation, autotuning and cache stateAllocator pools, L2 and application-cache state
1

Read

In this order, only the parts listed

0 of 3 done

  1. CUTLASS: warmup and buffer rotationCUTLASS GEMM Performance Measurement Methodology

    Documentation updated September 21, 2026: Benchmark Requirements; Warm-ups and Profiling Iterations; Buffer Rotation

    Do not copy the Blackwell iteration counts. The claim that rotation guarantees DRAM-resident inputs is too strong: replacement, access coverage and persistence affect residency. Treat rotation as an eviction strategy to check, not proof of a cold cache.

  2. Allocator pools versus data cachesAI Systems Performance Engineering - Chapters 6 to 8

    Chapter 6, CUDA Programming Refresher: Asynchronous Memory Allocation and Memory Pools

  3. Harness cold and warm contractGPU Microbenchmark and Kernel Suite - Harness and Instrumentation

    Architecture constraints; Milestone B - Instrumentation, compilation/autotuning and cold/warm items

2

Focus on

  • A warmed allocator, compiled code cache, tuned configuration, L2 cache and application KV cache are different state. Record them separately.
  • Warm every evaluated shape, dtype and specialization. A new shape can trigger compilation or tuning after another shape has settled.
  • Inspect warmup batches and clock state with a declared stability rule and a time cap. A fixed count is not evidence of convergence.
  • Reuse buffers when reuse represents the application. Rotate preallocated buffers when studying streaming traffic; exclude rotation setup and label unverified residency.
Common mistakes · 3
  • Calling torch.cuda.empty_cache() between trials and claiming to have flushed L2. It releases unused allocator cache, not a hardware data cache.
  • Putting compilation or input allocation in only one variant's timed boundary.
  • Running warmup forever to obtain a preferred timing while hiding thermal drift.
3

Try it yourself

Closed-book, before checking anything

From a fresh process, record the first call and subsequent batches for the timing unit's matrix multiply. Repeat with preallocated rotating inputs and with the same inputs reused. Keep the warmup samples and declare which state each run preserves. Do not require a difference: a small workload or unchanged execution path may show none.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.Does a warm model imply every specialization is compiled?Answer

    No. New shapes, dtypes or guards can create new specializations or trigger tuning.

  2. 2.Is repeated-buffer caching always a benchmark defect?Answer

    No. It is legitimate when the target workload reuses those buffers. It is misleading when presented as streaming DRAM performance.

  3. 3.Why keep a first-call result even when reporting warm performance?Answer

    It exposes startup, compilation and tuning costs that warm timing deliberately excludes. Deployment may pay them.

5

Practice

  • CS336 Assignment 2: benchmarking_script (c)

    Problem (benchmarking_script), part (c), p. 4

    Reuse the model setting from the timing unit. Compare zero, one, two and five warmup steps, then test your bounded stability rule. Keep identical timed boundaries and record allocator and specialization state. The section mini-project adds the rotating-buffer cache experiment.

You're done when

You can regenerate separate first-use and warm reports with retained warmup samples, a bounded stability rule, and an explicit allocator and buffer-reuse policy.

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 6 to 8Chris Fregly · primary

    Read Chapters 6 to 8: GPU architecture and occupancy, profiling and tuning memory access, and occupancy, warp efficiency and instruction-level parallelism, with their Nsight Systems, Nsight Compute and roofline workflows. Treat every quoted speedup as a hypothesis for your own hardware.

  • CUTLASS GEMM Performance Measurement MethodologyNVIDIA · support

    Apply the environment, clock, warmup, timing, verification and reporting guidance to the benchmark harness. Generalize the method beyond GEMM and document every intentional deviation.

  • GPU Microbenchmark and Kernel Suite - Harness and InstrumentationRoadmap-Final · support

    Complete Milestones A and B: correct references, synchronized timing, raw samples, noise characterization, environment capture, operation and byte models, timeline traces and profiler evidence.

Also in this section

  • AI Systems Performance Engineering companion code - Chapters 6 to 8Chris Fregly · required

    Use selected baseline and optimized pairs from code/ch06, code/ch07 and code/ch08 plus the shared benchmark and verification machinery. Run only hardware-compatible paths, inspect the tests first, retain raw artifacts and document any guard or unavailable feature.

  • Nsight Systems User GuideNVIDIA · required

    Learn capture, statistics, CUDA API and GPU timeline views, NVTX ranges and report export. Produce one trace that attributes a host gap, transfer or synchronization cost without using the kernel profiler first.

  • Nsight Compute Profiling GuideNVIDIA · required

    Study the profiling model, replay, metric collection, sections, roofline and source correlation. Collect the smallest counter set that can falsify your bottleneck hypothesis and record profiler overhead.

  • Compute SanitizerNVIDIA · required

    Run memcheck plus applicable racecheck, initcheck and synccheck cases against seeded defects. Preserve minimal reproducers and regression tests, and distinguish unsupported checks from a clean result.

  • Roofline: An Insightful Visual Performance ModelUC Berkeley · required

    Read the original model and construct one roofline plot with explicit peak assumptions, useful operations and bytes. Add measured points and explain gaps from launch, resource, cache or instruction effects.

  • CS336 Assignment 2 - Section 2.1 ProfilingStanford University · support

    Do the benchmarking_script, nsys_profile, mixed_precision_accumulation and memory_profiling problems on a model size that fits your GPU instead of the handout's B200 settings. Keep raw timings, traces and memory snapshots.

  • TensorTonic Language Modeling from Scratch - Measure Kernel Timeline UtilizationTensorTonic · support

    Solve the timeline-utilization problem after the timeline unit, then repeat the calculation on a trace you captured yourself.

  • PyTorch 2.14 numerical accuracy and tensor testingPyTorch · reference

    Read the numerical-accuracy introduction, Extremal values, non-finite inputs and Ampere precision sections, plus the assert_close contract and make_tensor parameters. These supply current comparison semantics missing from the pool's project checklist.

  • CUDA 13.4 Floating Point and IEEE 754NVIDIA · reference

    Read sections 2.2, 3.1 to 3.2 and 4.4 for reduction order and single-precision flush-to-zero flags. Do not use the historical CPU-has-no-FMA statements as current hardware facts.