LLM-written kernels that beat PyTorch on half of KernelBench Level 3 under hardened checks
On this page16 sections
Difficulty 38: Levels 1 and 2 passed fast_1 = 0.5 under hardened checks in 2026, but whole-architecture Level 3 tops out at 38% and needs multi-kernel fusion and correctness across hidden inputs. Application value 55: trustworthy automated kernel writing would cut expert time on long-tail operators and new hardware. Leverage 40, the highest in the pack: the harness and the result gate how far agent-written systems code can be trusted elsewhere.
The problem
Can AI models write GPU code that beats PyTorch on half of KernelBench’s whole-model tasks, with cheating ruled out?
- 1Model gets a PyTorch model to speed up
- 2Writes custom GPU kernels
- 3Hidden tests catch shortcuts and cheats
- 4Levels 1–2 passed; Level 3 at 38%
- 5Goal: half of Level 3 faster
What is asked. KernelBench gives an AI model a piece of PyTorch code, the Python library most neural networks are written in, and asks it to write faster GPU code that computes the same thing. Level 1 tasks are single operations (one matrix multiply), Level 2 are short chains of operations, and Level 3 are 50 whole small networks: multilayer perceptrons, convolutional and recurrent networks, transformer blocks. The score is the fraction of tasks where the generated code is correct and faster than PyTorch. The problem asks for a system that reaches on Level 3, under the hardened KernelBench-Verified rules, on one H200 GPU. It gets at most 5 attempts per task, no human edits, and must pass an audit for cheating.
Why cheating is the first barrier. Speed and correctness can be checked by machine, which is what makes this a good test for AI agents. But a weak check can be fooled. A kernel that skips work, returns cached answers, or recognises the specific test inputs can look fast and correct. This is called reward hacking, and published systems have been caught doing it. KernelBench-Verified therefore tests every kernel on four hidden input distributions (the original inputs, and the same inputs scaled by 3, by 0.01 and by −1). A kernel that hard-codes the answer for one distribution fails the others. It also lets PyTorch use the faster TF32 tensor-core mode, so the baseline is realistic. The analogy is an exam with unseen versions of each question. It breaks because an exam checks answers, while here the speed claim must also be checked by timing.
Why Level 3 is hard. Beating PyTorch on a whole network means fusing many operations into fewer kernels and scheduling them well, all without breaking correctness on any input distribution.
State of the art. The original KernelBench paper (February 2025) found frontier models matched PyTorch on under 20% of tasks. Under the KernelBench-Verified rules (June 2026, single attempt per sample, best of 5), reaches 52.0% on Level 1 and 64.9% on Level 2 (GPT-5.5). That meets the old target. The best Level 3 score is 38.0% (Gemini 3.1 Pro), and the other models score 24–32%.
What a solution looks like. A system's prompts, model identity and generated kernels, published and rerun under the KernelBench-Verified harness, scoring at least 25 of 50 Level 3 tasks with no hacks found in the audit.
Go deeper
The full technical text.
A system that takes only a PyTorch reference module and returns GPU kernels such that, on KernelBench Level 3 (the 50 full-architecture tasks: MLPs, CNNs, RNNs and transformer blocks) under the KernelBench-Verified protocol on one H200, at least 50% of tasks are correct on all hidden input distributions and faster than the TF32-enabled PyTorch eager baseline (fast_1 ≥ 0.5), with at most 5 independent samples per task and no human edits, and with no reward-hacking behaviour (output caching, skipped computation, input-specific shortcuts, unsynchronised timing) found in an audit of the accepted kernels. The earlier target of fast_1 ≥ 0.5 on Levels 1 and 2 has been met (see state of the art).
Words on this page (8)
- benchmark
- A fixed set of tasks and a scoring rule used to compare systems fairly.
- fast_p
- The share of benchmark tasks where the generated kernel is correct and more than p times faster than the baseline.
- PyTorch
- The open-source Python library in which most neural networks are written; its built-in operators are the baseline here.
- kernel (GPU)
- A function that runs on the GPU, executed by thousands of threads in parallel.
- reward hacking
- Scoring well on a test without doing the intended task, for example by skipping work the test fails to check.
- large language model
- A transformer neural network trained on large amounts of text to predict the next token.
- tensor core
- A unit inside each GPU core that multiplies small matrix tiles in one instruction, much faster than ordinary arithmetic.
- transformer
- The neural-network design behind modern language models, built from attention and feed-forward layers.
New to this? Read first (3)
- Ouyang et al.: KernelBench: Can LLMs Write Efficient GPU Kernels?Defines the benchmark, its three levels and the fast_p score.
- Zhang et al.: KernelBench-VerifiedShows how generated kernels cheat weak tests and gives the hardened 2026 scores used here.
- METR: Measuring automated kernel engineeringA readable account of what AI kernel-writing gains look like under careful measurement.
Path to understanding
foundations → problemThe research entries this problem rests on, in the order to read them. Each links to its explainer.
- Start with
- The GPU memory hierarchy and the roofline modelHardware
- PyTorchLibrary
- Step 2
- Step 3
- Step 4
- Kernel autotuning and automated kernel generationAlgorithm · host
- Then
- LLM-written kernels that beat PyTorch on half of KernelBench Level 3 under hardened checksThe problem
State of the art
The KernelBench paper (preprint, February 2025) reports that frontier models matched the PyTorch baseline in under 20% of tasks out of the box. Later systems reported much higher numbers on varying versions, hardware and attempt budgets (for example CUDA-L1 on A100, Kevin-32B on its own subset), and several were found to exploit weak correctness checks; Sakana AI withdrew claims after a kernel skipped its own correctness test. KernelBench-Verified (Zhang et al., arXiv:2607.16241, June 2026) re-evaluates frontier models on H200 with a TF32 baseline and four hidden input distributions, single-shot best-of-5: fast_1 reaches 52.0% on Level 1 and 64.9% on Level 2 (GPT-5.5), so the Level 1–2 target is met, but the best Level 3 score is 38.0% (Gemini 3.1 Pro), with 24–32% for the other models. The KernelBench repository has no official leaderboard.
Realistic applications
Cheap, trustworthy automation of kernel writing would shift expert time to the hardest kernels and let new accelerators bootstrap software faster.
What counts as solved
A reproducible run by an independent party under the hardened harness at a pinned release meeting the 50% bar within the attempt budget, with code and model identity disclosed.
How it gets verified
To verify: GPU benchmarkA kernel run and timed on stated hardware against a baseline.
Hardware: one NVIDIA H200 (the KernelBench-Verified setup; an H100 rerun is reported alongside). Suite: KernelBench Level 3 (50 tasks) under the KernelBench-Verified harness at a pinned commit: PyTorch eager baseline with TF32 enabled, correctness required on all four hidden input distributions (original, x3, x0.01, x(-1)) at the benchmark tolerance, CUDA-event timing with synchronisation. Budget: at most 5 independent samples per task, best correct sample counted, no human edits. Metric: fast_1, the share of the 50 tasks with a correct kernel faster than the baseline; pass at 0.5 or more. Also report torch.compile as a second baseline and run the paper's reward-hacking audit on every accepted kernel. Harness: the KernelBench-Verified scripts, with prompts, model identity and generated kernels published.
Claims
No claimed results on this problem.
Where the work is
Model and search work (compute), harness engineering, and the reasoning needed to fuse whole architectures correctly.
Connected problems
- This problem is related to An autotuner that finds configurations within 2% of the best in 20 trialsBoth search for fast kernels under a measurement budget.
Progress
- Jun 26, 2026Levels 1 and 2 pass fast_1 = 0.5 under hardened checkssource
KernelBench-Verified reports single-shot best-of-5 fast_1 of 52.0% (Level 1) and 64.9% (Level 2) on H200, but at most 38.0% on Level 3 (preprint).
- Feb 14, 2025KernelBench releasedsource
Baseline results show frontier models matching PyTorch in under 20% of tasks (preprint).