Auto-research with codex: How I achieved a 232x Faster Kernel
Scaling Performance: Achieving a 232x Speedup in QR Kernels via Auto-Research
Originally posted on sankalp's blog on July 8, 2026
📌 Introduction
Recently, GPU Mode, in partnership with Core Automation, organized a competition centered around the concept of "auto-research." The objective was to develop a highly optimized implementation of batched square compact-Householder QR factorization (more commonly known as QR decomposition).
Out of 183 competitors, I secured 12th place, ultimately producing a kernel that was faster than the provided baseline.
"Some might dismiss this as mere
'loop engineering', and frankly, I'm okay with that."
In this post, I'll detail my methodology, the hurdles I encountered, and the insights I gained. Note: You don't need a PhD in linear algebra to follow along; I've prioritized the research process over the raw mathematics.
For those interested in the specifics, you can find the Problem Link and Leaderboard here. This was part of the Linear Algebra Kernels in the Age of Research series.
🛠️ Problem Breakdown
The Technical Goal
We were tasked with processing a batch of square CUDA matrices with dimensions . The goal was to produce a compact Householder representation identical to the output of torch.geqrf(A).
The required outputs were:
- An matrix: The upper triangle contains , and the lower triangle stores the Householder vectors.
- A vector: Containing the reflector coefficients.
Verification Process
The checker validated the results by reconstructing using torch.linalg.householder_product(H, tau) and extracting . The following conditions had to be met:
Constraints and Benchmarks
The leaderboard ranked submissions based on the geometric mean of runtimes across various matrix sizes and conditioning scenarios.
| Matrix Size () | Importance |
|---|---|
| Primary benchmark | |
| Large-scale stress tests |
While internal computations could utilize lower precision (e.g., FP16, FP8, or NVFP4), the final factors had to pass accuracy checks.
A Concrete Example ()
Consider the matrix :
In this scenario, is orthogonal (unit-length, perpendicular columns) and is upper triangular (zeros below the diagonal). The compact Householder method allows us to map the first column to in a single reflection.
🤖 Why This is "Auto-Research-able"
The contest environment was specifically designed to be agent-friendly. By providing the popcorn CLI, participants could automate the cycle of testing, benchmarking, and submitting.
The organizers allowed nearly unlimited submissions, provided they were spaced out to avoid crashing the Modal credit pool or clogging the queues.
🎓 Learning to Ask Better Questions
I entered this contest as an underdog. While I've spent a year learning GPU optimization (Triton and some CUDA), I am not a professional in the field. To put this in perspective, the person just above me on the leaderboard was a principal engineer at NVIDIA.
Aura farming aside, my strategy relied on converting unknown unknowns into known unknowns. The more domain knowledge I acquired, the more effectively I could prompt LLMs.
My Learning Roadmap
- Understand the basics of QR Decomposition.
- Compare Gram-Schmidt vs. Householder reflections.
- Research the Blocked Householder algorithm.
- Study the trailing WY-update architecture.
Through iterations with Claude and various educational videos, I realized that the Blocked Householder approach was the only viable path to high performance.
Real-World Application
This isn't just a contest exercise. Matrix decompositions are critical for modern LLM training optimizers that use preconditioning, such as:
- Shampoo-style optimizers: Which utilize these decompositions for scaling.
- Muon (used by Kimi): Which treats weight updates as matrices rather than flattened vectors.

🚀 The Path to Breakthroughs
The process involved a constant battle against local maxima. I had to introduce idea diversity to ensure the agent didn't just optimize a mediocre approach.

The "Codex-maxxing" Workflow
I spent hours letting the system iterate. At one point, the process looked like this:


By generating a "beam" of different candidate implementations, I could explore multiple optimization paths simultaneously.

🏁 Conclusion & Reflections
What I could have improved:
- Better initial theoretical grounding: Spending more time on the math before coding might have reduced early wasted iterations.
- More aggressive precision experimentation: I could have pushed the boundaries of
NVFP4further.
Ultimately, this experience proved that while domain expertise is a massive advantage, a robust auto-research loop combined with strategic LLM prompting can allow an underdog to compete with the best in the field.
References & Acknowledgements:
- GPU Mode & Core Automation for the contest.
- The open-source community for Triton/CUDA resources.