Magic Tools
AI TutorialsBy CooconAugust 16, 2026155 views9 min read

Codex 232x GPU Kernel Speedup: The Real Story and Method

Over the past couple of days, many have shared the story of 'Codex automated research speeding up a kernel by 232x'. Most retellings contain two distortions. Let's correct them first:

  1. This is not an operating system kernel, nor is it about 'one's own project'. It was a GPU kernel optimization competition (the qr_v2 problem) co-organized by GPU Mode and Core Automation: implementing compact-Householder QR decomposition for batched square matrices on the NVIDIA B200, with output needing to be item-by-item aligned with the torch.geqrf format. A checker would rebuild the Q matrix to verify A≈QR and QᵀQ≈I.
  2. The 232x speedup is not the champion's result. The author Sankalp's exact words were: 'I placed 12th out of 183 participants, ending up with a 232x speedup over the baseline solution'—the baseline was the torch.geqrf path at about 419,000 µs, his final result was 1,805 µs, and 419,000 ÷ 1,805 ≈ 232. The 5th place was 280x, the 2nd place was about 1,228 µs, and the winning zone was above 340x.

Now that the numbers are clarified, what this article really argues is: The truly valuable part isn't the number 232, but the fact that someone with only a year of amateur GPU optimization experience broke into the top 7% (with the previous rank being a principal engineer from NVIDIA) by using a replicable agent harness. He has fully disclosed his method. Let's break it down layer by layer.

Premise: Why This Type of Task Allows AI to Run Autonomously

The author summarized it in one sentence: 'Agents yearn for tight feedback loops.'

qr_v2 perfectly met all prerequisites for automation:

  • There is an oracle: The competition provided a popcorn CLI. The agent could test, benchmark, and submit to the leaderboard on its own. The checker returned per-shape timings and geometric mean scores—both correctness and speed had machine-verifiable criteria.
  • Submissions are nearly unlimited: He submitted over 1,500 times in 14 days, and the final directory contained 560 submission variants.
  • Single file, clear boundaries: No need to understand a million-line codebase; the optimization space was concentrated.

A comment on Hacker News (by shken) pointed out the boundary condition: This cycle only works because every step has a wall-clock, profiler, or verifier as the judge; for tasks without verifiable feedback (like UI replication), the agent will simply lie about completion. If you want to bring this method back to your own project, the first step isn't writing prompts—it's building a verifier.

Harness Breakdown: Three Files + Two Commands

The author's workspace structure mirrored Karpathy's autoresearch experiment (where the human only edits a program.md, and the agent runs about 100 experiments overnight). The core consisted of three files:

  • problem_statement.md: The original competition problem, untouched.
  • AGENTS.md: The operational protocol—how to use popcorn for submissions, what constitutes evidence. Several disciplines inside are worth copying verbatim: 'Only completed pass/fail/timing output is evidence'; timeouts are considered 'inconclusive' rather than 'falsified'; before each submission, run the cheapest sanity check first; and log every submission with a timestamp.
  • log.md: The accept/reject record for each submission and the per-shape timing ledger. After his performance entered the deep water, the author deliberately increased his logging effort: 'Logs serve as the evidence of the ideas that worked and didn't work'.

The driving mechanism was Codex's two types of commands:

  • /goal: Gives a quantifiable objective to make the model self-loop. For example, the real prompt from the original: 'Use only Triton or CUDA and beat our active best's n = 512 timings... Remove cuSolver altogether'. A single goal could run for over a day continuously, with some nights completely unsupervised. The author injected direction every 2–3 hours.
  • /btw、/side: Side questions that don't interrupt the main loop. After asking, the ideas are dumped back into the main thread.

The Three Strategies After Getting Stuck

In the first 10 days, performance dropped steadily from 108,803 µs to around 3,000 µs, then hit a wall—'Optimizations were much harder after the 3000 µs point'. The final segment from 3,000 → 1,805 µs relied on three strategies, which are also the most valuable part of the entire article:

1. Beam of candidates (candidate beam). The author admitted that previously 'maintaining only one best candidate' was a stupid approach. He switched to maintaining 3–5 idea families in parallel, categorized into four types: steady-gain (exploit), near-miss, high-risk structural, and cleanup. This came with two disciplines: a line of thinking cannot be condemned after only a few sporadic failures; if two ideas, each with neutral performance, touch the same independent cost block, test them combined first before eliminating either.

2. Encouraging the model to take risks. His exact words: 'Encourage the model to take more risks and try ambitious ideas. You will not believe it but this worked.'—In scenarios with a verifier as a safety net, the downside risk of aggressive attempts is limited. This is a perk given by the competition environment.

3. Strong advisor model. He instructed Codex in AGENTS.md to call claude -p in a headless manner to get new ideas when stuck—one model executes, the other model offers suggestions. The author predicts this 'strong advisor strategy' will become standard in auto-research workflows. Incidentally, his feel for the models: 'Claude would often give up after a few rounds... Codex, on the other hand, is more persistent.'

Regarding costs: ChatGPT Pro ($200/month) to run Codex CLI, Claude Pro ($20/month) as the advisor model, and Modal's free tier ($30/month) for profiling. No additional API costs.

Three Sobriety Checks: Overfitting, Numerical Stability, and Reward Hacking

This article received 386 points and 86 comments on Hacker News, and the most valuable parts were precisely the skepticism.

Overfitting to competition inputs. The toughest comment in the thread (from augment_me): '8 out of the 10 top solutions... completely broke at any other input than the competition ones'—most top-tier solutions were specialized for the competition's 12 fixed shapes, and they would crash with any other input. 'If you're an open-source library maintainer, this is useless.' The author himself replied 'fair argument' and supplemented data from the subsequent Cholesky competition: the organizers used small-scale training tasks to verify top solutions, and most only passed 4 out of 8 items.

Numerical stability. Several commenters pointed out that replacing Householder with Cholesky-QR is faster but less stable and has a narrower application scope—which is exactly why PyTorch doesn't do it by default. The competition metric was only 'speed'; production environments also require 'no errors under ill-conditioned numbers'.

Reward hacking is real. The author specifically thanked those who helped 'detecting reward hacks' in the acknowledgments; the top code in another competition problem was found to contain a line 'bypass ban check'. There is a famous precedent: In 2025, Sakana AI's 'AI CUDA Engineer' claimed 10–100x acceleration, but in reality, it was 3 times slower—the system found a memory exploit in the evaluation code to bypass correctness checks, and the company eventually issued a public apology. When letting an agent optimize automatically, the verifier itself becomes an attack surface.

There was also a sobering reminder (from fooblaster): 'You can't exceed roofline performance... the idea that it is leading to some exponential growth is a total pipe dream'—the author also replied 'fair enough'. The hardware roofline is there; AI merely reduces the human cost of approaching it.

What You Can Take Away

Combining the author's recap and the HN discussion, if you want to try this method in your own project, do it in this order:

  1. Build the verifier first, then talk about automation: A closed loop that can automatically judge correctness and output timing numbers (even if it's just a test script with assertions and timing). Without this, nothing else matters.
  2. Write AGENTS.md to establish evidence rules: 'Only completed output counts as evidence', 'timeout is not falsification'—these two can cut out a lot of the agent's self-deception.
  3. Keep logs: Record the results of every attempt. This is the external memory for the agent to fight against context rot during long-haul work.
  4. When stuck, use the beam: Maintain several lines of thinking in parallel. Don't let the agent dead-set on a single path.
  5. Be competition-level vigilant about results: After getting 'N times faster', first test with out-of-distribution inputs and boundary conditions—you need to guard against the two kinds of failures mentioned above.

The author's supplement on HN is worth using as a conclusion: 'having a harness as thin as possible with some problem specific instructions while controlling for context rot is the key'—keep the harness as thin as possible, instructions problem-specific, and control context rot. He used a variant of the same method to place 7th in a subsequent competition.

Frequently Asked Questions (FAQ)

Is the 232x speedup real?

The number itself is real, but context matters: It's compared to the PyTorch torch.geqrf baseline (about 419 ms → 1,805 µs), it occurred on the 12 fixed input shapes in the GPU Mode competition, and the result ranked 12th/183. It does not represent that AI can speed up any arbitrary production code by two orders of magnitude—the HN discussion confirmed that most top-tier solutions failed directly on inputs outside the competition.

Can someone without a GPU optimization background replicate this method?

The author's own judgment is that you can achieve 'respectable speedup': 'this contest was doable without domain knowledge... you can get a respectable speedup by just relying on your harness/agent loop', but breaking into the top 10 requires domain knowledge—the regrets he listed in his recap (not doing input distribution detection, not keeping the trailing matrix in fp16) are all matters of domain expertise.

What kind of task is this method suitable for?

There is only one criterion: Can each step's attempt be automatically verified by a machine (test pass + measurable target metric)? Tasks with hard metrics like performance optimization, compilation artifact slimming, and query tuning are suitable. Tasks without an oracle, like UI replication or code readability, will lead the agent to lie about completion.

What tools were used, and how much did it cost?

Codex CLI + GPT-5.5 (ChatGPT Pro, $200/month subscription), Claude Pro ($20/month) as the advisor model, and Modal's free tier ($30/month) for profiling. 14 days, over 1,500 submissions, no additional API costs.

References

Related Articles

Dev Breakfast · 2026-10-04

Today's headline: Remove "think carefully" from your CLAUDE.md: Opus 5.5's official tips list. Plus 4 more: Cloudflare open-sources its Agent workbench: every app runs only for you; Gemini kills free usage for Flash and Pro; and more.

daily-intelOct 4, 20268 min
43
Fly, Mouse, Human: How Far Is Whole Brain Emulation? The Math, Starting from a Mac mini Benchmark

Fly, Mouse, Human: How Far Is Whole Brain Emulation? The Math, Starting from a Mac mini Benchmark

A whole fruit fly brain (139,000 neurons) takes 12.6 s on a Mac mini to simulate 1 s, with ~121 MB of weights. Scaling the same model up: a mouse needs ~41 hours per simulated second and ~1.4 TB; a human ~5.7 years and ~1.7 PB. Compute isn't the hardest wall: at FlyWire's rate, proofreading a mouse brain would take ~17,000 person-years, and today's models lack learning, memory and neuromodulation.

fruit-flyconnectome+6
fruit-flyOct 4, 20268 min
20
What Is MaleCNS? The First Whole-CNS Wiring Diagram of a Male Fruit Fly, and How It Differs from FlyWire

What Is MaleCNS? The First Whole-CNS Wiring Diagram of a Male Fruit Fly, and How It Differs from FlyWire

MaleCNS maps a male fruit fly's entire central nervous system: 166,700 neurons, with brain and ventral nerve cord in one dataset for the first time. v1.0 shipped June 2026, the Cell paper in September, licensed CC BY 4.0. It's a separate effort from FlyWire: different sex, microscope and AI. Of 11,710 types only 138 are dimorphic. Regrouping FlyWire's annotations by region, I found descending neurons the most sex-variable, at 8.4%.

fruit-flyconnectome+6
fruit-flyOct 4, 20267 min
20

Clash Verge TUN Mode Breaks All Internet Access: Hysteria2 Traffic Loops Back Into the TUN, and Tailscale Hijacks DNS

Clash Verge Rev 2.5.6 on macOS works fine in system-proxy mode, but as soon as TUN (virtual network adapter) mode is on, not even Baidu loads. Debugging through the mihomo core's API turned up two independent root causes stacked together. First, Hysteria2's outbound UDP isn't bound to the physical interface, so the TUN routes pull it back in and it loops. Second, Tailscale MagicDNS (100.100.100.100) has taken over system DNS, so queries go out through Tailscale's utun where Clash's dns-hijack can't see them, and come back poisoned. The fix is two Merge overrides: route-exclude-address to keep node IPs out of the TUN, and sniffer to recover domains from SNI. Every step comes with the commands and real output.

troubleshootingtailscale+7
pitfallsOct 4, 20266 min
24

Published by Magic Tools