kernel-autoresearch
A plugin for Claude Code and Codex that makes a GPU kernel or workload faster from one prompt.
By Gaurav Jain (gauravjain14).
The prompt gives the kernel task and the GPU:
- The task: the operation to make fast. Describe it in words (what it computes, the data types, the sizes), or
point at a folder with your code or a challenge's files (
--from FOLDER).
- The GPU: this machine's, or a remote one (
--backend modal:H200:1, --backend ssh:HOST).
- Optional: rules (precision, size limits), an agent budget, and a judge or leaderboard to send results to.
/kar:kar "Make a 4-bit quantized matrix-vector product fast on this machine's GPU: packed 4-bit weights with a
scale and zero-point per group of 128, BF16 input and output, sizes 4096x4096 to 4096x16384, batch 1 and 8.
Agent budget $25."
A team of agents then:
- writes a reference for the operation and a correctness check, and proves the check rejects cheating kernels;
- measures the GPU and works out how fast each input shape could run at best (its roofline floor);
- profiles the current best kernel (nsys, ncu, SASS) and reads the CUDA and PTX documentation;
- proposes changes, with an estimate of each one's gain before it is built;
- builds each change and tests it on the GPU;
- keeps the changes that measure faster and stay correct, and combines them;
- audits the best kernel for bugs the checks miss, and fixes them;
- repeats until the budget is spent or the kernel is close to its floor.
If you have a judge or a leaderboard, results can be sent to it.
The method was developed during the Muse Open Kernel Challenge (H200s, five problems, 7th on the kernels
leaderboard).
Quick start
The repository is the plugin: installing the plugin brings the whole harness with it.
Claude Code
/plugin marketplace add gauravjain14/kernel-autoresearch-plugin
/plugin install kar@kernel-autoresearch
/kar:kar "make the attention kernel in ./attn fast on H100" --from ./attn
(also /kar:kar-status, /kar:kar-judge, /kar:kar-report, /kar:kar-join, /kar:kar-new, /kar:kar-run; the plugin puts
kar on the shell's PATH.)
Codex
codex plugin marketplace add gauravjain14/kernel-autoresearch-plugin
codex plugin add kar@kernel-autoresearch
then ask for it ("use kar to make ./attn fast on H100"); the kar-harness skill runs kar go. Grok and other agents
read the same skill folder, skills/kar-harness/.
A shell, no plugin
git clone https://github.com/gauravjain14/kernel-autoresearch-plugin && cd kernel-autoresearch-plugin
bin/kar doctor # is this machine ready (Python, numpy, torch, cuda-python, GPUs, nsys/ncu,
# agent CLIs, Modal)? Each problem comes with its fix.
bin/kar go "Row-wise softmax over a BF16 [rows, vocab] matrix; vocab 32000 or 128256; rows 1, 8, 64; FP32 math"
bin/kar go "make the MoE layer in this challenge fast on H200" --from ./challenge --backend modal:H200:3 --judge judge.toml
(pip install -e . puts kar on PATH instead.)
What you need on your machine: Python 3.11+ with numpy, one agent CLI (Claude Code, Codex, Grok or Cursor, logged in),
and a GPU: this machine's (torch, cuda-python and the CUDA toolkit's profilers), a Modal account (pip install modal,
modal token new), or an ssh host.
kar go checks the machine, has an agent write the task (mirroring the --from folder when given: its reference,
shapes, score formula, rules, judge), validates it on the target GPU, shows you what "correct" means, proves the
evaluator, and starts a team of four. With no judge, the team keeps closing the gap to speed of light until its
budget or a plateau ends the run. kar report RUN re-checks and re-measures the result. Any MCP client can use
RUN/ws/kar-mcp (the lane commands as tools).
One prompt, measured
One /kar prompt typed in an empty folder, through the installed plugin, on an RTX 4060 Ti with Claude Code agents
(2026-11-11): "Make a 4-bit quantized matrix-vector product fast on this machine's GPU ..." (packed 4-bit weights,
per-group scale and zero-point, BF16 in and out; 4096x4096, 8192x4096, 4096x16384; batch 1 and 8).
| result |
|---|
| task written and validated by the session, evaluator proved (11 cheating kernels rejected) | about 5 minutes |
| first kept kernel (fused tensor-core kernel) | 49.6x the PyTorch baseline, 96.0% of speed of light, 30 minutes in |
| the team's auditor | proved that kernel wrong on extreme finite inputs, with a test the reference passes |
| final kernel (fixed, 2.6% slower; the faster one stays on record with what it fails) | 48.4x, 93.7% of speed of light, passes the stress suite and the team's 2 registered tests |
| cost | $37 of agent use at list prices, 0.11 GPU-hours, 1.6 hours |
What is generic, and how