TensorLean: A New Tool for Formal Verification of GPU Kernels

TensorLean uses Lean to formally verify GPU kernels at the PTX level: 83 of 149 cases correct, 38 defective.
Columbia University and CertiK jointly proposed TensorLean, which uses the Lean proof assistant to perform formal verification directly on production GPU kernels at the PTX level. The report shows that it checked 149 kernel instances, with 83 proven correct and 38 defective, covering mainstream handwritten kernels such as FlashAttention and DeepGEMM. Choosing the PTX level makes the conclusions closer to the actually executed code, but PTX semantic modeling and specification correctness are preconditions. The article notes that 83 reflects tool capability rather than a general kernel error rate, and the specific nature and severity of the defects have not been disclosed. Currently there is only a single-source report, and the tool's adoption cost, false positive rate, and comparison with other approaches are all missing. Its practical significance lies in providing a supplementary line of defense beyond testing for critical kernel paths, and its long-term value lies in demonstrating a path for composable proofs at the PTX level.
When GPU Kernels Become a Black Box: TensorLean's Verification Approach
GPU kernels are the key to the performance of deep learning frameworks. Handwritten kernels such as FlashAttention and DeepGEMM, while pursuing extreme speed, also compress a great deal of complexity into the minds of a few engineers. TensorLean, jointly proposed by Columbia University and CertiK, attempts to pry open this black box with formal methods. According to a report by MarkTechPost, TensorLean performs formal verification directly on production GPU kernels at the PTX level, using the Lean proof assistant to carry the proof process.
This choice is noteworthy. Most formal verification tools work at the source code or intermediate representation level, while PTX is NVIDIA's low-level virtual instruction set, already very close to the hardware. Verifying at the PTX level means bypassing the semantic gap introduced by high-level abstractions and compiler optimizations, so the verification conclusions are closer to the code that actually executes. The cost is that the PTX semantic model itself must be carefully modeled, and this is where the real workload comes from.
PTX (Parallel Thread Execution) is a virtual instruction set architecture defined by NVIDIA, situated between high-level languages such as CUDA C/C++ or Triton and SASS (the actual GPU machine code). When a CUDA program is compiled, nvcc first generates PTX, and then ptxas compiles it at install time into SASS for a specific architecture. PTX is therefore a stable intermediate representation decoupled from specific GPU models, with relatively clear semantics, while retaining the core elements of the GPU execution model such as the thread hierarchy, shared memory, and synchronization barriers. The advantages of formal verification at the PTX level are: it bypasses the syntactic sugar of high-level languages and the complex optimizations of the compiler front end, and can directly correspond to the structure of the actually executed code; at the same time, PTX has complete semantics defined in official documentation, making it more suitable as a modeling target than SASS. The difficulty lies in the fact that PTX is still evolving, different versions of the instruction set differ, and the precise modeling of concurrency semantics such as the memory consistency model and warp-level synchronization itself requires a great deal of work.
Lean is an interactive theorem prover and also a dependently typed programming language, initiated by Leonardo de Moura at Microsoft Research and now developed as an open-source community project. Compared with similar tools such as Coq and Isabelle, Lean has in recent years attracted a large amount of work in formal mathematics and program verification thanks to the rapid expansion of the mathlib mathematics library and a relatively friendly toolchain (such as the Lake build system and VS Code integration). In program verification, Lean is usually used to express the denotational or operational semantics of a program, and then developers write proof scripts, with Lean's kernel gradually checking the correctness of the proof. Lean's dependent type system makes it possible to express "a certain kernel satisfies its specification under any input" as a type, and proving that this type has an inhabitant is equivalent to proving that the proposition holds. This "proofs as programs" property makes the verification scripts themselves composable and reusable, which is also the technical basis for the original article's mention of "accumulating into a shared library."

149 Kernel Instances: 83 Proven Correct
The core data given in the report is very concrete: TensorLean checked 149 kernel instances, of which 83 were proven correct and 38 had defects. The distribution of defects covers well-known production kernels such as FlashAttention and DeepGEMM. This ratio shows two things: formal verification can indeed catch real problems in current handwritten GPU kernels; and at the same time, the correctness of existing kernels is far from reaching a level where they can be "reliable by default."
It is worth emphasizing that "proven correct" here holds under a given specification. If the specification is wrong, then no matter how complete the proof is, it is meaningless. Therefore, the number 83 reflects more that "the tool can handle this batch of kernels and give conclusions" rather than that "one third of GPU kernels are generally wrong." The original material does not elaborate on the specific nature, severity, and triggering conditions of the 38 defects, and these details will directly affect the judgment of the actual value of this work.
Why Lean, Why PTX
In recent years Lean has accumulated a large ecosystem in the field of mathematical formalization, and the maturity of its toolchain has improved markedly. Applying Lean to GPU kernel verification at the PTX level is a relatively novel combination. Its potential benefit lies in the fact that proof scripts are reusable and composable, and the verification work for different kernels can accumulate into a shared library rather than starting from scratch for each project.
From an engineering perspective, the real barrier for such tools is not how many kernels they can prove, but the cost of adoption. If the verification workflow requires rewriting kernels or substantially modifying the build system, it will be difficult for teams to incorporate it into daily development. The report does not provide information on TensorLean's degree of automation, proof length, or human effort, and these are key gaps in evaluating its usability.
In formal verification, a specification is a precise mathematical description of "what a program should do," as distinct from the implementation of "what the program actually does." A verification conclusion that "the kernel is correct" should strictly speaking be stated as "the kernel implementation satisfies its specification." A specification may include: for any valid input, the output is consistent with some reference implementation (such as a mathematical definition on the CPU side) within a given error bound; no out-of-bounds memory access; no data races; and so on. Writing a specification incorrectly or too weakly is one of the most common failure modes in formal verification — the proof process is entirely correct, but the proposition being proved is not what the developer actually wants. The original article's emphasis that "if the specification is wrong, then no matter how complete the proof is, it is meaningless" refers precisely to this point. In practice, writing a meaningful and provable specification for numerical kernels involving softmax such as FlashAttention requires simultaneously considering floating-point error bounds, special value handling, and performance-irrelevant semantic abstraction, which is itself an independent research task.
Practical Significance for Kernel Developers
Bugs in kernels such as FlashAttention and DeepGEMM often manifest as numerical errors under specific shapes and specific dtype combinations, and conventional testing can hardly cover all branches. This is precisely where the appeal of formal verification lies: it provides a guarantee covering all inputs (within the scope of the model), rather than the statistical confidence of sampled testing.
However, there is still a distance between a paper tool and a production workflow. At the current stage, a more realistic positioning is: supplementary verification of critical kernel paths, as an additional line of defense beyond testing. Whether it can become a routine step in CI depends on the tool's response speed to kernel changes and the cost of maintaining proofs.
Positioning from Multiple Perspectives
At present, the public information about TensorLean mainly comes from a single report by MarkTechPost, and no independent team's reproduction or evaluation has yet been seen, so its conclusions should be treated with caution. The confirmed facts are: the tool was jointly proposed by Columbia University and CertiK, works at the PTX level, is based on Lean, and obtained results of 83 correct and 38 defective on 149 kernel instances. As for the specific impact of the defects, the tool's false positive rate, and comparisons with other GPU verification approaches (such as methods based on SMT or symbolic execution), the report does not cover them.
As AI infrastructure increasingly relies on handwritten kernels, it is highly likely that formal verification will move from academia to engineering. The value of TensorLean may lie not in what it proves now, but in the fact that it demonstrates a path for composable proofs at the PTX level.
The SMT-based verification and symbolic execution mentioned in the original article are the two main alternative routes for formal verification of GPU kernels. SMT (satisfiability modulo theories) methods usually encode kernel path conditions as first-order logic formulas and hand them to solvers such as Z3 and CVC5 for decision; the advantage is a high degree of automation and mature reasoning about arithmetic and bit-vectors, while the disadvantage is that when facing loops and complex control flow, a large amount of unrolling is needed or invariant annotations are relied upon, and the state space easily explodes. Symbolic execution, on the other hand, traverses program paths with symbolic values instead of concrete inputs, and is suitable for finding assertion violations on specific paths, but the number of paths grows exponentially with branches, and modeling GPU warp-level concurrency semantics is especially difficult. By contrast, interactive theorem proving routes such as Lean have a low degree of automation and require large human effort, but they can handle arbitrary loops and inductive invariants, and the proofs are composable and the conclusions are fully covering. The trade-offs among the three in engineering deployment are essentially a balance among the degree of automation, scalability, and strength of conclusions.
One-line Summary
TensorLean uses Lean to formally verify GPU kernels at the PTX level: of 149 cases, 83 correct and 38 defective.
Paragraph Summary
Columbia University and CertiK jointly proposed TensorLean, which uses the Lean proof assistant to perform formal verification directly on production GPU kernels at the PTX level. The report shows that it checked 149 kernel instances, of which 83 were proven correct and 38 had defects, with the defects covering mainstream handwritten kernels such as FlashAttention and DeepGEMM. Choosing the PTX level makes the verification conclusions closer to the actually executed code, but PTX semantic modeling and specification correctness are preconditions for the conclusions to hold. The article points out that the number 83 reflects the tool's processing capability rather than a general kernel error rate, and the specific nature and severity of the defects have not yet been disclosed. At present there is only a single-source report, and the tool's adoption cost, false positive rate, and comparison with other verification approaches are all missing. Its practical significance lies in providing a supplementary line of defense beyond testing for critical kernel paths, and its long-term value lies in demonstrating a path for composable proofs at the PTX level.
Related articles

Hero or Luck? Technical Reflections Sparked by an Arizona Grandfather Finding a Missing Toddler in the Desert
An Arizona grandfather finding a missing toddler in the desert hits Hacker News. This article analyzes emergency search, drone thermal imaging, child location devices, and community collaboration, exploring the boundaries of technology and human effort in extreme environments, while noting the material's limitations.

Run Agentic Coding on Mac with One Command: The Localcode Open-Source Tool
Localcode is an open-source agentic coding tool for Mac that launches with a single command. This article examines its local, open-source, minimal-install positioning, who it suits, and the information gaps to consider before adoption.

Lean Formalization of Masullo Manuscript: Progress Map Sparks Discussion
A public progress map for a Lean formalization project of Alessandro Masullo's manuscript sparks Hacker News discussion on formalization costs, collaboration, and AI-assisted proving.