Agentic Kernel Optimization for All — automated GPU kernel optimization for any kernel, any hardware, any language.
$ npx -y skills add tongminglaic/ako4all --agent claude-code
Table of Contents
AKO4ALL is automated GPU kernel optimization, packaged as a single Claude Code skill. Drop a kernel into your working directory, invoke the skill, and the agent bootstraps a workspace in place and iteratively rewrites the kernel for maximum performance — profile, edit, benchmark, repeat, until the kernel stops getting faster. The skill is a single SKILL.md protocol document; other coding agents can drive the same loop by following it directly.
AKO4ALL vs AKO4X — two sibling projects with different framings.
Reach for AKO4ALL when you just want a kernel optimized; reach for AKO4X when you want infrastructure around the optimization.
A kernel and at least one set of test inputs are required. Everything else is optional.
get_inputs(), or raw data files (.npz, .bin, shape lists, etc.) that the agent wires up itself. The agent assembles whatever is provided into something the bench script can call.Clone the repo directly into Claude Code's skills directory:
git clone https://github.com/TongmingLAIC/AKO4ALL.git ~/.claude/skills/ako4all
Or, if you already have it cloned somewhere else, symlink it:
ln -s /path/to/AKO4ALL ~/.claude/skills/ako4all
Open Claude Code in a directory containing your kernel, then ask it to optimize the kernel. Files in the working directory are inspected automatically; you can also point at external paths. Optional constraints — iteration cap, language preference, dependency policy, etc. — included in the prompt will be merged into HINTS.md.
The skill presents a resolved plan, asks if anything is genuinely ambiguous, and starts iterating. You can interrupt at any point to redirect.
If you want the conventional layout the skill recognizes:
<workspace>/
├── source/ # Kernel + optional reference and inputs
│ ├── kernel.py
│ ├── reference.py # Optional
│ └── inputs.py / data.npz ... # Optional — input data, any format
├── bench/ # Your own benchmark script (optional)
│ └── ...
├── knowledge/ # Reference materials (optional)
└── HINTS.md # Agent directives (optional)
These are conventions, not requirements. If your files are organized differently, just point Claude at them.
For optimizing several related kernels in parallel, in Claude Code the main agent can spawn one subagent per kernel via the Task tool.
⚠️ Subagents can't ask back. In Claude Code, subagents lack
AskUserQuestion. The main agent composes each subagent's prompt from your instructions plus what's in each kernel's directory; any decision you don't pin down there will fall toSKILL.mddefaults. So include the things you care about (per-kernel paths, optional reference / inputs locations, language or iteration-cap constraints, custom branch names) — and let the rest default.
ncu) — recommended; its version must match your CUDA / PyTorch CUDA build. If unavailable, the loop still proceeds (no profiling — the agent reasons from runtime stats instead).Note: During the loop the agent may run
pip install/apt installetc. to fill in missing dependencies. A container or virtual environment is recommended for isolation; to forbid installs, add a directive toHINTS.md(see Agent Behavior) or restrict via Permissions.
The agent creates an opt/<kernel> branch, copies your kernel to solution/, and generates scripts/bench.sh to wrap your benchmark. After verifying the baseline (and profiling it with ncu if available), it iterates: edit solution/ → benchmark → log → commit. After 3 stagnant iterations it re-profiles, plans the next direction, and continues. Defaults like the stall threshold live in HINTS.md; iteration history lives in ITERATIONS.md. See SKILL.md for the full protocol.
Driven by Claude Opus 4.8 (1M context, max thinking effort), on four FlashInfer-Bench inference operators AKO4ALL rewrote the reference into Triton kernels that all beat FlashInfer's strongest expert kernel — geomean speedup over the FlashInfer expert on NVIDIA B200, all correctness-passing:
| Operator | Speedup vs FlashInfer expert | Workloads |
|---|---|---|
| GQA paged decode | 1.36× | 48 |
| MLA paged decode | 1.21× | 47 |
| MLA paged prefill | 1.50× | 38 |
| RMSNorm h128 | 1.12× | 14 |
All four operators we ran are shown here — we time-boxed this round to four kernels, so these are not the best four cherry-picked from a larger sweep.
What one kernel takes to optimize — a typical run, end-to-end from the initial prompt to the agent finishing:
| End-to-end | Input | Output | Cache read | Cache write |
|---|---|---|---|---|
| ~55 min | ~15k | ~253k | ~17.6M | ~752k |
A single drop-in skill — competitive-with-expert kernels in under an hour, from a single prompt.
A few defaults worth knowing:
ncu runs on the baseline before iter-1 and again after 3 stagnant iterations.To adjust any of this — or to add your own directives (optimization constraints, dependency policies, iteration caps, ...) — edit HINTS.md in your workspace. The file is self-documenting.
The optimization loop involves running shell commands (compiling, benchmarking, profiling). By default, most coding agents prompt for approval on each command. To run fully unattended, grant the necessary permissions through your agent's configuration.
For Claude Code, the simplest option is to bypass all permission checks:
claude --dangerously-skip-permissions
Create .claude/settings.local.json:
{
"permissions": {
"allow": [
"Bash(*)", "Read(*)", "Write(*)", "Edit(*)",
"Glob(*)", "Grep(*)", "Agent(*)",
"WebFetch(*)", "WebSearch(*)"
]
}
}
ako4all is a Claude Code plugin with 1 hand-picked skill, indexed on Flowy in the Code Generation category. Install it with the command on its page. It includes AKO4ALL. Its skills do not fire on their own yet. Request auto-invocation to have Flowy route them as you prompt. Free and open source.
Is this plugin yours?
Claim it with GitHubSubmit a pluginPromote it