/inferencekit:profilingfrom inferencekit
Routes inference profiling to vendor tools (nsys, ncu, rocprof, Instruments) for timeline and kernel analysis. Identifies where time goes, GPU idle, launch overhead, and memory-bound kernels on NVIDIA, AMD, Apple Metal, and CPUs.
Ships in inferencekit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
nsys records a timeline (CPU threads, CUDA API calls, kernels, copies, NVTX ranges): where the time goes and whether CPU or GPU is on the critical path. ncu replays one kernel reading hardware counters: why it takes as long as it does. Neither proves a speedup; only an interleaved A/B does (benchmarking). In optimizing-kernels' change loop: one nsys capture per lever area (again when the bottleneck moves), a mechanism profile only for a claimed change.
Use when decode or prefill is below ~85% of its ceiling for unknown reasons (ceiling bands), for launch overhead, host syncs or idle gaps, for one dominant kernel family's limiter, or for the mechanism behind a measured speedup. Not for a speed number (never time with a profiler on), nor before you have a benchmark and a ceiling (a profile without them has no scale).
GPU approval: captures occupy the GPU; run them only with budget.approved: true in intake.yaml or an explicit yes to the stated cost. Analysing existing files needs none.
Read doctor's data.hardware.platform/data.profiling_route and the relevant hardware reference. NVIDIA: nsys → ncu. AMD: rocprofv3 HIP/kernel/copy timeline → architecture-supported counters (Instinct support does not establish Radeon support). Apple: Instruments CPU/Metal → Xcode/MLX capture. CPU: perf when permitted, otherwise engine timers or CPU-only torch.profiler. nsys/ncu capture is NOT RUN elsewhere; profiling itself still applies.
Retrieve current official docs online for unknown architectures, runtime/tool support, flags or errors before choosing a path; record URL/date/version and check local help. Use AMD ROCm, Apple Developer/MLX and NVIDIA primary sources. Retain timeline/op attribution when counters fail, marking unsupported checks NOT RUN. All platforms follow critical path → Amdahl → change → correctness → unprofiled interleaved A/B, with the same environment hygiene. Include text encoding, image VAE, audio codec/vocoder and buffering where applicable.
HF_HUB_OFFLINE=1): the capture must hold no tokens.inferencekit ceiling bw), memory headroom for replay.env -i with an allowlisted environment (inferencekit nsys capture / ncu capture do it). Why: a .nsys-rep stores the full environment, tokens included.inferencekit nsys analyze -> data.steps.families.*.critical_pct_of_step, GPU idle in data.steps.idle_pct_of_step). kernel_sum_us / span_us > 1 means kernels overlap and duration shares are inflated.cudaGraphLaunch time) from a node-traced capture. Why: node tracing inflated it about 25x in one measured case.--launch-skip landing in warmup, autotuning, graph capture or prefill (the wrong launch).Profile:
- [ ] 1. Benchmark number and ceiling in hand (ms/token or TTFT, % of ceiling)
- [ ] 2. inferencekit nsys capture -- <steady command> -> ev_cap (.nsys-rep, .sqlite)
- [ ] 3. Check the record: trace mode (node/graph), env allowlist, capture window, limitations
- [ ] 4. inferencekit nsys analyze <rep|sqlite> -> ev_tl
- [ ] 5. Profile check: per-step wall p50 vs the benchmark's ms/token (within a few %?)
- [ ] 6. kernel_sum / span: > 1 means overlap; use critical-path shares only
- [ ] 7. Answer the six questions, each with a number
- [ ] 8. One family dominates and is far from speed of light -> ncu on it (counters blocked: NOT RUN, see "Fallbacks"):
inferencekit ncu capture --kernel-regex '^<name>$' --launch-skip <N_pre + 2k> --count 5 -- <cmd> -> ev_ncap
inferencekit ncu summarize <.ncu-rep> --peak-gbs <ev_bw> -> ev_k
- [ ] 9. Bound label per kernel; speed-of-light gap; Amdahl bound of the proposed change
- [ ] 10. Fill the fixed tables; every number observed/derived/inferred
inferencekit nsys capture -- python run_decode.py --model ./models/qwen3-8b-fp8 --gen-len 128
inferencekit nsys analyze <.nsys-rep or .sqlite path from the capture record's artifacts>
inferencekit ncu capture --kernel-regex '^fp8_block_gemv_kernel$' --launch-skip 400 --count 5 \
-- python run_decode.py --model ./models/qwen3-8b-fp8 --gen-len 64
inferencekit ncu summarize <.ncu-rep from the capture record> --peak-gbs <ev_bw>
inferencekit evidence show <ev_id>
MCP tools: capture_nsys, analyze_nsys, capture_ncu, summarize_ncu, capture_rocprof, analyze_rocprof, inspect_evidence (in OpenCode, run captures through the CLI, detached). Options: --help. Hygiene and manual env -i recipes: references/capture-hygiene.md.
Other skills link here for these rules.
doctor's data.profiling_counters.status, from the driver setting and the process's capabilities (not root: a container's root usually lacks CAP_SYS_ADMIN): allowed, admin_only (no ncu, unless its reason says this process has CAP_SYS_ADMIN: then probe) or unknown. inferencekit doctor --probe-profilers settles it with a tiny nsys and ncu capture, or the first small ncu capture does (counters in its coverage.missing: blocked). Containers and many cloud instances block them, A100 and H100 included: a host setting, not the GPU model.--profiler-config with /start_profile and /stop_profile, SGLang /start_profile, torch.profiler in a custom engine. The CLI does not parse its Chrome/Perfetto traces: read kernel time per step and GPU idle gaps by hand or with profile-analyst. It slows the run: never time with it on (references/torch-profiler.md).profiles: <path>, ... in constraints; non_interactive: a QUESTIONS.md request): inferencekit nsys analyze <file.nsys-rep or .sqlite>, inferencekit ncu summarize <file.ncu-rep> --peak-gbs <ev_bw or GB/s> (no GPU; without the ncu CLI, CSV exports: references/ncu-capture-recipes.md). A profile from another GPU or engine version explains that setup only: say so by every number. Never copy, commit or upload such files (they may hold secrets); cite the analysis.inferencekit rocprof capture and rocprof analyze for kernel/HIP traces, or a supported vendor profiler; rocprof-compute support depends on the exact GPU (amd-rocm.md). Use perf or likwid on CPU, Instruments or MLX on Apple, under env -i. Vendor captures outside the CLI are cited by file; kernel totals may overlap and the bound label stays inferred.--cuda-graph-trace=graph shows realistic host timings (host costs, CPU vs GPU critical path); node shows every kernel inside graphs (ranking, gaps) but inflates cudaGraphLaunch. inferencekit nsys capture traces nodes; for host costs add one graph-level capture (references/capture-hygiene.md).kernel_sum_us - busy_us is about one family's summed duration, that family is mostly hidden: size changes with critical_pct_of_step (lessons, "Summed time lies under PDL").cudaStreamSynchronize, D2H of the sampled token) mean the CPU is. 3. Which stage? Attention, MLP, lm_head or sampling, by critical-path family. 4. A few big kernels or a long tail? A long tail of microsecond kernels means hand-off bound. 5. Speed-of-light gap? Bytes a big kernel must read / measured bandwidth vs its in-step time. 6. Amdahl bound? 1 / ((1 - f) + f / s) for critical-path fraction f made s times faster. Traps and SQL on the .sqlite: references/six-questions.md.| Label | Evidence pattern (heuristic thresholds) | Lever |
|---|---|---|
| memory-bound | DRAM throughput >= ~70% of the measured peak; SM pipes well below theirs | read fewer bytes (precision, fusion that avoids re-reads) |
| compute-bound | a pipe (tensor, FMA, ALU) >= ~70% of its peak; DRAM well below | fewer instructions (better maths path, tensor cores, cheaper dequant) |
| latency-bound | DRAM and SM both below ~50%; few eligible warps; long-scoreboard / barrier stalls; grid below one wave or low occupancy | more bytes in flight: more blocks (split-K), wider loads, fewer dependent steps |
The label is inferred: a hypothesis, not a verdict. Counters suggest; in-place timing decides (lessons). Capture recipes: references/ncu-capture-recipes.md; metrics and the L2-resident and nominal-peak traps: references/ncu-metrics.md.
Evidence kinds: nsys_capture -> nsys_timeline; ncu_capture -> ncu_kernels; rocprof_capture -> rocprof_summary. Profile files hold host names, paths and command lines: never upload one unless the user checked it.
| Question | Answer | Number | Class | Evidence |
|---|---|---|---|---|
| Profile vs benchmark (step ms vs ms/token) | % difference | derived | ev_tl, ev_bench | |
| kernel_sum / span | ratio | derived | ev_tl | |
| 1-6 (as above) | observed / derived | ev_tl, ev_bw |
| Kernel (anchored) | Launches profiled | Grid, waves | ncu duration us (not e2e) | DRAM GB/s | % of measured peak | SM % | Occupancy | Top 2 stalls | Bound (inferred) | Evidence |
|---|
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
inference-profiling, gpu-profiling, kernel-analysis, nsys, ncu, pytorch-profiler
npx claudepluginhub kittenml/inferencekit --plugin inferencekit9 skills in this plugin
/benchmarkingMeasure end-to-end inference latency, throughput, memory and cost against tuned baselines with balanced rounds and quality evidence. Use for engine/config comparisons and performance claims. Route text, image, audio and video to their own client timers and protocols; isolate device measurements./evaluating-quantizationChoose a compressed model format by measuring memory, complete-request speed and task/perceptual quality on the exact target hardware. Use for quantization, lower precision or fitting a model on cheaper hardware. Respect the chosen quality policy and separate model-change permissions./inference-triageRoute inference performance questions for text, image, audio, video and other models to the cheapest useful evidence: latency, throughput, memory, hardware cost or quality. Use when unsure where to start; select tools for NVIDIA, AMD, Apple Silicon or CPU and preserve resource authorization.Other plugins' skills for the same job