Code: github.com/PhilippMarquardt/kernel-development

GPU Kernel Optimization with AI Agents: The Open Kernel Challenge

The Muse Spark Open Kernel Challenge asked participants to make the inference kernels of Meta's Muse Spark Open model faster than SGLang's defaults on a single NVIDIA H200. I jumped into the final week of the kernel track with one rented H200 and spent it directing roughly 40 AI coding agents. I chose what to pursue, checked the benchmarks behind every claim, and approved submissions while the agents wrote kernels, profiling tools, and tests.

Of the five problems, I seriously worked on two and ended up 43rd of 1,747 (top 2.5%, 6.8% behind 1st) on BF16 projections and 60th of 1,426 (top 4.2%, 11.7% behind 1st) on MoE routed experts, finishing 148th of 2,014 overall (top 7.3%).

Score over time for MoE and BF16

The competition setup

Each problem isolates one slice of serving Muse Spark Open on an 8×H200 node, scoped down to a single GPU. Submissions are single Python files timed against SGLang's kernel on the same H200 with identical inputs, alternating between candidate and baseline inside CUDA graphs with a cold L2 cache between replays. Shapes mirror SGLang serving agentic coding workloads (single-token decode and 8-token verify blocks at 1, 16, and 32 concurrent users), and the score is geometric-mean speedup over SGLang.

ProblemWhat it computesFinal scoreRank
BF16 projectionsAttention and MoE-block projections + router (BF16 weights)1.610x43 / 1,747 (top 2.5%)
Routed experts (MoE)Top-8 of 256 experts, NVFP4 weights, SwiGLU, per-expert norm2.512x60 / 1,426 (top 4.2%)
Decoder layerFull layer: projections, attention, router, experts, norms2.283x148
Prefill layerSame layer at prefill shapes, up to 80K context1.827x203
Attention decodeGQA over paged FP8 KV cache, sliding window or full context2.642x216

Precision and semantics are locked down: NVFP4 stays NVFP4, BF16 stays BF16 (lossless repacking only), activations keep SGLang's precision, attention must cover all valid keys, and everything must capture cleanly into a CUDA graph. Each problem allows 10 scored runs and 20 check runs per day. The kernel boards themselves don't carry prize money; the $100,000 pool is for the 8×H200 serving track that opened afterward.

One detail you have to keep in mind when reading leaderboard numbers is run-to-run variance. Board scores keep your best run, and the exact same file fluctuates by ~1.5–2.5%:

ProblemSame file across runs
MoE2.451 – 2.512
Decoder layer2.237 – 2.283
Attention2.603 – 2.642
Prefill1.790 – 1.827

The middle of each leaderboard is packed tight. On the decoder layer, 2.247 to 2.283 jumped roughly 130 places (from ~275th to ~145th), whereas near the top a 1.5% gain moves you far less.

Why we had to build kdev

Like most participants, we started from the strongest public engines (primarily alygg77's and vjeux's, credited in the files). On its own, the public MoE engine sat around 200th place (and slid to 228th as others improved), and BF16 started at 122nd:

ProblemPublic engine baselineFinal submissionRank
Routed experts (MoE)2.366x (~200th, low 228th)2.512x (~2.49 repeat level)60th
BF16 projections1.539x (122nd)1.610x (~1.60 repeat level)43rd

The biggest early sinkhole wasn't kernel math, it was bad local benchmarking. Coding agents happily iterate on whatever timing script is in front of them, and we burned several days chasing phantom wins before fixing our measurement stack. Over three days, the agents built kdev (~31,000 lines of Python, 458 tests) specifically to bake the judge's exact setup into the defaults. Every major default corresponds to a bug that bit us:

Benchmarking mistakeWhat went wrongkdev default
Local builds with nvcc 12.8 while judge ran CUDA 13.012.8 serialized attention tensor-core ops (491 µs locally vs 357 µs on judge), steering us toward the wrong designPinned to judge toolchain, recorded in build metadata
Flushing L2 by writing a bufferDirty lines wrote back during the timed kernel (+1–2.5 µs on small kernels), inflating apparent headroomRead-based L2 flush matching the judge
Timing candidate and baseline separatelyUnderstated real speedups by ~2x and flipped a keep/drop decisionInterleaved A/B timing with paired ratios and bootstrap CIs
Testing MoE on 5 fixed expert routingsA candidate looked 3 µs faster locally while running 6 µs slower on real routing distributionsFresh pool of 100 routings per benchmark
Background warmups running outside the lockNoisy stalls that looked like regressionsExclusive GPU lock that waits until no other CUDA process is active

We also tuned kdev's CLI output for agent context windows: every command prints a ~40-line summary and a run ID, tucking raw samples, SASS disassembly, %globaltimer per-block timelines, register/spill counts, and roofline charts into a run directory that agents can page through as needed. Alongside it sat an append-only experiment ledger (~650 entries by the end of the week) and a shared notes board so newer agents could check what had already been tried without overwriting earlier numbers.

MoE routed experts: where the time actually went

On paper, MoE routed experts looks memory-bound because it streams 4-bit weights for top-8 of 256 experts. A measured roofline quickly showed that pure byte streaming plus routing and one barrier already matched the leaderboard leaders, meaning the real gap was compute overlap and synchronization overhead.

We still tried three ground-up MoE kernel rewrites, and all three failed their gates (the best hit 0.70x of our top public-based file). All three started from a naive bytes / bandwidth + const mental model tuned on a local RTX 5070 Ti, which needs 4.5x less bandwidth per SM than an H200. Fitting runtime against active expert count on the H200 separated streaming rate from fixed overhead and showed why:

MoE kernelCost per expertEffective rateFixed overhead
Best public-based file7.15 µs3.96 TB/s10.5 µs
Rewrite "nk"9.02 µs3.14 TB/s11.0 µs
Rewrite "nk", compute disabled6.49 µs4.36 TB/s9.1 µs
Rewrite "fk2"–3.8–3.9 TB/s27–29 µs

nk streamed fast enough when compute was turned off, but its math wasn't overlapping the memory pipeline. fk2 streamed fine too, just behind a 27–29 µs fixed launch/setup wall. Earlier, dividing total bytes by total time had smeared both effects into a fake "2.4 TB/s bandwidth wall" and sent an entire investigation in the wrong direction.

What actually moved the MoE score from ~200th to 60th was splitting off lean, specialized engines for the small batch sizes, where a general-purpose MoE kernel pays for scheduling machinery it doesn't need and where 1 µs at batch 1 moves the geometric mean as much as 8 µs at 32 users. Measured on 96–120 real routings against the public engine:

Custom engineSpeedup vs public engineMain change
1-token decode1.15xSingle-pass kernel without big-batch scheduling
1-user verify (8 tokens)1.06xLosslessly repacked expert scales to 5 bits to stream fewer bytes
32-user decode1.02–1.03xTrimmed epilogue from 9.7 µs down to 2.5 µs

Before any MoE candidate went to the judge, it had to pass tens of thousands of poisoned-buffer checks, timeout guards, cloned-input runs, and hundreds of CUDA graph replays per shape with zero mismatches. (The final file did retain one scratch-buffer zero-initialization invariant inherited from the public base, which I noted explicitly.)

BF16 projections: sweeping the cheap knobs

BF16 projections consists of 30 independent shapes from 1 to 256 tokens, and we were already within 4–7% of 1st place, making it the highest-leverage track to push. I put four agents on disjoint batch-size ranges, one strategist modeling where the leaders were likely ahead, and a coordinator merging per-shape winners after same-hour A/B checks.

Nearly all of the climb from 122nd (1.539x) to 43rd (1.610x) came from systematic tuning rather than exotic kernels: exhaustive cuBLASLt algorithm pins, per-shape dispatch routes, and small router tweaks. Flashier ideas got cut quickly by measurement. A lossless 12-bit weight packing scheme came in at 0.895x on a key shape and was dropped, and several register-pressure proposals turned out to be physically impossible once checked against SASS and register limits (for instance, a 2-warpgroup consumer design hit a hard 96-register ceiling at 576 threads).

H200 hardware numbers we measured

To stop guessing at roofs, we ran microbenchmarks on the H200 and used the measured constants inside kdev's roofline model:

  • Weight streaming follows T = 1.7 µs + bytes / 4.62 TB/s, with no real-weight access pattern exceeding ~4.7 TB/s. Plain vectorized loads won; TMA 2D box loads topped out around 4.0 TB/s, and L2 prefetch hints slowed streaming down by ~25%.
  • The compute core peaked at 6.91 TB/s-equivalent at N = 8, dropping to ~2.0 at N = 128 where tensor cores saturate. Small-N tensor-core instructions took 45–59 clock cycles rather than 32.
  • Launch and sync overhead came out to ~1.7 µs per extra small CUDA graph node, 2.6–2.9 µs per stream split even with programmatic dependent launch, 1.3–1.5 µs for cooperative launches, and ~0.65 µs for a dependent cold DRAM round trip.
  • Cold data-TLB misses cost ≤ 0.03 µs and cold instruction cache 0.07–0.16 µs, so page-touch tricks weren't worth pursuing.
  • TMA multicast only paid off using relaxed remote barrier arrives (per-SM delivery rose from 46 to 75 bytes/clock across cluster sizes 1, 2, and 4); release barriers were 3x slower, which explained why earlier runs had written off multicast.

Managing ~40 agents on one GPU

Coordinating that many agents over a single GPU required strict operational rules. Every timed run acquired the exclusive GPU lock, while compilation was forbidden under the lock so a 5-minute nvcc build wouldn't starve the machine. A watcher script checked GPU utilization, lock queues, and stalled agents every 20 minutes, and re-scanned GitHub and the leaderboard every 3 hours to diff new public baselines against our per-shape timings. Every idea got a written pass bar, kill bar, and time cap before any code was written, and only I approved scored judge submissions.

Even with that structure, plenty of subtle failure modes popped up during the week:

  • Premature "at the floor" claims: agents declared both MoE dequant and cuBLAS ("at the 754 TFLOP wall") near optimal, and both claims were later disproved by a public weight re-layout and by cuBLASLt algorithm pins. After that, no floor claim counted without an instruction-level SASS breakdown and an exhaustive knob sweep.
  • Over-prioritizing big rewrites: early on we jumped straight into megakernels and barrier-free rewrites before doing the boring work (judge-checking the baseline, sweeping library knobs, reading SASS). Reversing that order saved huge amounts of time.
  • Echo-chamber reviewers: reviewer agents that received our full history mostly suggested 1–2% tweaks to our current approach. Spinning up clean-sheet reviewers that saw only the problem spec and public per-shape times was what surfaced genuinely different ideas.
  • Lossy handoffs: when agents hit context limits and rotated out, successors inherited vague notes like "dead" without the exact variant or numbers, nearly causing us to skip valid alternatives. Recording exact configs and measurements in the append-only ledger fixed that.
  • Compiler and harness surprises: nvcc hoisted a __restrict__ load above the wait for a preceding kernel (corrupting eager-mode runs ~50% of the time) and hoisted a weak load out of a spin loop (causing hangs). One decoder-layer submission silently fed BF16 instead of FP32 activations into the router for small batches, passing all unit tests and only turning up via a competitor's notes. Another test script ran 1/40th of its claimed call count and exited 0 even when printing FAIL, caught only by reading the test source. And the judge itself has undocumented submission filters: files over 1,000,000 bytes are rejected, as is anything containing subprocess, even in a comment.

The kernel track wrapped up on November 4. The $100k serving track on a full 8×H200 node runs through November 19, and I'm carrying kdev and the same measurement workflow straight into that.