Measurement, Profiling and Correctness

GPU timing is asynchronous and performance tools perturb the workload. This stage builds a correctness-first harness, combines timelines with kernel counters and roofline models, and requires converging evidence before any optimization claim.

Section 3 of 10 · 12 units · about 46 hours

0/12

By the end you can Audit and repair a misleading GPU benchmark, diagnose one correctness defect and classify three kernel regimes using independent references, synchronized raw trials, timelines, counters and a roofline model declared before profiling.

Units

Build it

Mini project · about 12 to 16 hours

Correctness-first harness with timelines, counters and regime evidence

Harden the kernellab harness with manifests, interleaved trials, independent references, sanitizer reproducers, timelines, counters and regime evidence. Correctness precedes speed throughout, and every number keeps raw samples and lineage. The harness and bound carry into every kernel section.

  1. 1Extend manifests/env.json with a timestamped machine-state log and an interference audit. Separate cold from warm trials, and keep both traces.
  2. 2Run paired randomized interleaved trials in harness/run.py with raw samples, drift plots and stated uncertainty. Check the method against CS336 benchmarking_script, and keep the trial design with event-timed evidence.
  3. 3Write independent copy and reduction references in refs/ over an adversarial matrix with prefilled outputs. Test your own tail, stride, cancellation and extreme-value policy, and check the numerical note with CS336 mixed_precision_accumulation.
  4. 4Write minimal reproducers for memory, initialization, race and barrier defects and diagnose each with compute-sanitizer. Capture one NVTX-annotated nsys timeline, check it with CS336 nsys_profile, and keep logs, repairs and regressions.
  5. 5Take one minimal, hypothesis-linked capture: hardware counters if you have access (on Linux, sudo ncu), otherwise event timings, bytes over time, cuobjdump -res-usage and nsys timelines. Place one roofline point with sourced ceilings.
  6. 6Predeclare three regimes with one falsifier each, then collect interleaved timings, a timeline and resource evidence. Report each hypothesis as confirmed, contradicted or unresolved, and keep the regime reports.
  7. 7Apply the end-to-end bound with critical-path share to one retained trace, reporting kernel time beside completed latency with losing shapes kept. Check the memory note with CS336 memory_profiling, and file a device-scoped reproduction manifest.
What you hand in
  • The hardened harness with machine-state log, interleaved trials, raw samples and drift plots.
  • Independent references with adversarial matrix and extreme-value policy, plus sanitizer reproducers with logs.
  • One nsys timeline, one minimal counter capture or permission-block record, and roofline plus regime evidence.
  • The end-to-end bound with losing shapes and the device-scoped reproduction manifest.
How to check it
  • Self-grade with the rubric below
  • CS336 Assignment 2 public tests

    Run the benchmarking_script, nsys_profile, mixed_precision_accumulation and memory_profiling problems on sizes that fit your GPU's memory.

How it's graded

References and tolerances

Pass: The copy and reduction references pass the adversarial matrix, and extreme inputs follow your written policy.

Great: Tail and stride regressions fail on the defective kernel and pass after repair.

Sanitizers and timelines

Pass: Each reproducer reports under its stated tool, and the timeline attributes one host gap without reaching for counters.

Great: Regressions are minimal single-defect programs with the identifying log line kept.

Counters and regimes

Pass: The counter capture is minimal and hypothesis linked with overhead recorded, or the permission block is kept, and each regime carries a falsifier and verdict.

Great: The roofline labels useful against requested bytes, and the end-to-end report retains losing shapes.

Resources

  • AI Systems Performance Engineering - Chapters 6 to 8Chris Fregly

    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.

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

    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

    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

    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

    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

    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.

  • CUTLASS GEMM Performance Measurement MethodologyNVIDIA

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

  • CS336 Assignment 2 - Section 2.1 ProfilingStanford University

    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

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

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

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

  • PyTorch 2.14 numerical accuracy and tensor testingPyTorch

    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

    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.