cuda-kernel-optimizer

An iterative performance-tuning workflow for CUDA, CUTLASS, or Triton kernels. A kernel is a small program that runs many times on a graphics processor to perform a computation.

In plain words
What is it for?
Use it to optimise .cu or Triton kernel files, benchmark alternatives, inspect GPU performance reports, and identify which changes improved the result.
Why use it?
It compares candidate implementations against a reference, measures their performance, and checks whether claimed changes appear in the generated machine code.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/kernelflow-ops/cuda-optimized-skill/cuda-kernel-optimizer
Any agent
npx skills add KernelFlow-ops/cuda-optimized-skill --skill cuda-kernel-optimizer
Clone the repo
git clone --depth 1 https://github.com/KernelFlow-ops/cuda-optimized-skill

Made for: Claude Code, Codex.

Per session 198 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,658 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00198 $0.03658
Opus 5 $0.00099 $0.01829
Sonnet 5 $0.00040 $0.00732
Haiku 4.5 $0.00020 $0.00366

Measured 2d ago against content hash 3db640895c97, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cuda-kernel-optimizer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 13 executable files (scripts/ablate.py, scripts/benchmark.py, scripts/branch_explore.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/cuda-kernel-optimizer/SKILL.md · 346 lines

How it starts

The opening of the file, as written. The whole thing — 346 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CUDA Kernel Iterative Optimizer (v2 — Roofline-Driven)

What this skill does

Given:

  • a baseline kernel file (.cu for CUDA / CUTLASS, or .py for Triton),
  • a reference Python file (exposes reference(**kwargs) — same contract as benchmark.py --ref),
  • kernel dimension arguments (e.g. --M=4096 --N=4096 --K=4096),
  • optional iteration count N (default 3), ncu_num (default 5), and branches (default 4),

the skill runs a roofline-guided, branch-and-select iterative optimization loop and produces a timestamped directory of per-iteration artifacts plus a final summary.

Key point

  1. Roofline-driven axis budget: compute/memory/latency axis budgets are allocated proportionally to measured Δ gaps, with a per-axis cap of 2.
  2. Branch-and-Select: each iteration generates K candidate kernels (hyperparameter/implementation variants), benchmarks all, selects champion.
  3. Ablation attribution: after selecting champion, each method is individually ablated to determine its actual contribution.
  4. SASS verification: cuobjdump --dump-sass confirms claimed optimizations actually appear in generated code.
  5. Every iteration produces a full ncu report on the champion kernel.

Inputs the skill expects from the user

Before starting, confirm you have:

  1. Baseline operator file, e.g. ./gemm.cu or ./gemm_triton.py
  2. Reference file, e.g. ./ref.py (required — correctness validation depends on it)
  3. Dimensions — kernel-signature scalars like --M=4096 --N=4096 --K=4096
  4. Iteration count N (default 3)
  5. ncu_num — how many top metrics to extract per axis (default 5)
  6. branches — how many hyperparameter variants per iteration (default 4)

benchmark.py is bundled at scripts/benchmark.py; all scripts default to it automatically.

If any of these are missing, ask the user once — briefly — then proceed.

The loop at a glance

0. check_env          → env.json (GPU, nvcc, CUTLASS, ncu)
1. init run folder    → run_YYYYMMDD_HHMMSS/
2. copy baseline      → baseline/ + bench once to seed `best`
3. for i in 1..N:
     a. profile best_kernel with ncu (--set full)  → iterv{i}/best_input.ncu-rep
     b. extract top compute/mem/latency            → ncu_top.json
     c. roofline.py: compute Δ_c, Δ_m, Δ_l        → roofline.json + axis_budget
        if near_peak (all Δ < 0.15) → early stop
     d. Claude picks methods (b_axis per axis, cap=2) → analysis.md (CoT)
     e. Claude writes K branch kernels (same methods, diff hyperparams)
     f. branch_explore.py: compile + bench all K   → select champion
     g. if champion FAIL: regenerate (max 3 retries)
     h. ncu profile champion (--set full)          → iterv{i}/kernel.ncu-rep
     i. ablate.py: single-method rollback bench    → attribution.json
     j. sass_check.py: verify SASS signatures      → sass_check.json
     k. update state with attribution + SASS results
4. emit summary.md

Read the full file on GitHub · 346 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 346 lines · 0 tokens per session scan A 3db640895c97

Subscribe to this mod's changes

cuda-kernel-optimizer is a skill published in the GitHub repository KernelFlow-ops/cuda-optimized-skill (202 stars, last pushed 4mo ago), licensed MIT. It adds 198 tokens to every session and 3,658 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens