Skip to content

Verified GPU kernel optimization

Faster GPU kernels. Proven correct before they ship.

Kerneln profiles your PyTorch, Triton and CUDA kernels, has AI rewrite the slow ones, and keeps a rewrite only when it is proven correct and measurably faster. Then it opens the pull request, and your CI holds the line.

Get started Watch the 21-second story

Faster GPU code you can check

One H100 session through Kerneln, on an NVIDIA H100 80GB (RunPod), 23 October 2026: Hazy Research's Llama-3.2-1B megakernel measured at 1.12 ms per token, 1.35× faster than vLLM 0.31 and 7.9× faster than Hugging Face eager (Kerneln also flagged that its output differs at 1.25% of token positions); a Claude rewrite kept at 2.13× with two slower ones reverted; Qwen3-0.6B served at 17.2 requests/s on vLLM; and $2.20 of GPU spend tracked across 37 jobs.

Recorded 9 October 2026: 7.64× verified PR #3 merged re-measured 3.2–4.2× faster (CPU sandbox)

What is Kerneln?

Kerneln is a GPU kernel optimization platform: it profiles PyTorch, Triton, CUDA and ONNX workloads, uses AI to rewrite slow kernels, keeps a rewrite only when a verifier shows it matches the reference (within per-dtype tolerance) and is measurably faster, and ships it as a GitHub pull request guarded by a CI regression gate.

One kernel’s journey

Eight steps from a slow kernel to a cheaper one, recorded end to end.

Everything below happened on 9 October 2026 on kerneln.com, to kernels/attention.py in our demo repository. It ran in Kerneln’s CPU sandbox, so these are CPU numbers. The loop is the same on a GPU runner.

  1. 01Slow kernel
  2. 02Profile
  3. 03Rewrite
  4. 04Verify
  5. 05PR + CI gate
  6. 06Merge
  7. 07Re-measure
  8. 08Cost

01 / 08 · The kernel

A slow attention kernel.

The hot path of a serving stack: multi-head attention, written for clarity. Python loops walk every batch and every head, and the softmax is done by hand.

It is correct. It is also 48 ms per call at batch 32.

File
kernels/attention.py
Shape
8 heads · seq 128 · dim 64
Runtime
PyTorch eager, float32
Where
CPU sandbox
demo-repo · kernels/attention.py
def run(q, k, v):    batch, heads, seq, dim = q.shape    scale = 1.0 / math.sqrt(dim)    out = torch.empty_like(q)    for b in range(batch):        for h in range(heads):            scores = torch.matmul(q[b, h], k[b, h].transpose(0, 1)) * scale            row_max = scores.max(dim=-1, keepdim=True).values            weights = torch.exp(scores - row_max)            weights = weights / weights.sum(dim=-1, keepdim=True)            out[b, h] = torch.matmul(weights, v[b, h])    return out
median latency · pytorch_eager · float32 CPU sandbox
Median latency of the original attention kernel by batch size
batch 1 1.24 ms
batch 8 15.25 ms
batch 32 48.26 ms
Original kernel and its benchmark: PyTorch eager, float32, CPU sandbox on kerneln.com (x86_64, 2 threads, PyTorch 2.5.1+cpu, no network), 9 October 2026.

02 / 08 · Profile

Profiled. The bottleneck has a name.

Kerneln links the file from GitHub and profiles every new version. The op profile ranks where the time goes: aten::mm owns 37.6%, launched 1,280 times by that loop, with aten::exp close behind.

An Amdahl what-if turns the ranking into a plan: what each op is worth fixing, end to end.

Top op
aten::mm · 37.62%
Calls
1,280
Biggest lever
5× mm → 1.43× overall
Profiler
torch.profiler
Op profile · attention.py · batch 8 · float32 · cpu

Self-time hotspots · hottest first

Share of time per PyTorch op
OpSharePercent
aten::mm 37.62%
aten::exp 26.47%
aten::max 10.3%
aten::div 5.19%
aten::copy_ 4.26%
aten::mul 4.09%
aten::sub 3.11%
aten::select 2.97%

aten::mm

Type
MATMUL
Share
37.62%
Total
94.25 ms
Calls
1,280
Likely
COMPUTE-bound
hotspot

Biggest lever

Making aten::mm 5× faster speeds the whole run up 1.43×.

Amdahl what-if, end to end.

Recorded op profile of the original kernel, CPU sandbox on kerneln.com (x86_64, 2 threads, PyTorch 2.5.1+cpu, no network), 9 October 2026. Share of CPU self time.

03 / 08 · Rewrite

AI rewrites it.

Optimize hands Claude the kernel, its profile and its benchmark. Three model calls, three candidate rewrites.

The first one replaces the loops with batched matmuls and an in-place softmax that keeps the same sequence of operations. Plausible is not the bar, though.

Model
Claude Opus
Rewrites
3 (default budget)
Run
#73
Lines
−10 +9
kernels/attention.py · rewrite #1 of 3
3 model calls PyTorch · CPU sandbox −10 +9
@@ def run(q, k, v): @@    batch, heads, seq, dim = q.shape    out = torch.empty_like(q)    for b in range(batch):        for h in range(heads):            scores = torch.matmul(q[b, h], k[b, h].transpose(0, 1)) * scale            row_max = scores.max(dim=-1, keepdim=True).values            weights = torch.exp(scores - row_max)            weights = weights / weights.sum(dim=-1, keepdim=True)            out[b, h] = torch.matmul(weights, v[b, h])    return out     dim = q.shape[-1]    scores = torch.matmul(q, k.transpose(-1, -2))    scores.mul_(scale)    row_max = scores.amax(dim=-1, keepdim=True)    scores.sub_(row_max)    scores.exp_()    denom = scores.sum(dim=-1, keepdim=True)    scores.div_(denom)    return torch.matmul(scores, v)
Python loops over every batch and head become batched matmuls and an in-place softmax with the same op sequence.
Rewrite proposed by Claude Opus (anthropic/claude-opus-5.5 via OpenRouter) in optimize run #73, 9 October 2026. This is the exact change that shipped in PR #3.

04 / 08 · Verify

The verifier proves it, or it doesn’t ship.

Every rewrite must match the reference (within per-dtype tolerance) through five correctness stages, survive an anti-cheat audit for skipped work and ignored inputs, and win a Bayesian speed verdict outside a ±2% noise band.

All three rewrites were correct. Two were slower and were reverted. One was kept: 7.64× faster. Since then the verifier has grown stricter still: hidden input distributions and a peak-memory gate.

Correct
3 of 3
Faster
1 of 3
Kept
rewrite #1 · 7.64×
Best median
3.058 ms
Verifier · attention.py vs reference-attention.py

Correctness gate

  • Smoke test runs, returns finite output pass
  • Shape sweep batch, sequence and head shapes pass
  • Adversarial stability scaled and transformed inputs pass
  • Determinism repeat runs agree pass
  • Edge cases non-power-of-two, boundary shapes pass

Anti-cheat and verdict

  • Fresh inputs no memorized outputs pass
  • Ignored-input check output responds to every input pass
  • Poisoned buffers no reading stale memory pass
  • Speed verdict P(faster) ≥ 95% outside ±2% pass
  • Hidden input distributions inputs the model never sees added since
  • Peak-memory gate no trading memory for speed added since

Every rewrite

1 of 3 kept

Decision for each of the three rewrites
#DecisionCorrectAnti-cheatSpeedup
1 kept pass clean 7.64×
2 reverted pass clean 0.37×
3 reverted pass clean 0.40×

Kept · verified faster

best median 3.058 ms per call

7.64×

Every rewrite in optimize run #73 (CPU sandbox on kerneln.com (x86_64, 2 threads, PyTorch 2.5.1+cpu, no network), 9 October 2026) went through these checks. Hidden inputs and the peak-memory gate were added to the verifier after this run.

05 / 08 · Pull request

A pull request goes up, and CI checks it again.

The kept rewrite arrives as pull request #3, with the full audit in its description. The server checks the PR source byte for byte against the logged model output.

Then the repository’s own CI runs the Kerneln benchmark gate on the change, independently. It passed a minute later.

Opened
18:24 UTC
Gate passed
18:25 UTC
Action
rnx-benchmark
Branch
optimize-73
Pull request #3 · demo repository
open

Optimize attention.py: 7.64× faster (Kerneln run #73) #3

optimize-73 → main · 1 commit · 6e4c9a0

Kerneln rewrote this kernel and verified the result before proposing it.

Speedup: 7.64× on the CPU sandbox (best median 3.058 ms).

Audit table posted on the pull request
RewriteDecisionCorrectAnti-cheatSpeedup
#1KEEPyesclean7.64×
#2REVERTyesclean0.369×
#3REVERTyesclean0.4×

Your CI's Kerneln benchmark gate checks this pull request independently.

Kerneln benchmark gate rnx-benchmark · pytorch_eager · batch 1, 8 · GitHub-hosted runner passed
All checks have passed Merge pull request
Pull request #3 opened by Kerneln on 9 October 2026 at 18:24 UTC; the Kerneln benchmark gate passed at 18:25 UTC.

06 / 08 · Merge

Merged.

A person on the team merged it into main four minutes after it opened. Nothing about how the team ships changed: a branch, a PR, a green check, a merge.

Kerneln’s auto-sync noticed the new version of the linked file and started its profile and benchmark jobs on its own.

Merge commit
e4429b6
Merged
18:28 UTC
Auto-sync
profile + benchmark
Checks
1 passed
demo-repo · main
  1. e4429b6 Merge pull request #3 from optimize-73
  2. 6e4c9a0 Optimize attention.py: 7.64× faster (Kerneln run #73)
  3. 2108517 Reset demo: original attention kernel

Auto-sync · kernels/attention.py

New version on main. Started 2 jobs:

  • Op profile CPU · batch 8 · float32
  • Benchmark eager + torch.compile · batch 1, 8, 32
Merged into main on 9 October 2026 at 18:28 UTC. Auto-sync saw the new version of the linked file and started its jobs.

07 / 08 · Re-measure

Re-measured after merge, by itself.

A separate benchmark compared main against the run from before the merge, in every configuration: 3.2–4.2× faster in PyTorch eager and 1.8–2.4× under torch.compile, each with 0% probability of being slower.

That is lower than 7.64× because it is a different measurement, over more configurations and a second runtime. We publish both.

Eager
3.38× · 4.22× · 3.24×
torch.compile
2.28× · 2.43× · 1.81×
Batches
1 · 8 · 32
P(slower)
0.0%
Benchmarks · attention.py · this run vs baseline
Speedup vs baseline (before merge)1× ·· 4×
Speedup of each configuration after the merge
ConfigurationVerdictSpeedup
pytorch_eager / float32 / b1 3.38×
pytorch_eager / float32 / b8 4.22×
pytorch_eager / float32 / b32 3.24×
torch_compile / float32 / b1 2.28×
torch_compile / float32 / b8 2.43×
torch_compile / float32 / b32 1.81×

PyTorch eager

3.2–4.2×

torch.compile

1.8–2.4×

Benchmark of main after the merge vs the pre-merge baseline run, CPU sandbox on kerneln.com (x86_64, 2 threads, PyTorch 2.5.1+cpu, no network), float32, 9 October 2026. P(slower) was 0.0% in every configuration.

08 / 08 · Cost

The same work, for less compute.

At a fixed price per hour, cost per call moves with time per call. In eager mode the attention kernel now costs about a quarter to a third of what it did per call.

What that is worth to you depends on how much of your GPU time the kernel takes. Put in your own numbers; it is arithmetic, not a promise.

Per call, eager
23.7–30.9% of before
Formula
spend × share × (1 − 1/speedup)
Cost per call · attention.py · PyTorch eager
29.6
23.7
30.9
batch 1batch 8batch 32

Your estimate · not a measurement

spend × share × (1 − 1/speedup) =

$2,000 / month

20.0% of the bill

At a fixed price per hour, cost per call moves with time per call. Indexed from the measured speedups (CPU sandbox on kerneln.com (x86_64, 2 threads, PyTorch 2.5.1+cpu, no network), 9 October 2026). The calculator is an estimate with your inputs, not a measurement.

Proof, with sources

Every number here was recorded.

Three recorded sessions: the demo pull request on 9 October 2026 (CPU sandbox), and two on an NVIDIA H100, on 27 September and 23 October 2026. Each figure carries its date and conditions.
  • No customer logos, testimonials or invented metrics. We have none to show yet.
  • Features waiting for GPU verification never show results.
  • The H100 optimizer baselines were deliberately wasteful test kernels, and we say so.
  • The megakernel is Hazy Research’s, not ours. Kerneln measured it, and flagged that its output differs.
Recorded results with date, context and source
ResultWhat was measured
1.35× Faster than vLLM 0.31 for Hazy Research’s Llama-3.2-1B megakernel (1.12 ms vs 1.51 ms per token; 7.9× faster than Hugging Face eager), measured and checked by KernelnNVIDIA H100 80GB HBM3 SXM (RunPod), batch 1 decode, bf16, 30 runs × 128 tokens. The megakernel is Hazy Research’s; Kerneln measured it. Its next token matched the reference at 98.75% of positions, below Kerneln’s 99% bar, so Kerneln labels it “Differs”Source: Kerneln megakernel run, H100 session 23 Oct 2026 ·
2.13× Claude replaced a chain of about 15 elementwise kernel launches with one Triton kernel; 1 of 3 rewrites kept, the other two were slower (0.41×, 0.52×) and revertedNVIDIA H100 80GB HBM3 SXM (RunPod). Baseline is a deliberately wasteful test kernelSource: H100 session, optimize run ·
17.2 req/s Qwen3-0.6B on vLLM within the latency SLA, 4.2× from batching, time to first token p50 17.4 ms, with correct-answer checksNVIDIA H100 80GB HBM3 SXM (RunPod)Source: H100 session, serving benchmark ·
7.64× Verified speedup of an attention kernel rewritten by Claude; 1 of 3 rewrites keptCPU sandbox on kerneln.com, PyTorch attention, optimize run #73, shipped as PR #3 in our demo repositorySource: Kerneln optimize run #73 and PR #3 ·
3.2–4.2× Faster after merge in PyTorch eager (batch 1/8/32: 3.38×, 4.22×, 3.24×); 1.8–2.4× under torch.compileIndependent re-measurement of main vs the pre-merge baseline, CPU sandbox, float32, P(slower) 0%Source: Kerneln benchmark comparison, 9 Oct 2026 ·
3.48× Claude rewrote an unfused GELU chain into a Triton kernel; 1 of 4 rewrites kept, the other 3 were correct but 0.99× and revertedNVIDIA H100 80GB HBM3 (RunPod). Baseline is a deliberately wasteful test kernel. P(faster) = 1.0, 90% interval 3.42–3.53×Source: H100 dry run, optimize job 46 ·
1.94–2.56× TensorRT fp16 vs PyTorch eager fp16, GELU+linear 1024×1024, batch 1/8/32NVIDIA H100 80GB HBM3 (RunPod), median of 30 timed runs, L2 flushed, clocks not locked (boost characterized), labelled as-deployedSource: H100 dry run benchmark table ·
Rejected TensorRT fp16 was fastest on a transformer block at batch 1, but its max error (0.018–0.023) failed the correctness gate, so eager won among correct variantsNVIDIA H100 80GB HBM3 (RunPod); transformer block d=1024, 16 heads, FFN 4096, seq 512Source: H100 dry run ·

FAQ

Questions, answered directly

What is Kerneln?

Kerneln is a GPU kernel optimization platform. It profiles PyTorch, Triton, CUDA and ONNX workloads, uses AI (Claude) to rewrite slow kernels, keeps a rewrite only when a verifier shows it matches the reference (within per-dtype tolerance) and is measurably faster, and ships it as a GitHub pull request guarded by a CI performance regression gate.

How is Kerneln different from asking an AI assistant to optimize a kernel?

An assistant gives you code and a claim. Kerneln runs every rewrite through a five-stage correctness gate, an anti-cheat audit and a Bayesian speed verdict in a sandbox, keeps only rewrites that pass, shows you every rejected one, and then re-checks the change in CI. You merge evidence, not a claim.

Which frameworks and file types does Kerneln support?

Uploads and linked files can be PyTorch or Triton (.py), CUDA C++ (.cu, .cuh), ONNX (.onnx) and PyTorch checkpoints (.pt, .pth), up to 100 MB. Benchmarks cover PyTorch eager, torch.compile, ONNX Runtime and TensorRT in fp32, fp16, bf16 and fp64.

Do I need a GPU to try it?

No. Profiling, benchmarking and AI rewrites of PyTorch kernels run in Kerneln’s CPU sandbox. Triton and CUDA C++ rewrites, TensorRT, GPU timings and hardware counters need a GPU runner, which you can attach yourself (a RunPod setup script is included).

How does Kerneln know an AI-written kernel is correct?

Each candidate must match the reference across a smoke test, a shape sweep, adversarial input scaling, a determinism check and edge cases such as non-power-of-two shapes, with per-dtype tolerances. An anti-cheat audit then checks provenance, fresh inputs, poisoned buffers and whether the output responds to every input. Only then is speed judged.

Has Kerneln actually shipped a faster kernel?

Yes, end to end, on 9 October 2026: in Kerneln’s CPU sandbox, Claude rewrote a PyTorch attention kernel, Kerneln kept 1 of 3 rewrites as verified 7.64× faster, opened pull request #3 in our demo repository, the CI gate passed, it was merged, and a fresh benchmark measured 3.2–4.2× faster in eager mode and 1.8–2.4× under torch.compile. On an NVIDIA H100, Claude rewrites of deliberately wasteful test kernels were verified 3.48× faster (27 September 2026) and 2.13× faster (23 October 2026).

More answers in the FAQ, and dated release notes in the changelog.

Point Kerneln at your slowest kernel.

Sign-up is open and self-serve. Connect GitHub or upload a file, and get a profile, a benchmark and verified rewrites, without changing how you ship.