Kernel profiling nsight
Skill Amey-Thakur/AI-SKILLS/skills/gpu-ai-infrastructure/kernel-profiling-nsight
Plug-and-play skills and prompts for every AI coding agent
npx -y skills add Amey-Thakur/AI-SKILLS --skill kernel-profiling-nsightAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 19 days oldThe repository was created 19 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Profile GPU work with Nsight Systems and Nsight Compute to read the timeline, name the bottleneck class, and pull the metric that dictates the fix. Use when a GPU program is slower than expected and you need evidence before touching a kernel.
SKILL.md
3.5 KB, as published. Nobody here has run it
Kernel profiling with Nsight
The two tools split the job cleanly: Nsight Systems shows the whole timeline of where time goes across CPU, copies, and kernels, while Nsight Compute dissects one kernel's internals. The common mistake is opening Compute first and missing that the GPU sat idle 60 percent of the run waiting on the host. Profile top-down, from timeline to kernel, so the change you make is the one costing wall-clock time.
Method
- Capture the whole run with Nsight Systems first. Run
nsys profile -o out ./appand open the report. Scan GPU utilization across the timeline: gaps between kernels mean the device is starved by host code, tiny launches, or a synchronouscudaMemcpy. Close idle time before optimizing any kernel. - Annotate phases with NVTX ranges. Wrap logical stages (data load, forward,
backward) in
nvtxRangePush/nvtxRangePopso the timeline reads as named bands instead of an undifferentiated wall of kernels. This makes the starved phase obvious at a glance. - Name the bottleneck class before optimizing. Every kernel is capped by one of three things: memory bandwidth, compute throughput, or latency from too little parallelism. Nsight Compute's Speed Of Light section reports Memory and Compute as percentages of peak; high memory and low compute is bandwidth-bound, both low is latency-bound and usually low occupancy.
- Capture the target kernel with the full set. Run
ncu --set full -k kernel_name -c 1 ./appto profile one invocation. Filter by name and count because profiling every launch is slow, and the full set is what lets the guided analysis rules fire. - Read the metrics that name the fix, not raw counters.
dram__throughputandsm__throughputgive the SOL split,l1tex__t_sector_hit_rateshows cache reuse, and low sectors-per-request flags uncoalesced loads. Warp State Statistics names the top stall: Long Scoreboard is waiting on memory, Barrier is__syncthreadscontention. - Follow the guided rules, change one thing, reprofile. Compute prints findings like "uncoalesced global access" with an estimated speedup. Treat each as a lead, apply a single change, and reprofile, since a fix often shifts the bottleneck to a new class rather than removing it.
- Diff before and after to prove the win. Open the two
.ncu-repfiles side by side and confirm both the targeted metric moved and kernel duration dropped. A counter that improved without cutting duration was not the bottleneck.
Litmus tests
- Can you state memory-, compute-, or latency-bound with SOL percentages behind the claim?
- Did you rule out GPU idle time in Nsight Systems before opening a kernel?
- Does the profiler name a concrete stall reason rather than a vague "it's slow"?
- After the change, did kernel duration in the report actually fall?
Boundaries
Nsight tells you where time goes and why a kernel stalls; it does not write the
faster kernel. Turning uncoalesced loads into coalesced ones is
cuda-kernel-basics; turning bandwidth-bound into compute-bound is
gpu-memory-hierarchy. Overhead from ncu is high, so profile a reduced input,
and never draw conclusions from a debug build.