Unit 9 of 12 · about 4 hours · measure
Kernel counters, section sets, replay and profiler overhead
Counter collection changes execution and can replay work several times. A detailed report is not automatically a faithful measurement of application latency.
You'll be able to
- Choose the smallest section or metric set that can falsify a kernel hypothesis.
- Explain replay, cache and clock controls and their impact on comparability.
- Separate unprofiled latency from profiling overhead and record unavailable counters honestly.
Covers
Read
In this order, only the parts listed
0 of 2 done
- Nsight Compute 2026.3.1: collection and perturbationNsight Compute Profiling Guide
Sections 2.2.1 to 2.2.3, Sets and Sections, Sections and Rules, and Replay; 2.2.6, Overhead; 2.6.2, Clock Control; 2.6.3, Cache Control
Read Kernel Replay, Application Replay and Range Replay. Skip the detailed supported-API enumeration and advanced graph profiling until your hypothesis requires them.
- Choose a hot kernel after the system traceAI Systems Performance Engineering - Chapters 6 to 8
Chapter 8, Profiling and Diagnosing GPU Bottlenecks: Nsight Compute and Roofline Analysis and Profiler-Guided Analysis
Focus on
- Start from one named kernel and one hypothesis.
LaunchStatsdescribes launch resources;MemoryWorkloadAnalysistests traffic questions;ComputeWorkloadAnalysistests pipeline use. - Hardware counters may require multiple passes; software-patched metrics have separate overhead. Kernel replay saves/restores memory, while application replay reruns host setup and requires matching launches.
- Record replay mode, pass count, cache control, clock control, selected kernel and tool version. Default cache flushing can differ from warm application reuse.
- On Linux the driver restricts counters to administrators by default, and
ncuthen fails withERR_NVGPUCTRPERM. On your own machine, runncuwithsudoor grant access as https://developer.nvidia.com/nvidia-development-tools-solutions-err_nvgpuctrperm-permission-issue-performance-counters describes. Where you cannot, keep the error and use events, timelines, static resource reports and instruction inspection, leaving counter conclusions open.
Common mistakes · 3
- Using elapsed profiler process time as kernel latency or as production end-to-end latency.
- Collecting the full set by default, then diagnosing a noisy short kernel from unrelated metrics.
- Assuming counters from separate passes describe an unchanged concurrent workload when replay serialized or reran it.
Try it yourself
Closed-book, before checking anything
LaunchStats and the section needed for your hypothesis. On a permitted device, retain the report, replay settings and pass count, then compare completed process wall time with and without collection. If counters are denied, retain the error and substitute an unprofiled event result plus compiler resource report; do not report an overhead ratio for a failed capture.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Why might requesting more metrics increase profiling time greatly?Answer
Counters cannot all be collected together. Extra passes, memory save/restore, software instrumentation and first-use metric configuration add work.
2.Does restoring global memory restore the original L2 cache state?Answer
No. Device memory contents and hardware cache residency are separate state. Record cache control and choose replay appropriate to the experiment.
3.What does a denied counter capture tell you about the kernel's DRAM utilization?Answer
Nothing. It is a permissions failure, not a zero measurement. Keep the counter hypothesis open.
You're done when
You have a minimal hypothesis-linked report and separate unprofiled timing, or a documented counter blocker with static/timeline evidence and the remaining counter check marked pending.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 10 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.
- 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.
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/ch07andcode/ch08plus 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.
- 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.
- 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.
- CS336 Assignment 2 - Section 2.1 ProfilingStanford University · support
Do the
benchmarking_script,nsys_profile,mixed_precision_accumulationandmemory_profilingproblems 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.
- 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.
- 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_closecontract andmake_tensorparameters. 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.