Logo: Ncu Report Skill

Ncu Report Skill

Organisatioun
mit-han-lab
ncu-report-skill

Use before deciding how to optimize a CUDA kernel (hand-written CUDA, Triton, CUTLASS/CuTe), when a kernel is slower than expected, and whenever you are about to run Nsight Compute (ncu) or read its output — instead of guessing at the bottleneck, writing your own profiling script, or reading ncu's console tables by eye. One ncu collection, then helpers that extract key metrics, NCU's rule results, per-line stalls (inlined CUTLASS/CuTe/Triton code included) and PM timelines, and a playbook from signals to fixes. Also when a user asks to profile a kernel, read an ncu report or write an optimization plan ("profile 一下", "为什么慢", "ncu 报告"). Written for ncu 2026.3 on Blackwell (B200 / B300) and other NVIDIA GPUs.

Iwwersiicht

Editeurmit-han-lab
Repositoryncu-report-skill
Skill-Nummncu-report-skill
Stären
258
Forks
38
Matgeliwwert Dateien
18
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 18 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    mit-han-lab huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Ncu Report Skill an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/mit-han-lab/ncu-report-skill/tree/main
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/mit-han-lab/ncu-report-skill.git \
  .claude/skills/ncu-report-skill
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Ncu Report Skill an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Ncu Report Skill automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Ncu Report Skill net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Skill: CUDA Kernel Profiling (Nsight Compute)

When to use: before choosing what to optimize in a GPU kernel (CUDA C++, Triton, CUTLASS/CuTe), when a kernel is slower than its budget or baseline, after a change whose effect you do not understand, and every time you are about to run ncu or read a report — so the bottleneck comes from measurements, not guesses. Also when someone asks to profile a kernel, find its bottlenecks, read an ncu report or write an optimization plan ("profile X", "为什么这个 kernel 慢", "ncu report 说...", "下一步怎么优化", "帮我看一下这份 ncu 报告").

Written for: Nsight Compute 2026.3.1, the newest release (it also reads reports of older versions), on Blackwell — B200 (sm_100) and B300 (sm_103), 148 SMs each. A CUDA toolkit bundles the ncu of its release (CUDA 13.2: 2026.1.1); newer ones are separate installs (NVIDIA's CUDA package repositories carry nsight-compute-<version>, and the toolkit's ncu launcher runs the newest installed). Most advice is generic; GPU- or version-specific notes say so. ncu's flags, sets and metric names change between releases: ncu --version, ncu --help, ncu --list-sets and ncu --list-sections are the authority when something here does not match what you have.


Golden rule

Profile → Diagnose → Plan, in that order. Never guess.

Most under-performing CUDA kernels are under-performing for exactly one reason that ncu can tell you in 10 seconds. Don't invent hypotheses before you have the report. Don't start coding a fix before you've matched the observed pattern to a known diagnosis. Don't write a wall of suggestions — rank them by evidence and expected impact.


Quickstart (what to do when someone says "profile this kernel")

  1. Create a new run directory first — one directory per run, never reuse an existing one — under the directory your project keeps profiling artifacts in (its README, AGENTS.md or contributing docs may name one; if none does, create one at the repo root and say where in the report). Each run holds its own harness/, reports/, analysis/ and REPORT.md; the docs call it $PROFILE_RUN_DIR. See reference/00-directory-layout.md.

  2. Decide what you're profiling. What inputs? Which dispatch path? What question do you want answered? If the kernel takes variable-sized inputs (variable seq lengths, variable batch sizes), you must pick specific representative shapes from the user's workload — don't profile with arbitrary inputs.

  3. Get a profile target. If the kernel already carries line info (many prebuilt libraries do; reference/02-harness-guide.md shows how to check), profile the real code: a few-line driver (Python or C++) that calls it once on a representative input is enough. Build a standalone harness with -lineinfo when the build has no line info or the kernel is buried in a slow program; the template is helpers/harness_template.cu. Keep it in $PROFILE_RUN_DIR/harness/.

  4. Collect one report with --set full: it holds the per-PC stall samples (SourceCounters) and the PM-sampling timelines and timed warp samples (PmSampling); --import-source yes embeds the source so the report reads anywhere. Give -o the .ncu-rep extension (without one, ncu 2026.3 writes .ncu-repz; the helpers read both):

    bash
    ncu --set full --import-source yes --clock-control boost \
        -k "regex:KERNEL" -c 1 -o "$PROFILE_RUN_DIR/reports/full_<tag>.ncu-rep" <command> [args]

    See reference/03-collection.md for picking the launch, skipping warm-up and faster targeted runs.

  5. Parse with the helpers — not by eye-balling the CLI — into $PROFILE_RUN_DIR/analysis/: analyze_reports.py (key metrics and NCU's rule results), extract_stall_hotspots.py (stalls per source line; --binary for inlined CUTLASS/CuTe code), plot_timeline.py (PM timelines). See helpers/README.md and reference/04-python-api.md.

  6. Work through the six analysis dimensions. See reference/05-analysis-dimensions.md. Every one matters, but on any given kernel only 1–2 will dominate.

  7. Match patterns to the diagnosis playbook. See reference/06-diagnosis-playbook.md. It maps NCU signal → likely cause → concrete fix, with example counts for "how big is this".

  8. Write the report at $PROFILE_RUN_DIR/REPORT.md with evidence-backed recommendations, ranked by expected impact. See reference/07-report-template.md.


Where the GPU is

Only ncu (and the program it launches) needs a GPU. Building the harness for an explicit architecture, ncu --import, and every Python helper only read and write files, so they can run on a machine or in a container without one. No helper picks a GPU or locks a clock: run ncu on the GPU your environment gives you, the way it runs any GPU command. If GPU commands run in another container or on another machine, keep the run directory where both see it (inside the project, say) and pass paths that exist on both sides.

ncu locks the GPU clock for every profiled kernel by default, which keeps reports comparable: at boost in ncu 2026.1–2026.3 (--clock-control boost; older versions default to base, which on a B300 runs kernels ~1.7x slower). ncu --help shows the default. To profile at another fixed clock, lock it outside ncu (e.g. sudo nvidia-smi -lgc MHZ,MHZ before, sudo nvidia-smi -rgc after) and pass --clock-control none, or ncu replaces your lock with its own. See reference/03-collection.md.


File index

Reference docs (read these when you need details)

FilePurpose
reference/00-directory-layout.mdRead first. Directory / naming conventions — one run = one subdirectory, no cross-contamination
reference/01-workflow.mdEnd-to-end checklist from "user request" to "final report"
reference/02-harness-guide.mdProfiling the real code vs. a standalone harness; checking for line info; drivers for Python / prebuilt libraries
reference/03-collection.mdncu command recipes: full, targeted, source-only, survey, clocks
reference/04-python-api.mdncu_report Python API patterns with copy-pasteable code
reference/05-analysis-dimensions.mdSix analysis dimensions: occupancy, balance, stalls, tensor core, timeline, memory
reference/06-diagnosis-playbook.mdPattern → diagnosis → fix. Merges Blackwell programming principles with NCU signals
reference/07-report-template.mdHow to structure the final report
reference/08-metric-names.mdMetric names on Blackwell with ncu 2026.3, and the ones that differ from older docs
reference/09-common-issues.mdPermissions, PM sampling, inlined code, TVM-FFI / PyTorch gotchas

Helpers (reusable code)

FilePurpose
helpers/harness_template.cuStandalone harness template — paste your kernel, fill in input allocation, done
helpers/safetensors_loader.hHeader-only safetensors reader (no external deps) for loading real workload tensors
helpers/analyze_reports.pyKey metrics, NCU rule results (by estimated speedup), side-by-side comparisons
helpers/extract_stall_hotspots.pyPer-line stall aggregation; --binary attributes inlined code to the kernel's own lines
helpers/plot_timeline.pyASCII PM-sampling timeline plotter — makes tail effect visible
helpers/list_flashinfer_workloads.pyBrowse a flashinfer-trace dataset — shape histograms, filter by axis, resolve safetensors paths for specific UUIDs
helpers/ncu_utils.pyShared Python helpers: finds ncu_report, report loading (every kernel in a report), safe metric access, rules, PM series, inline chains

Critical lessons (don't skip)

  1. Metric names differ between GPUs and ncu releases. reference/08-metric-names.md lists what --set full collects on Blackwell with ncu 2026.3. A name missing from a report may still exist: request it with --metrics. Enumerate with action.metric_names() or ncu --query-metrics.

  2. Always compile with -lineinfo (or profile code that has it). Without it, ncu's source view is blank and you cannot do per-line stall analysis. ncu attributes each PC to its innermost inlined frame — a library header for CUTLASS/CuTe code — so pass the profiled binary to extract_stall_hotspots.py --binary to rank the kernel's own lines.

  3. PM sampling is the only way to see tail effects. Static metrics average over the whole kernel; only the time-series (helpers/plot_timeline.py) shows the shape of utilization over time.

  4. Load-imbalance on variable-length inputs is often the #1 bottleneck. If the user's workload has sequences of varying length, per-SM active-cycle variance will often dwarf every other effect. Always check the input distribution.

  5. NCU's rule engine (--page details, or rules_<tag>.txt from analyze_reports.py) tells you where to look. Each rule comes with Est. Speedup: X%. Read them first, then check each against the counters before ranking it: estimates for small grids, shared-memory bank conflicts or L2 compression can be far off.

  6. Don't delegate understanding. Run the profiles yourself, open the reports, cite specific metric values. Never write "the profile shows it's memory-bound" — instead, name the two or three metric values that back your conclusion (e.g., "gpu__dram_throughput.avg.pct_of_peak_sustained_elapsed well under 10%, and long_scoreboard stalls dominate the pcsamp histogram, so the kernel is latency-bound on L1, not DRAM-bandwidth-bound"). Fill in the actual numbers from your report. Specificity is the deliverable.


Related skills

  • blackwell-cuda-programming.md — Blackwell-specific programming principles and checklists, preserved as a companion reference. Use it when proposing new kernel designs; use this skill when diagnosing existing kernels.

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Ncu Report Skill?

Use before deciding how to optimize a CUDA kernel (hand-written CUDA, Triton, CUTLASS/CuTe), when a kernel is slower than expected, and whenever you are about to run Nsight Compute (ncu) or read its output — instead of guessing at the bottleneck, writing your own profiling script, or reading ncu's console tables by eye. One ncu collection, then helpers that extract key metrics, NCU's rule results, per-line stalls (inlined CUTLASS/CuTe/Triton code included) and PM timelines, and a playbook from signals to fixes. Also when a user asks to profile a kernel, read an ncu report or write an optimi...

Firwat Ncu Report Skill op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Ncu Report Skill besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Ncu Report Skill an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/mit-han-lab/ncu-report-skill/tree/main an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Ncu Report Skill benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Ncu Report Skill benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Ncu Report Skill domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Ncu Report Skill gratis?

Jo. mit-han-lab huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇