In August 2025, some Claude users encountered a strange phenomenon.
They clearly asked questions in English, yet Thai suddenly appeared in the answers; when asked to write code, the generated programs contained obvious syntax errors. For the users who encountered the problem, the large model seemed to have suddenly "gone out of control."
Anthropic later explained in a post-mortem that a runtime optimization used for speedup had affected some TPU servers.
The timeline of the Claude API incident published by Anthropic. The middle row is the output anomaly described in the article: it appeared on August 25, and the related optimization was rolled back on September 2. Image source: Anthropic, September 17, 2025.
A simple performance optimization unexpectedly introduced computational errors that disturbed the model's normal probability distribution. Some Tokens that were originally almost impossible to be selected were given abnormally high probabilities, and the model's output thus became chaotic and unpredictable.
In chat and code-writing scenarios, the consequence of underlying computational errors is chaotic text output, and the user experience suffers. But what if the scenario is switched to an autonomous driving system? If the same output distortion occurs at a critical moment, when the brake should be applied, an incorrect probability value could cause the system to fail and endanger safety.
When algorithms face a "crisis of trust," and traditional testing methods find it difficult to exhaust all possible errors, researchers' attention naturally turns to a direction that has been developed for many years in the fields of mathematics and computer science — Formal Verification.
But truly introducing this capability into the underlying computation of modern AI systems is far more difficult than imagined. GPU kernels involve complex parallel execution, floating-point arithmetic, and hardware optimization. Large-scale formal verification of actually deployed high-performance operators has long been a difficult problem.
Now, this difficult problem has achieved a new breakthrough.
On November 20, CertiK and researchers from Columbia University jointly announced TensorLean. This is the first time globally that, on the compiled GPU code (PTX) of production-level AI operators, while simultaneously considering how tasks are dynamically allocated, how data is asynchronously transferred, and how much error floating-point arithmetic will produce, mathematical proofs are used to verify whether the actual computation meets expectations.
The research team evaluated 149 compiled GPU kernel instances, of which 83 instances passed the corresponding Lean specifications in the initial verification. The remaining 66 instances were found to have defects, accounting for 44.3% of the samples evaluated in this study.
This study covers GPU architectures of different generations and involves
DeepSeek
's DeepGEMM and the widely used FlashAttention operator library. The team found 38 correctness issues in 6 libraries in total, of which 2 came from
DeepSeek
's DeepGEMM and 23 came from FlashAttention. The same defect may affect multiple compilation instances.
Let us take a detailed look at TensorLean's breakthrough technical achievements.
Formalization at the Tensor level
TensorLean's technical breakthrough is concentrated at three levels.
First, verification occurs at the PTX code level.
From writing to execution, a GPU kernel goes through multiple stages. Developers first write source code in high-level languages such as CUDA C++, then compile it through a compiler into an intermediate instruction called PTX (Parallel Thread Execution), and finally NVIDIA's assembler converts it into machine code directly executed by the GPU hardware.
During this process, the compiler performs a large amount of "translation optimization" on the source code: rearranging instruction order, merging duplicate computations, adjusting data storage methods, and so on. These optimizations usually make the program run faster, but they may also introduce errors during the translation process. In other words, the source code written by the developer is correct, but the actual compiled execution code may be wrong.
Traditional verification, if it only checks the source code, will miss problems introduced by the compiler. TensorLean chooses to directly verify the compiled PTX instructions.
To achieve this, the team built a complete PTX semantics model in the Lean theorem prover, precisely describing in mathematical language the GPU's floating-point arithmetic rules, Tensor Core computation rules, inter-thread memory synchronization mechanisms, asynchronous data copying, and other behaviors, and implemented a parser of about 1,800 lines of code that automatically converts compiled PTX into a formal representation suitable for mathematical reasoning. The proofs are completed in Lean and can be machine-verified.
Second, automate the core difficulties in GPU execution.
The first difficulty is concurrency. A GPU kernel usually runs hundreds of threads simultaneously; each executes part of the computation and must also exchange data and wait for each other at specific moments. Directly reasoning about the behavior of all threads under all possible schedules is almost infeasible. For example, in FlashAttention-4, two groups of threads take turns using the same temporary storage. After the previous group finishes reading, the next group writes, and the computation can proceed normally. But if the next group writes a little too early, the previous group may read overwritten data. The team ran a set of related tests 17,760 times on an H100 and never once observed this error discovered by TensorLean.
TensorLean's approach is to "divide by roles and analyze representatives." In most kernels, threads play only a few roles; for example, some are responsible for moving data, while others are responsible for computation. TensorLean groups threads by role and analyzes only one "representative thread" for each group, so one analysis covers the behavior of all threads in the group.
What about interactions between groups? TensorLean constructs an "ordering graph" that records which operations are guaranteed to complete before which other operations. TensorLean can automatically prove two things. First, two threads will not simultaneously read and write the same block of memory without synchronization protection, so there are no data conflicts; second, all threads can complete normally, and there is no deadlock. Once these two properties are proven, the analysis results of each group can be safely combined.
The second difficulty is dynamism. In production-level kernels, how many times a loop executes and which data each thread processes are determined only at runtime, varying with the input tensor size and hardware configuration. If verification is performed only for one specific set of parameters, the scope of the proof is too narrow.
TensorLean uses loop invariant techniques, using mathematical induction to prove that "no matter how many times the loop executes, a certain property always holds after each round," thereby covering all possible parameter combinations at once. There is no need to run a separate test for each length and batch size.
The third difficulty is floating-point precision. Operations in mathematical formulas are exact, but floating-point computations on GPUs have rounding errors. What's more troublesome is that floating-point addition does not satisfy the associative law. If the kernel's floating-point output is directly compared with the mathematical formula, the computational complexity of verification will grow exponentially with the number of operations, which is simply infeasible.
TensorLean designed a two-step verification method. First, introduce an "intermediate reference object", that is, assume that the GPU uses exact real numbers to execute the same instruction sequence, obtaining an ideal result. In the first step, prove that this ideal result is completely consistent with the mathematical specification, eliminating all algorithmic-level errors. In the second step, compute the upper bound on the accumulated rounding error between the actual floating-point operations and the ideal result. Combining the two steps proves that the deviation between the kernel's actual output and the mathematical specification is within an acceptable tolerance range.
Third, reduce the cost of writing verification specifications.
Formal verification has a historical challenge: writing "specifications" is extremely costly. This is because it must not only describe the mathematical operations themselves, but also describe how data is stored in GPU memory. The seL4 microkernel has only about 8,700 lines of C code, yet its verification required 20 person-years and 200,000 lines of proof.
TensorLean separates the mathematical computation logic from the underlying memory layout, allowing researchers to write specifications at a higher level of abstraction.
Specifically, a kernel's specification is split into four independent parts:
- spec_math: what the kernel should compute, described using pure tensor operations
- spec_machine: what changes the kernel leaves in GPU memory
- Layout: how each tensor is stored in memory, that is, the mapping rules from elements to memory
- Constraints: additional constraints on inputs and outputs
After mathematics and memory are separated, researchers only need to care about the tensor-level mathematical logic when writing specifications, without worrying about the underlying byte arrangement. TensorLean automatically translates tensor-level specifications into PTX-level specifications.
This decoupling also brings reuse advantages. The same class of operations is largely similar in mathematical logic, with differences mainly in memory layout. The mathematical part can be reused, and only the memory layout description needs to be added for each specific implementation.
The team wrote mathematical specifications for 72 open-source kernels. Together they have 151,285 lines of source code, corresponding to 10,278 lines of specifications, about 15:1.
Operator Verification of FlashAttention and DeepSeek
In actual verification, the team completed formal verification of 27
DeepSeek
related kernels. The team also checked all 37 source kernels of FlashAttention-2 through FlashAttention-4, totaling 102 compiled instances. One source kernel can be compiled into multiple instances under different configurations.
FlashAttention underwent four generations of iteration over four years, from Ampere to Blackwell architecture, and each generation represented the optimal implementation of attention kernels at the time. As the de facto standard attention operator, FlashAttention has been widely deployed by mainstream frameworks such as PyTorch, vLLM, and SGLang, supporting the training and inference services of a large number of large language models.
This core position means that any correctness defect in FlashAttention could affect every model running on these systems.
These 37 source kernels cover three generations of GPU architectures, Ampere, Hopper, and Blackwell, totaling 55,910 lines of source code. The team used 6,242 lines of specifications to describe the computational requirements they should satisfy.
Eight Categories of Correctness Defects
End-to-end formal verification, covering everything from mathematical specifications all the way to compiled PTX instructions, enables TensorLean to capture a wide range of correctness defects. The research team classified the discovered defects into eight categories.
- Algorithm implementation errors. The kernel code deviates from the intended algorithm, such as incorrect formulas, incorrect conditional judgments, or unhandled special cases. Such problems have nothing to do with floating-point precision or memory access; the algorithm logic implemented by the kernel itself is wrong.
- Numerical defects. Insufficient precision or numerical range, or numerical instability. Such kernels are correct under ideal real-number arithmetic, but fail under finite-precision floating-point arithmetic.
- Uninitialized memory. The kernel reads shared memory before initializing it, or some output locations are not written. This leads to incorrect computation results or causes nondeterministic control flow.
- Memory access errors. Incorrect tensor memory layout or distributed layout, or missing bounds checks, leading to out-of-bounds access and memory corruption.
- Data races. Two threads access the same global or shared memory address, at least one of which is a write, and no barrier or fence orders them. Such races can silently corrupt output tensors without any error being reported.
- Deadlocks. Threads form a circular wait. The consequence is that the kernel hangs and cannot complete computation.
- Compilation errors. Kernel compilers such as NVCC, Triton, or CuTe DSL compile correct source code into incorrect executable code. Since TensorLean verifies at the PTX level, all errors introduced by the compiler are within the scope of checking.
- Undefined behavior. Certain operations exceed the range specified by the language or instruction, so the program's execution results are not guaranteed.
The left figure compares the source code and specification line counts of each FlashAttention-3 kernel, and the right figure summarizes the data for FlashAttention-2, -3, and -4. Image source: Figure 6 on the TensorLean official website.
Some of these defects were exposed during the specification-writing stage: researchers tried to precisely define the kernel's expected behavior in mathematical language, but found that the actual implementation deviated from the mathematical definition.
Other defects were discovered during the automated proof process — the prover could not complete the proof on certain execution paths, and upon further investigation, the researchers confirmed that the problem lay in the kernel implementation itself. At present, all discovered defects have been fixed and reported to the relevant developers.
Even kernel implementations that are widely trusted and deployed may have various correctness hazards that have not been adequately detected.
Traditional testing can only verify program correctness through a limited set of input samples, and it is difficult to exhaust all boundary conditions and execution paths. TensorLean, however, through formal verification, provides mathematical-level correctness guarantees for all possible inputs within the scope defined by the specification, elevating kernel reliability assurance from empirical testing to the level of rigorous mathematical proof.
When Formal Verification Meets AI Computing
Formal verification is not some new technology.
As early as more than twenty years ago, Airbus had already introduced formal methods into flight control software development. In the chip design field, after the Pentium FDIV incident, Intel deeply embedded formal verification into its processor R&D process. In the operating system field, researchers completed a full functional correctness proof for the seL4 microkernel, investing about 20 person-years, and it remains a landmark case in formal verification to this day.
These cases show that formal verification has long proven its value in fields with extremely high requirements for correctness and reliability. For AI systems that are becoming increasingly large in scale, increasingly complex in computational processes, and where underlying errors may be amplified layer by layer, formal verification clearly has broader application space.
A single frontier large-model training run can cost hundreds of millions of dollars, while inference services support the daily use of hundreds of millions of users. And beneath these massive systems are tens of thousands of GPU kernels, responsible for executing fundamental operations such as matrix multiplication, attention computation, and normalization.
To extract the ultimate performance from the hardware, engineers need to highly optimize these computational kernels for different GPU architectures. Data layout, thread scheduling, computational precision, memory access patterns—every link in the chain may undergo complex engineering transformations.
This also means that the code ultimately running on the GPU is already separated from the mathematical formulas we are familiar with by multiple layers of optimization and transformation. Any tiny error may be amplified in large-scale computation.
Researchers at the University of Michigan documented a thousand-GPU training incident. A vision-language model trained for more than 3,000 steps before monitoring metrics raised an alarm. Engineers repeatedly ran experiments and swapped kernels, yet still could not find the cause after five days. It was later discovered that a low-level program in PyTorch had a data race that corrupted a few lines of data only under rare input combinations.
The value of TensorLean lies precisely in extending formal verification down to the foundational layer of AI computation.
It directs the object of verification at production-grade GPU kernels involved in model training and inference, and attempts to handle complex problems unique to high-performance computing, such as floating-point computation, concurrency synchronization, and dynamic branching.
For large-model R&D teams, every round of performance optimization carries correctness risk. Changing data layout, switching precision formats, adjusting thread configurations—any one of these changes may cause code that previously passed tests to produce errors under new operating conditions.
TensorLean provides a verification method that can be repeatedly executed as code iterates. First write mathematical specifications for the kernel, then after optimization re-verify whether the new implementation still satisfies the specifications. When the specifications themselves remain unchanged, verification can be directly reused; when optimization changes the preconditions, the specifications also need to be updated accordingly. In this way, engineers pursuing higher performance also have the opportunity to obtain stricter correctness guarantees.
For computing infrastructure providers, as the AI workloads run by customers grow larger, low-level computational errors may bring expensive rework costs, wasted compute, and even affect model training results and the reliability of inference services.
If critical computational kernels can come with checkable mathematical proofs, computing platforms will also have the opportunity to provide, beyond performance and stability, a stricter and auditable layer of correctness assurance.
Epilogue: Infra Enters the "Provable" Era
Today, AI systems are becoming increasingly complex. Model scales continue to expand, training and inference frameworks keep iterating, and low-level computation increasingly relies on highly customized hardware and software optimization.
But no matter how powerful the model is, it ultimately depends on these low-level computational programs to transform massive tensor operations into actual results. If even the most fundamental computational process cannot be guaranteed correct, then the reliability of upper-layer systems will always harbor hidden risks.
GPU kernels are the lowest-level, most dense, and hardest-to-check components in AI systems, and they are the numerical foundation of all upper-layer capabilities. If the correctness of this layer can be covered by mathematical proof, the trust-transmission effect it brings will extend upward along the entire software stack.
From operating system kernels to AI kernels, this line of research has spanned a decade.
In 2016, Ronghui Gu and Professor Zhong Shao of Yale University collaborated to develop CertiKOS, providing the first complete formal verification for a concurrent operating system kernel. The following year, the two co-founded the security company CertiK, applying formal verification to smart contracts. By 2022, CertiK had become a unicorn company valued at $2 billion. In 2026, the Columbia University lab led by Ronghui Gu and CertiK set their sights on AI Infra. The two co-first authors Qiang Wei and Ganxiang Yang, together with Rong Yi of Columbia University and Xupeng Li of CertiK, developed TensorLean and used it to verify the GPU kernels actually used by
DeepSeek
and FlashAttention. TensorLean represents the extension of this technical route toward AI infrastructure, with the underlying methodology in the same lineage.
The capabilities of large models are advancing by leaps and bounds, and the computing infrastructure supporting these capabilities also needs equally serious reliability assurance. The step taken by TensorLean has brought production-grade AI code within the range of formal verification for the first time.
For the still rapidly evolving AI Infra, this is the beginning of a brand-new stage.
This article comes from the WeChat public account "Machine Heart" (ID: almosthuman2014), author: Leng Mao










