hotkernel
Provides tools for working with NVIDIA GPUs and tooling: reports the card, driver, memory, power limit and compute capability via nvidia-smi, runs commands under Nsight Systems and Nsight Compute and parses the reports, lists the heaviest kernels with ncu throughput/occupancy, and disassembles the PTX or SASS of a cubin (or the latest Triton-cache kernel) with cuobjdump. Also computes a roofline verdict for a given card against the spec-sheet or measured streaming bandwidth.
Integrates with a local PyTorch interpreter to profile and optimize kernels: traces a script's top CUDA kernels by device time via torch.profiler, runs scripts repeatedly to collect their timing line (mean/std/min), and runs baseline vs. candidate interleaved to report speedup and a verdict (faster, slower, inconclusive, incorrect, invalid). Also scaffolds targets from arbitrary PyTorch functions, using their fp32 result as the correctness reference.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@hotkernel profile my training step, find the hot kernel, and speed it up"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
hotkernel
Find the hot kernel, cool it down.
An MCP server that gives your coding agent hands on Nsight and SASS, a verify-and-record contract it cannot fudge, and a kernel-speedrun loop it runs on its own on the GPU on your desk.
English | 中文
Ask Claude to "make this kernel faster" today and it guesses: it cannot see the Nsight report, does not know which kernel eats 60% of the step, has never read the SASS the compiler produced, and cannot benchmark its own rewrite on your card. hotkernel is the missing pair of hands. Ten tools wrap nsys, ncu, cuobjdump, torch.profiler and a strict verify-and-record contract; one skill turns them into a loop: profile, pick the hot kernel, read its SASS, check it against the roofline, rewrite it in Triton, verify against the baseline, record the verdict, keep or revert, repeat.
**Five targets, five autonomous agent runs, one RTX 5090: rmsnorm 3.2× faster than eager PyTorch, softmax 1.2× faster than torch.softmax, gemv level with cuBLAS. Every kernel the agent kept runs at 95–105% of the card's measured streaming bandwidth. Where the library already sat near that ceiling (cuDNN decode attention, tinygemm int4 GEMV), the agent found nothing, stopped on its own, and the board says so.**¹
¹ Each range comes from three independent
verify()calls of the agent's final kernel against the baseline, n=7 interleaved runs each, on one RTX 5090 at 575 W under WSL2. Speedups are relative to the baseline scripts inexamples/: eager PyTorch for rmsnorm,torch.softmaxfor softmax,torch.mv(cuBLAS) for gemv. "Measured streaming bandwidth" is device memcpy on the same card under the same timer, 1501 GB/s (84% of the 1792 GB/s spec), see the calibration. Raw logs for every number are inresults/.

Replay of a real run, rendered from its log: results/softmax/agent-run-20261014-200625. The 1.22× on screen was measured under timing protocol 2; the same kernel re-measured under protocol 3 is 1.17–1.21×.
Install
Claude Code, one command (Claude Code 2.1.275 or later): it adds this repository as a plugin marketplace and installs the plugin, which is the MCP server plus the kernel-speedrun skill.
claude plugin install hotkernel --marketplace xinhuagu/hotkernelInside a session the same is /plugin marketplace add xinhuagu/hotkernel followed by /plugin install hotkernel@hotkernel. The plugin has one option, the Python that has your PyTorch and Triton: set it with /plugin configure hotkernel@hotkernel, or at install time with claude plugin install hotkernel@hotkernel --config hotkernel_python=$HOME/venvs/mytorch/bin/python. Left empty, hotkernel uses the first python on PATH that can import torch, and says so if there is none. The server itself stays torch-free and runs as uvx hotkernel.
Codex and other MCP clients (Cursor, DSH) keep the plain MCP setup:
codex mcp add --env HOTKERNEL_PYTHON=$HOME/venvs/mytorch/bin/python hotkernel -- uvx hotkernelor {"command": "uvx", "args": ["hotkernel"], "env": {"HOTKERNEL_PYTHON": "..."}} in the client's MCP config, plus a copy of skills/kernel-speedrun/ in the agent's skills directory. Claude Code without the plugin works the same way: claude mcp add -e HOTKERNEL_PYTHON=... hotkernel -- uvx hotkernel.
Related MCP server: Flameox
Point it at your own kernel
hotkernel new turns any PyTorch function into a target with the same contract as the examples: the function becomes the baseline, its fp32 result the reference, tolerances default by dtype, and the protocol-3 timer is vendored next to the scripts, so they run in your torch interpreter whether or not hotkernel is installed there.
hotkernel new gelu --from torch.nn.functional:gelu --shape 4096x8192 --dtype bf16 --out targetswrites targets/gelu_baseline.py, targets/gelu_candidate.py (starts as the baseline; this is the file the loop edits) and targets/_hotkernel_contract.py. A function of your own works the same way, with extra inputs in call order: --from ./mykernels.py:fused --extra w:8192. Then bench the baseline for the number to beat, and verify the untouched candidate against it, which must come back inconclusive before anything changed. Agents get the same through the new_target tool. On the reference card the untouched gelu candidate benched at 0.0952 ms and verified inconclusive; a deliberately wrong one came back incorrect.
Before / after
All rows: RTX 5090 @ 575 W, bf16, timing protocol 3, n=7 per verify(); rows with a win are three independent reproductions.
Target | Baseline | Baseline mean | Agent's kernel mean | Speedup | Share of measured bandwidth | Agent time | What the agent wrote |
rmsnorm 4096×8192 | eager PyTorch (5 kernels) | 0.287–0.300 ms | 0.088–0.095 ms | 3.17–3.32× | 95–101% | 10 min, 7 experiments (a second 3-minute run found the same kernel) | one Triton program per row, row in registers, one read and one write |
softmax 4096×8192 |
| 0.107–0.111 ms | 0.090–0.093 ms | 1.17–1.21× | 96–99% | 6 min, 4 experiments | one program per row, max, exp and sum in registers, 8 warps |
gemv 8192×8192 |
| 0.088–0.091 ms | 0.085–0.088 ms | 1.03–1.05×, 2 of 3 runs significant: level with cuBLAS | 101–105%² | 7 min, 3 experiments | autotuned row-block GEMV, 2 rows × 1024 columns per program |
decode attention, 1 token, 32K context, GQA 32/8, d=128 |
| 0.100–0.103 ms | 0.104–0.107 ms | no gain, 5 of 5 runs inconclusive³ | baseline at ~91% | 10 min, 5 experiments (stopped early) | split-KV Triton decode; the kernel itself beat cuDNN, the combine step ate the gain |
int4 GEMV 8192×8192, group 128 |
| 0.032–0.037 ms | 0.036–0.039 ms | no gain, 4 of 4 runs inconclusive³ | baseline at 64–76% | 11 min, 4 experiments (stopped on its own) | Triton GEMV on packed nibbles; about even on medians, behind on means |
² gemv is almost all reads; the copy ceiling is half reads and half writes, so a read-only kernel can sit slightly above it.
³ Rows without a win were not reproduced; the ranges are over the agent's own
verify()calls. Baselines for these two were picked by measuring every library path that runs on this card; the choice is logged inresults/<target>/baseline_choice.json.
Every row on LEADERBOARD.md was written by record(), including the runs that did not win and a deliberately wrong candidate that verify() rejected as incorrect. Each agent run's full transcript is in results/<target>/agent-run-*/.
What the agent gets
Tool | What it does | Needs |
| card, driver, memory, power limit, compute capability |
|
| ridge point for this card; memory- or compute-bound verdict and attainable time for a kernel given flops and bytes, against the spec sheet or the measured bandwidth | nothing |
| top CUDA kernels of a script by device time, via | your torch |
| run a command under Nsight Systems or Nsight Compute, parsed |
|
| the n heaviest kernels from a saved report, with ncu throughput and occupancy | nothing |
| PTX or SASS of a cubin, or of the latest Triton-cache kernel by name |
|
| run a script n times, collect its | your torch |
| run baseline and candidate interleaved, n times each; speedup and a verdict: | your torch |
| write the verify result to | nothing |
| scaffold a target from your own function: baseline, blank candidate and the vendored contract, the same as | nothing |
torch_trace, bench, verify and record work on any machine with PyTorch. Nsight is optional and only makes the picture sharper.
The loop
The skill in skills/kernel-speedrun/SKILL.md is the whole method:
benchthe baseline. That is the number to beat.torch_traceorprofileto find the kernel that actually dominates.rooflinewith the kernel's flops and bytes: memory-bound kernels want fusion, compute-bound kernels want tensor cores and bigger tiles.disasmthe Triton kernel after its first compile: register spills, uncoalesced loads, long dependency chains are all visible in SASS.One hypothesis, one change, then
verify(candidate, baseline, n=7). It returnsfasteronly when the gap beats2 * sqrt(std_b²/n + std_c²/n)and every candidate run passed the correctness check.record()the result, win or lose. It writes the log and the leaderboard; the agent never edits the board. Keep the change only ifrecord()says it beats the run's best so far, otherwise revert.Stop after three changes in a row that do not beat the best, or when the kernel is within 10% of the measured bandwidth floor.
It is autoresearch with kernel wall-clock as the metric instead of training loss.
Measured, not claimed
LLMs writing CUDA kernels have a credibility problem: the AI CUDA Engineer claimed 10 to 100× in 2025 and was found to be bypassing its own correctness checks, and KernelBench exists because "the kernel compiles" and "the kernel is correct and faster" are different things. hotkernel's answer is structural:
The contract lives in the baseline. Shape, dtype, seed, reference, tolerances and the timer are in the baseline file the agent cannot edit; the candidate only supplies a function.
verifyreturnsinvalidif anything in the contract differs.The timer was wrong twice and fixed in the open. Version 1 reused one input and let the 96 MB L2 pose as DRAM. Version 2 flushed L2 by zeroing a buffer and charged every call ~45 µs of someone else's write-backs; the softmax agent noticed that Nsight and
verifydisagreed by 2×. Version 3 rotates buffers larger than twice the L2 and was calibrated against five streaming kernels, which all land at 79–84% of the spec sheet, matching ncu's hardware counters. Old rows are kept and marked as not counted.Wrong is loud.
verifyreports no speedup for a run whoseokis false, every row carries n and std, and the baseline is in the repo so anyone can rerun it.
Platforms
NVIDIA GPU required. Reference card: RTX 5090 (sm_120). The roofline table covers 5090, 4090, 3090 and H100, each with its source; add yours in
src/hotkernel/gpus.py.WSL2 is the reference platform. All nine tools are verified on an RTX 5090 under WSL2 Ubuntu 24.04, driver 617.42:
nsys2026.1.3 andncu2026.2.1 extracted into user space from NVIDIA's apt repo (no sudo),cuobjdumpandnvdisasmstraight from the Triton wheel (no CUDA toolkit needed).ncuneeds the GPU performance-counter permission once (NVIDIA Control Panel, Developer settings). Versions, commands and raw outputs:docs/platform-matrix.md.Native Windows: the server runs (pure Python). If your torch lives in WSL2, start the server through
wsl.exe; the platform matrix has the exactclaude mcp addline.Triton on RTX 50 series: FlashAttention 2/3/4 do not run on sm_120, which is exactly why hand-tuned Triton kernels matter on these cards.
License
Apache-2.0.
Available Tools
10 toolsbenchB
Run a Python script n times in the user's interpreter and aggregate its timing. Contract: the script prints one JSON line to stdout containing at least {"ms": } and optionally {"ok": } for a correctness check. Returns mean/std/min over the n timed runs plus every raw sample, so a LEADERBOARD row can cite n and seed.
Inputs: script (required), n, cwd, args, +2 more.
disasmA
Disassemble a kernel. target is a .cubin/.ptx/.so/.exe path, or 'triton-cache' to search
~/.triton/cache (and TRITON_CACHE_DIR) for the most recent kernel whose name contains
kernel. level: 'sass' (via cuobjdump -sass) or 'ptx' (cuobjdump -ptx / the .ptx file).
A real kernel is 500-3000 SASS lines; max_lines<=0 returns all of them.
Inputs: target (required), level, kernel, max_lines.
gpu_infoA
Identify the GPU(s) in this machine via nvidia-smi: name, driver, memory, power limit, compute capability, max SM clock. Also returns the matching roofline table entry if known.
Inputs: no named parameters.
new_targetB
Scaffold a target from the user's own PyTorch function so the loop can run on it: writes
<out_dir>/_baseline.py (the function as the baseline plus the Target definition:
inputs, seed, fp32 reference, dtype-default tolerances, rotation, timer),
<out_dir>/_candidate.py (the file to edit; starts as the baseline) and the vendored
hotkernel_contract.py (protocol 3) they import, so they run in HOTKERNEL_PYTHON without
hotkernel installed there. from: 'torch.nn.functional:gelu' or './mykernels.py:fused';
shape: the primary input x, e.g. '4096x8192'; extra: more inputs in call order like
['w:8192', 'b:8192'] (random tensors of the same dtype); rotate: inputs that stream through
memory (default ['x']); flops: nominal flops per call for roofline(); reference: a different
'module:function' to run in fp32 as the reference when the baseline cannot run in fp32
(a backend-forced SDPA call, a bf16-only library kernel). For inputs randn cannot draw (a
quantized weight): derive: a 'module:function' from the dict of raw random tensors to the
dict of tensors the call takes, in call order; inputs: the names it returns, e.g.
['x', 'w_q', 'scales'] or 'x,w_q,scales', which become the candidate's signature; reference
is then required and gets the derived inputs as they are (it must do its own fp32 math);
min_bytes: the bytes one call must read (one weight layout), which sizes the rotation K.
Same as the CLI hotkernel new. Then bench() the baseline and verify() the blank candidate
(expect 'inconclusive') before changing anything.
Inputs: from_ (required), shape (required), target (required), atol, +13 more.
profileB
Run a command under Nsight Systems (tool='nsys') or Nsight Compute (tool='ncu') and return the path of the report plus a parsed kernel summary. nsys gives the per-kernel time breakdown; ncu gives per-kernel metrics (achieved occupancy, DRAM throughput, SM throughput) and is much slower, so use ncu_kernel_regex to target one kernel.
Inputs: cmd (required), cwd, tool, out_dir, +3 more.
recordA
Write a verify() result to results//.json, then regenerate
LEADERBOARD.md from every log under results/ (so the table is always reproducible from
the raw files). The Speedup cell is filled only when the verdict is 'faster'; otherwise it
says 'no gain', 'incorrect' or 'invalid'. Call it after every verify(), win or lose; never
edit LEADERBOARD.md by hand. note is the one-line "what changed"; who says honestly
who produced the candidate, e.g. 'agent: running kernel-speedrun unattended' or
'hand-written by during tool bring-up'.
Inputs: target (required), verify_result (required), cwd, who, +1 more.
rooflineA
Roofline for a GPU (default: the first GPU in this machine). Pass the kernel's flops and bytes moved (bench()/verify() return them as roofline_inputs) to get the bound, the attainable TFLOPS and attainable_ms from the spec sheet. Pass measured_mem_gbs (the bandwidth a streaming copy reaches on this card under the repo's timer, see docs/platform-matrix.md; 1501 on the reference RTX 5090) to also get attainable_ms_measured, the floor a kernel can realistically get within 10% of. dtype: bf16 | fp16 | fp8 | fp32.
Inputs: gpu, bytes, dtype, flops, +1 more.
top_kernelsA
Read a saved profile CSV (from profile()) and return the n heaviest kernels. tool='nsys': cuda_gpu_kern_sum CSV -> share of GPU time, calls, avg/med/min/max/std ns. tool='ncu': details CSV -> per-launch duration, achieved occupancy, DRAM / SM throughput %, registers per thread, and a memory/compute/latency hint.
Inputs: summary_csv (required), n, tool.
torch_traceA
Run a Python script under torch.profiler in the user's interpreter. Returns kernels
(real GPU kernels by device time, pct over total kernel time) and ops (aten ops with
input shapes, inclusive time). Works without Nsight installed; use this first.
Inputs: script (required), cwd, top, args, +1 more.
verifyA
Decide whether a candidate script beats the baseline script. Both follow the bench contract (print one JSON line with "ms" and "ok"). Runs them interleaved (baseline, candidate, baseline, candidate, ...) warmup+n times each, back to back on the same card, discards the warmup pairs, and returns mean/std/min for both plus a verdict: 'faster' or 'slower' when |mean_b - mean_c| > 2*sqrt(std_b^2/n + std_c^2/n), 'inconclusive' otherwise, 'incorrect' if the candidate printed ok=false in any run (then no speedup is reported), 'invalid' if the two scripts disagree on shape/dtype/iters/seed or the baseline fails its own check. Also records gpu, driver, power limit, timestamp and the exact commands. Pass the result to record().
Inputs: baseline (required), candidate (required), n, cwd, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool occupies a distinct step in the optimize-measure-record loop, and descriptions explicitly order them (torch_trace 'use this first', profile for nsys/ncu, top_kernels for saved CSVs). The only real overlap is torch_trace vs profile vs top_kernels, all producing kernel-time breakdowns, though the backend/input distinction is spelled out. gpu_info returning a roofline entry also slightly blurs with roofline, but the primary purposes remain clear.
All names are lowercase snake_case with no style mixing. There is a mild convention split between noun-style query tools (gpu_info, roofline, top_kernels) and verb-style action tools (bench, verify, record, disasm, profile, new_target), but this reads naturally and predictably.
Ten tools map cleanly onto the kernel-speedrun pipeline: environment info, scaffolding, tracing, profiling, analysis, benchmarking, verification, and recording. Nothing feels redundant or missing at the count level.
The surface covers the full lifecycle from scaffolding a target (new_target) through measurement (bench/verify/profile) to persistent, reproducible logging (record regenerating LEADERBOARD.md). Minor gaps: no tool to list existing targets/results or inspect history without regenerating the leaderboard, and no way to remove or invalidate a bad record.
Maintenance
Related MCP Connectors
Agent GPU compute scheduling: compare billing, approve budgets, run tasks and persist results.
GPU compute for agents: run commands on an L4/A100/H100, watch logs, billed per second.
On-demand GPU nodes for agents: create nodes, run commands, and submit jobs, billed by the minute.
Train, evaluate, red-team and deploy AI agents: prompt tuning, LLM-judged evals, katas.
Related MCP Servers
- FlicenseNot gradedqualityAmaintenanceEnables coding agents to turn explicit artifacts or commands into bounded local runtime evidence from profilers, benchmarks, trace processors, and direct targets, with typed provenance, coverage, and optional durable preservation. It exposes analysis and capture tools for tracing, profiling, and investigating hotspots in application and native code, GPU kernels, and inference stacks.-
- FlicenseNot gradedqualityAmaintenanceEnables coding agents to trace, profile, and investigate performance hotspots in application code, native code, GPU kernels, and inference stacks by coordinating local profilers, benchmark tools, trace processors, and direct capture targets. Returns bounded, typed runtime evidence with observed inputs, provenance, coverage, and limitations, all through explicit artifact paths or commands with no workspace setup required.-
- FlicenseNot gradedqualityAmaintenanceEnables coding agents to run profilers, benchmark tools, and trace processors against explicit artifact paths or local commands, returning bounded, typed runtime evidence with coverage and provenance for tracing and profiling hotspots in application code, native code, GPU kernels, and inference stacks. Analysis and capture tools also support optional durable evidence preservation and inline replay of stored results.-
- FlicenseNot gradedqualityAmaintenanceEnables coding agents to run bounded local profiling, benchmarking, tracing, and capture workflows against explicit artifacts or commands, returning typed evidence, provenance, coverage, and limitations for investigating application, native, GPU, and inference hotspots.-