Spaces:
Running on Zero
A newer version of the Gradio SDK is available: 6.19.0
title: OUROBOROS Kernel Mint
emoji: πͺ
colorFrom: green
colorTo: yellow
sdk: gradio
sdk_version: 6.17.3
app_file: app.py
pinned: false
license: mit
short_description: A 1B model writes GPU kernels. A referee checks them.
tags:
- track:backyard
- track:wood
- sponsor:openbmb
- sponsor:modal
- sponsor:openai
- achievement:offbrand
- achievement:welltuned
- achievement:sharing
- achievement:fieldnotes
- achievement:offgrid
- achievement:llama
- tiny-titan
- best-agent
- minicpm
- triton
- gpu-kernels
- reinforcement-learning
- self-distillation
πͺ OUROBOROS Kernel Mint
Build a GPU operation out of blocks. A 1-billion-parameter model writes a real Triton kernel for it. Then a referee that can't be talked into anything decides whether the kernel is real, and times it against PyTorch's own compiler. Beat the compiler and you land on the leaderboard.
The point of the whole thing is that the green tick is earned. Nothing here is self-reported. Every kernel gets compiled, checked against PyTorch on nasty inputs, and benchmarked before it counts.
How to play
- Build. Snap blocks together (a normalization block, an optional residual, and one activation), or just pick a classic like softmax or swiglu. The numbers flowing through the machine update as you go, so you can see what each block does.
- Mint. A fine-tuned MiniCPM5-1B writes a fused Triton kernel for your machine. It drafts a
few attempts. Each one faces the referee: compile, check correctness against PyTorch, then
time it against PyTorch eager,
torch.compile, andtorch.compilemax-autotune. Attempts that fail are shown, not hidden. Two ways to run it: Local (offline) does the whole loop inside this Space with no cloud calls, and Pro mints with the 27B on Modal. Both modes use the same three-baseline comparison. - Beat the compiler. If your kernel is correct and faster than
torch.compilemax-autotune, it goes on the board. The crowns up top were minted by the 27B model. Switch on Pro mode to mint with that bigger model yourself.
The first mint of a session takes about 90 seconds while the model wakes up (the backend scales to zero when nobody's using it). After that it's a few seconds. There's a "watch a real mint" button that replays a recorded, verified run instantly, so you can see the whole loop without waiting.
Why bother
A GPU kernel is the small program that runs one step of a neural network on the graphics card. Fusing several steps into one kernel cuts trips to memory, and that's where a lot of real inference speed comes from. Writing them well is expert work, which is why PyTorch ships a compiler to do it for you.
The bet behind this project: the part that's actually scarce isn't the big model, it's a verifier the model can't fool. Give a small model a referee where correctness is a yes/no and speed is a measurement, let it learn from its own verified wins, and it gets good. The referee that scores your kernel in this Space is the same one that trained the models.
The numbers (all checked by the harness, none typed in by hand)
- The larger Qwen3.6-27B run produced 76 verified compiler-beating kernels on H200. 69 of them held up across 5 fresh re-benchmark runs (mean of means 1.30x, range 1.11x to 2.04x across this reproducible set; a single live mint on the board can read a little higher). The other 7 are single-shot probes on problems the model had never trained on.
- On a 376-cell grid of shapes and dtypes, the trained kernels keep a 1.49x geomean against max-autotune recompiled per cell. About 10% of cells are losses, and those are listed per cell rather than swept under the rug.
- They also beat hand-written expert kernels (Liger, Unsloth, the Triton tutorial) on swiglu, rmsnorm, relu2 and geglu. softmax and layernorm come out as ties within noise.
- The referee defends itself. A 30-case self-test passes good kernels, rejects subtly wrong ones, and blocks three specific ways of gaming the benchmark. It's green on a 4090 and an H200.
To be clear about what these are: reproducible scheduling wins on memory-bound fusion ops against the compiler's autotuner. They are not wins over cuBLAS or FlashAttention, and they're not new algorithms.
How it's built
- Models. OpenBMB's MiniCPM5-1B is the default smith (it really is 1B). Qwen3.6-27B is Pro mode. Both were fine-tuned with the same loop: supervised training on verified kernels, then RL where the only reward is the referee's verdict. No human labels anywhere.
- Modal does both the training and the serving. The 27B was trained on Modal H200s (the RL
run peaks around 110 GB of VRAM), and the live backend runs on Modal with scale-to-zero. The
interactive Modal backend re-benchmarks the selected verified kernel against PyTorch eager,
torch.compile, andtorch.compilemax-autotune before returning a result. - Local (offline) mode. Flip the toggle and the whole loop runs inside this Space: the 1B
writes the kernel with llama.cpp on the Space's own GPU, and the in-process referee compiles it,
checks it against PyTorch, and times it against eager,
torch.compile, andtorch.compilemax-autotune. No Modal call, no cloud model API. It handles the named ops and single-activation machines; Pro mode keeps the 27B and the same three-baseline comparison on Modal. - Frontend. One Gradio Space. The whole interactive part is a custom JavaScript machine-builder bridged to Python, so it doesn't look like stock Gradio.
- Verifier. An immutable Triton/PyTorch harness: allclose against PyTorch on adversarial inputs, CUDA-event timing against max-autotune, plus checks for memoization and input mutation so a kernel can't cheat the benchmark.
Links
- π€ The 1B smith: YMRohit/ouroboros-kernelsmith-minicpm5-1b
- π€ The 27B smith: YMRohit/ouroboros-kernelsmith-qwen3.6-27b
- π€ Verified kernel corpus + evidence reports: YMRohit/ouroboros-kernel-corpus
- GitHub repo with Codex-attributed commits: ymrohit/ouroboros-kernelsmith
- π Field notes (what we built and learned): FIELD_NOTES.md
- π Hugging Face blog: The Referee Is the Product
- π§Ύ Modal evidence: 27B Modal results
- π¬ Demo video: OUROBOROS Kernel Mint on YouTube
- π£ LinkedIn post: Build Small hackathon submission
- π£ Social post: on X / Twitter
- π£ Hugging Face post: OUROBOROS Kernel Mint
Built for the Hugging Face Build Small hackathon, targeting Backyard AI and Thousand Token Wood. MIT licensed. Making small models fast is a problem for anyone who runs them locally, which is most of the reason I built it.