Researchers use Lean to prove AI-written GPU kernels correct and safe
Unicorn News Desk ·
Key facts
- Paper
- Proving LLM-Generated GPU Kernels Correct and Safe (arXiv 2610.24548)
- Authors
- Archibald Browne, Eugene Lee, Cristopher Salvi
- Published
- 2026-10-17
- Correctness tool
- Velvet, a verifier embedded in Lean
- Safety tool
- VerCors, a deductive verifier for parallel code
Three researchers, Archibald Browne, Eugene Lee and Cristopher Salvi, describe a framework in which an AI agent writes a GPU kernel and then proves, inside the Lean proof assistant, that the kernel computes exactly what its high-level specification says. The paper, published on 17 October 2026 under the Programming Languages subject, also has the model prove that the kernel is thread-safe and free of data races, using a second verifier called VerCors.
The work lands in a growing area of interest: as AI systems get better at producing fast, low-level GPU code, the hard question shifts from “can it write the kernel?” to “how do we know the kernel is right?” Industry groups have been asking the same thing in public talks this year.
What the Lean-based framework does
The paper starts from how machine learning models are usually built. Development begins with a high-level specification written in an automatic differentiation framework such as PyTorch, JAX or TensorFlow. That specification is then lowered to a target backend, either by a compiler or by a research engineer writing the code by hand. The authors study whether frontier language models can take over that second, manual job: generating GPU kernels from high-level benchmark specifications.
A GPU kernel is the small, heavily optimised routine that runs in parallel across thousands of GPU threads, for example a matrix multiply or an activation function. Getting it fast is hard; getting it fast and correct is harder, because subtle indexing or synchronisation errors may only surface on certain inputs or hardware.
The framework attacks correctness with two separate proofs:
- Semantic equivalence in Lean. A language-model agent uses Velvet, described as a program verifier for imperative programs embedded in Lean, to prove that the generated CUDA kernel and the high-level specification compute the same result, under an explicit set of assumptions.
- Thread safety in VerCors. The framework also asks the language model to prove thread safety and data race freedom of the generated kernel in VerCors, which the authors describe as a deductive verifier for parallel code.
Lean is a proof assistant: a programming language and checker in which mathematical statements are written down and every step of a proof is verified by a small trusted core, often called the Lean kernel. Unicorn API covered another recent use of Lean in the Lean community’s certification of a Claude-assisted proof; this paper applies the same style of machine-checked reasoning to production-style code rather than pure mathematics.

Why floating-point proofs matter here
The authors frame their main contribution narrowly and specifically. They say they show that “a combination of Lean automation and language-model-guided proof construction can verify a broad set of basic neural-network building blocks over floating-point values, allowing LLMs to implement semantically correct and safe kernels”.
Floating-point arithmetic is the number format GPUs use for neural network math, and it does not behave like the real numbers taught in school: rounding means that reordering additions, for instance, can change the result. That makes it a notoriously awkward target for formal proofs, and many verification efforts simplify by reasoning about idealised real numbers instead. The paper’s claim is that its proofs work over floating-point values directly.
A second design choice concerns trust. According to the abstract, “floating-point verifications never rely on compiled code and are always checked via the Lean kernel”. In plain terms, the final say on whether a proof holds comes from Lean’s checker, not from running the generated program and observing outputs. The language model can propose proof steps, but it cannot talk its way past the checker.
| Item | As stated in the paper |
|---|---|
| Kernel language | CUDA |
| Specification sources | High-level benchmark specifications; models typically begin in PyTorch, JAX or TensorFlow |
| Correctness proof | Semantic equivalence via Velvet, embedded in Lean, under explicit assumptions |
| Safety proof | Thread safety and data race freedom via VerCors |
| Number format | Floating-point values |
| What checks the proofs | The Lean kernel, never compiled code |
| Scope claimed | A broad set of basic neural-network building blocks |
How it compares with Gimlet Labs’ kernel checker
The paper is not the only effort this year to bring formal methods to AI-generated kernels. Gimlet Labs, which says it runs inference across heterogeneous hardware and needs correct, performant kernels on several platforms, has described an early system with a different design.
Gimlet’s approach lowers both the reference model and the generated kernel to a common representation, then uses Z3 to validate that they are mathematically equivalent, or returns a concrete counterexample when they are not. Z3 is an automated solver: rather than building a step-by-step proof the way Lean does, it searches for an input that breaks the claimed equivalence. Gimlet says the approach complements traditional numeric tests by finding “fundamental structural mismatches not caught by existing testing”.
Jubi Taneja presented that work, described as a tensor algebra equivalence checker, at the ARRAY workshop at PLDI 2026. In her post about the talk, she framed the problem directly:
AI can generate highly optimized GPU kernels, but how do we know they’re correct?
She added that there is a “long way to go in building trust in AI-generated kernels”. Taneja later gave a GPU MODE talk on GPU kernel formal verification on 18 September 2026, promoted with the question of whether GPU kernels could be proved correct “instead of relying on testing alone”.
Side by side, the two efforts differ in emphasis, based on how each source describes them:
- Proof engine: the paper builds proofs checked by the Lean kernel; Gimlet uses the Z3 solver.
- Failure output: Gimlet highlights returning a concrete counterexample when equivalence fails; the paper’s abstract does not describe counterexample output.
- Concurrency: the paper adds a separate VerCors proof of thread safety and data race freedom; the Gimlet description focuses on equivalence with the reference model.
- Who writes the proof: in the paper, the language model helps construct the proofs alongside Lean automation.

Where the field is gathering
The research community around this topic has been visible at PLDI 2026, a major programming languages conference. Beyond the ARRAY workshop, the PAgE’26 workshop was held on 15 June in Boulder, Colorado, with a programme its lead organiser, Shraddha Barke, described as covering formal methods for AI, agentic code reasoning and debugging, and making agentic systems more reliable.
Gimlet Labs’ framing of why this matters is pragmatic: “As AI agents get better and better at autonomously generating optimized kernels, building trust in their correctness becomes the next bottleneck to deploying them in production”. The Browne, Lee and Salvi paper takes a step further along the same line by asking the AI agent not only to write the kernel but to supply the proof as well.
What it means for builders
For teams that write or tune their own GPU kernels, or that are experimenting with AI agents to generate them, the direction is clear even if the tooling is early. Numeric testing compares outputs on sample inputs and can miss cases it never tries. Formal verification aims to cover every input that satisfies the stated assumptions. Gimlet describes its checker as a complement to numeric tests, not a replacement, and that is a reasonable way to read the paper too.
Practical takeaways from what the sources describe:
- Assumptions are part of the result. The paper proves equivalence “under an explicit set of assumptions”. A proof is only as useful as those assumptions are realistic for a given deployment, so anyone adopting this kind of method will need to read them.
- Two kinds of bugs, two checks. Computing the wrong answer and racing on shared memory are different failures; the paper treats them with different tools.
- The model is a proof assistant, not the judge. Language models help construct the proofs, but the Lean kernel checks them.
- Heterogeneous hardware raises the stakes. Gimlet’s motivation is that each workload needs correct kernels on several platforms, which multiplies the code that must be trusted.
Limits and open questions
The evidence here is a paper’s own abstract, and several things that builders would want to know are not stated in the sources:
- Coverage numbers. The abstract claims a “broad set of basic neural-network building blocks” but the source text gives no count of kernels attempted or proved, and no failure rate.
- Which models. The paper refers to “frontier language models” without the source naming them.
- Performance. The sources do not say how fast the verified kernels run compared with hand-tuned or compiler-generated code, or how long proofs take to construct.
- Gap to the hardware. The paper verifies CUDA source against a specification; whether properties carry through compilation to what runs on the GPU is not addressed in the source text.
- Availability. No release, licence or packaged tool is described in the sources. For Gimlet’s work, a commenter on Taneja’s post asked whether a paper was available, and the company later pointed to a technical blog.
- Independent replication. None of the sources show third-party evaluation of either approach.
What to watch next
The next signals worth tracking are concrete numbers: how many kernels these methods can prove, how many they reject, and how many real bugs they catch that tests missed. Gimlet says its checker finds structural mismatches that existing testing does not; published counts of such cases would make that claim measurable. For the Lean-based framework, watch for released code, the list of verified building blocks, and whether the approach extends beyond basic neural-network operations to the larger fused kernels used in production inference. Further talks in venues like GPU MODE and PLDI workshops are likely places for that evidence to appear first.
Frequently asked questions
What does it mean to formally verify a GPU kernel?
It means proving mathematically that the kernel does what its specification says, rather than only testing it on sample inputs. In the paper, an AI agent uses Velvet, a verifier embedded in Lean, to prove a generated CUDA kernel is semantically equivalent to a high-level specification under explicit assumptions.
Does this handle floating-point math?
Yes, according to the authors. They say their combination of Lean automation and language-model-guided proofs can verify a broad set of basic neural-network building blocks over floating-point values, with checks done by the Lean kernel rather than relying on compiled code.
Does it check for data races?
Yes. The framework also asks the language model to prove thread safety and data race freedom of the generated kernel in VerCors, a deductive verifier for parallel code.
How does this compare with Gimlet Labs' kernel checker?
Gimlet Labs describes a system that lowers a reference model and a generated kernel to a common representation and uses the Z3 solver to show they are equivalent or return a counterexample. The paper instead builds proofs in Lean and adds a separate thread-safety proof in VerCors.
Can developers use this today?
The sources describe a research framework in a paper and do not state a release, licence or packaged tool, so availability is an open question.