mcpField
C
cuda-skill

cuda-skill

github.com/slowlycDevelopment172171 installsUpdated 12w ago
Repository

About cuda-skill

A reference skill for CUDA developers, covering CUDA, PTX, NVIDIA GPU architecture, and profiling and debugging tools. It directs users to local official documentation snapshots and current NVIDIA docs when information is missing or version-sensitive.

Key features

  1. 01Locate official docs by topic
  2. 02Check PTX instructions and constraints
  3. 03Look up CUDA Runtime and Driver APIs
  4. 04Guide correctness debugging and profiling
  5. 05Distinguish architecture and tool versions

Use cases

  1. 01Verify PTX instruction requirements
  2. 02Find CUDA API parameter behavior
  3. 03Debug errors with Compute Sanitizer
  4. 04Profile performance with Nsight tools

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/slowlyc/agent-gpu-skills --skill cuda-skill

After installing, type/cuda-skillin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/best-practices-guide/
1-overview.md
10-memory-optimizations.md
10.1-data-transfer-between-host-and-device.md
10.2-device-memory-spaces.md
10.3-allocation.md
10.4-numa-best-practices.md
11-execution-configuration-optimizations.md
11.1-occupancy.md
11.2-hiding-register-dependencies.md
11.3-thread-and-block-heuristics.md
11.4-effects-of-shared-memory.md
11.5-concurrent-kernel-execution.md
11.6-multiple-contexts.md
12-instruction-optimization.md
12.1-arithmetic-instructions.md
12.2-memory-instructions.md
13-control-flow.md
13.1-branching-and-divergence.md
13.2-branch-predication.md
14-deploying-cuda-applications.md
15-understanding-the-programming-environment.md
15.1-cuda-compute-capability.md
15.2-additional-hardware-data.md
15.3-which-compute-capability-target.md
15.4-cuda-runtime.md
16-cuda-compatibility-developers-guide.md
16.1-cuda-toolkit-versioning.md
16.2-source-compatibility.md
16.3-binary-compatibility.md
16.4-cuda-compatibility-across-minor-releases.md

Details

From the project README

NVIDIA CUDA Reference

Use this skill as the source of truth for CUDA, PTX, NVIDIA GPU architecture, and NVIDIA profiling or debugging tools. Prefer the local official-document snapshots, then verify against NVIDIA's current online documentation when a fact is version-sensitive or absent locally.

For DSL- or library-specific implementation, use the corresponding skill first:

  • Triton or Gluon kernel code: triton-skill
  • CUTLASS, CuTe, or CuTeDSL code: cutlass-skill

Add this skill when those tasks require CUDA API, PTX ISA, architecture, or NVIDIA tool facts.

Locate the references

Resolve the directory containing this SKILL.md, then use its references/ child. Do not assume a Cursor, Claude, or Codex-specific install path.

In examples below, set a task-scoped variable to the resolved absolute path:

CUDA_REFS=/absolute/path/to/cuda-skill/references

Read MANIFEST.md before making version claims. It records the snapshot version, source URL, and document inventory.

Source routing

QuestionPrimary source
PTX syntax, semantics, ISA or target requirementsptx-docs/
CUDA Runtime functions, errors, and structscuda-runtime-docs/
CUDA Driver functions, contexts, modules, VMMcuda-driver-docs/
CUDA programming model and feature behaviorcuda-guide/
General CUDA optimization guidancebest-practices-guide/
Nsight Compute metrics, sections, and CLIncu-docs/, ncu-guide.md
Nsight Systems tracing and CLInsys-docs/, nsys-guide.md
Correctness tools and cuda-gdbdebugging-tools.md
NVTX instrumentationnvtx-patterns.md
Frequent performance mistakesperformance-traps.md

The short guide files are search maps, not substitutes for the full official snapshots.

Query workflow

Start with file discovery. Do not load a large chapter or the whole specification when a focused page exists.

# Discover focused PTX pages.
rg -l -i 'wgmma\.mma_async' "$CUDA_REFS/ptx-docs"

# Read the relevant lines with context.
rg -n -C 12 'Target ISA Notes|PTX ISA Notes|wgmma\.mma_async' \
  "$CUDA_REFS/ptx-docs/9-instruction-set"

# Runtime and Driver API lookup.
rg -l 'cudaStreamSynchronize' "$CUDA_REFS/cuda-runtime-docs"
rg -l 'cuMemMap' "$CUDA_REFS/cuda-driver-docs"

# Programming and optimization concepts.
rg -l -i 'thread block cluster' "$CUDA_REFS/cuda-guide"
rg -l -i 'coalesc' "$CUDA_REFS/best-practices-guide"

For PTX instructions, inspect all of the following before answering:

  • instruction syntax and operands;
  • semantic description and memory ordering;
  • PTX ISA introduction version;
  • target ISA or sm_* requirements;
  • architecture-specific restrictions and undefined behavior.

Keep these four layers separate:

PTX ISA version
  → virtual target accepted by the assembler
  → toolkit/compiler support
  → physical GPU capability

A documented target does not by itself prove that the local toolkit accepts it or that the current machine implements it. For unreleased or preview architectures such as Rubin, verify the current official online documentation.

CUDA API lookup

Search by exact symbol first, then read the containing module and related type pages.

rg -n -C 20 'cudaErrorInvalidValue' "$CUDA_REFS/cuda-runtime-docs"
rg -n -C 25 'cudaLaunchKernelEx' "$CUDA_REFS/cuda-runtime-docs"
rg -n -C 25 'cuCtxCreate' "$CUDA_REFS/cuda-driver-docs"
rg -n -C 25 'cuMemCreate|cuMemMap' "$CUDA_REFS/cuda-driver-docs"

Check parameter lifetime, synchronization behavior, error propagation, version notes, and deprecation status. Do not infer Runtime API behavior from a similarly named Driver API function.

Debugging workflow

Minimize the reproducer, preserve the failing launch configuration, then use the narrowest correctness tool:

compute-sanitizer --tool memcheck ./program
compute-sanitizer --tool racecheck ./program
compute-sanitizer --tool initcheck ./program
compute-sanitizer --tool synccheck ./program

Use debugging-tools.md for tool options and limitations. After a fix, rerun the original workload because sanitizer execution changes scheduling and timing.

Profiling workflow

Use Nsight Systems to locate time and overlap problems, then Nsight Compute to explain one selected kernel.

nsys profile -o report ./program
nsys stats report.nsys-rep --report cuda_gpu_kern_sum

ncu --list-sets
ncu --list-sections
ncu --query-metrics
ncu --kernel-name regex:myKernel --launch-count 1 -o report ./program

Metric names, section identifiers, predefined sets, and report formats can change between releases and architectures. Discover what the active tool supports, then confirm semantics in the latest local Nsight documentation. Do not bind guidance to the machine's installed NCU version.

Base conclusions on measured evidence:

  • timeline placement, launch gaps, synchronization, and CPU/GPU overlap from Nsight Systems;
  • achieved throughput, instruction mix, stalls, memory traffic, occupancy, and source correlation from Nsight Compute;
  • compiler resource usage from ptxas -v or the build log.

Change one hypothesis at a time and remeasure against the same baseline.

Architecture questions

For Ampere, Hopper, Blackwell, or Rubin questions, distinguish public architecture disclosures from ISA availability. Check:

  • cuda-guide/05-appendices/compute-capabilities.md;
  • the instruction's PTX ISA and target notes;
  • ptx-docs/13-release-notes/;
  • current NVIDIA architecture or CUDA release documentation when local snapshots do not cover the claim.

Do not identify a GPU architecture solely from a failed CUDA runtime query or a product label. Use explicit compute-capability or compilation-target evidence when available.

Updating the snapshots

Always scrape into a fresh staging root. --force overwrites matching files but does not delete the output directory or unrelated files.

cd /path/to/agent-gpu-skills
uv run scripts/scrape_docs.py all \
  --output-dir /tmp/cuda-docs-staging \
  --force

diff -qr skills/cuda-skill/references/ptx-docs \
  /tmp/cuda-docs-staging/ptx-docs

Review version changes, page-count changes, renamed files, and representative instruction/API pages before merging. Do not remove obsolete live files without explicit user approval.

Run the repository validator after any update:

python3 scripts/validate_cuda_skill.py

Answer quality

State which document version supports the answer. Cite the focused local file and section when possible. If online verification was required, link the official NVIDIA page and label any inference. Avoid hardcoded performance thresholds unless they come from the user's measurements or a cited document.

Comments

Markdown supported