Researchers at CertiK and Columbia University published TensorLean on November 20, a system that formally verifies the GPU code that actually runs inside AI training and inference stacks, and reports having found dozens of real defects in libraries the industry treats as settled. The work was detailed in Chinese by 机器之心 on November 23, with the technical report credited to co-first authors Qiang Wei and Yang Ganxiang, alongside Columbia's Rong Yi and CertiK's Li Xupeng, in the lab of Gu Ronghui.
The target is a layer most verification work skips. A GPU kernel travels from CUDA C++ through NVCC into PTX, an intermediate instruction set, and only then into machine code. Compilers reorder instructions, merge redundant work and change data placement, all of which make code faster and can, occasionally, make it wrong. Tools that check source code never see that translation; TensorLean verifies the compiled PTX directly, using a PTX semantics model built in Lean that spells out floating-point rules, Tensor Core behavior, inter-thread memory synchronization and asynchronous copies, plus a parser of roughly 1,800 lines that converts compiled PTX into a form the proof assistant can reason about.
The results are blunt. Across 149 compiled kernel instances, 83 satisfied their Lean specifications on the first attempt. The other 66, or 44.3 percent of the sample, exposed defects. In total the team reported 38 correctness problems in six libraries, among them two in DeepSeek's DeepGEMM and 23 in FlashAttention. Because one source kernel compiles into many instances, a single bug can surface repeatedly.
Three technical problems had to be solved first. Concurrency: a kernel runs hundreds of threads that exchange data and wait on each other, and reasoning over every possible schedule is infeasible, so TensorLean groups threads by role, analyzes one representative per group, and builds a happens-before graph that lets it prove two things mechanically, that no two threads touch the same memory without synchronization and that no thread can deadlock. Dynamic behavior: loop counts and per-thread data ranges are only known at runtime, so the team used loop invariants and induction to cover all parameter combinations at once instead of testing a few shapes. Floating point: real arithmetic and GPU arithmetic diverge, and addition is not associative, so the proof proceeds in two steps, first showing an idealized real-number execution matches the mathematical specification, then bounding the accumulated rounding error.
The team also attacked the reason formal verification rarely reaches production code: writing specifications is expensive. The seL4 microkernel is often cited as the cautionary tale, roughly 8,700 lines of C verified with about 20 person-years and 200,000 lines of proof. TensorLean splits a kernel's specification into four independent pieces, one for the mathematics, one for the memory state left behind, one for layout and one for constraints, so an author writes tensor-level math and the system translates it down to PTX. For 72 open-source kernels, 151,285 lines of source corresponded to 10,278 lines of specification, a ratio near 15 to 1. FlashAttention versions two through four, all 37 source kernels across Ampere, Hopper and Blackwell, took 6,242 lines of specification to cover 55,910 lines of code and 102 compiled instances.
The defects fall into eight classes: algorithm errors, numerical problems such as insufficient precision or instability, uninitialized or unwritten memory, layout and bounds errors, data races, deadlocks, compiler-introduced bugs from NVCC, Triton or CuTe DSL, and undefined behavior. One case illustrates why testing misses these. In FlashAttention-4, two groups of threads take turns using the same scratch memory; if the second group writes early, the first can read overwritten data. The team ran 17,760 related trials on an H100 and never observed the race that the proof identified as reachable. All reported defects have been fixed and disclosed to the developers, according to the account.
The stakes are not abstract. In August 2025 some Claude API users received Thai text in English answers and syntactically broken code; Anthropic later traced it to a runtime optimization affecting some TPU servers that skewed the model's probability distribution, and rolled it back on September 2. Michigan researchers have described a thousand-GPU training run that went 3,000 steps before monitoring raised an alarm and took five days to trace to a data race in a PyTorch routine that corrupted a few rows only under rare input combinations.
The lineage matters too. Gu Ronghui co-developed CertiKOS with Yale's Shao Zhong in 2016, the first complete formal verification of a concurrent OS kernel, then co-founded CertiK and applied the method to smart contracts. TensorLean is that research program pointed at AI infrastructure, and it raises the possibility that the numerics under a model could eventually ship with a checkable proof the way flight-control software does. It also implies a new cost for kernel authors: every layout change, precision switch or thread reconfiguration has to be re-proved against a specification, which is cheaper than discovering the bug five days into a training run, but not free.
Comments (0)
Log in to join the discussion
Log InNo comments yet