AI guides

TensorLean verifies production GPU kernels: 83 instances meet specifications, issues reported upstream

By 冷猫0 viewsSource: 机器之心
TensorLean verifies production GPU kernels: 83 instances meet specifications, with issues reported upstream

CertiK and Columbia’s TensorLean verifies GPU kernels at the PTX level. Its November 20 announcement reported 83 of 149 compiled instances met specifications and 38 issues. Guarantees depend on modeled behavior, preconditions and tolerances; fixes require individual checks.

Editorial fact-check (November 24, 2026): TensorLean’s proofs concern inputs and executions satisfying specification preconditions, supported PTX behaviors and floating-point tolerances. They do not provide an unconditional correctness guarantee for subsequent machine code, hardware or an entire AI system. The body retains the 38 issues from the November 20 announcement; the public README listed 41 in this review. Neither count should be confused with the 149 compiled instances. Issues have been reported upstream, but FlashAttention PR3196 and DeepGEMM PR515 remained unmerged at the time of this review, so they cannot all be described as fixed and released. The repository still says a paper and full implementation will be released; a public issue list does not mean the complete verifier has been open-sourced. TensorLean public repository and current issue list (opens in a new tab)CertiK’s original research announcement (opens in a new tab)FlashAttention PR3196 (opens in a new tab)DeepGEMM PR515 (opens in a new tab)

In August 2025, some Claude users encountered something strange.

Questions asked in English suddenly elicited Thai text; requests for code produced programs with obvious syntax errors. To affected users, the large model seemed to have abruptly gone “out of control.”

Anthropic later explained in a postmortem that a runtime optimization intended to improve speed had affected some TPU servers.

Article illustration

Anthropic’s published timeline of Claude API incidents. The middle row concerns the abnormal output discussed here: it appeared on August 25, and the relevant optimization was rolled back on September 2. Source: Anthropic, September 17, 2025.

A simple performance optimization had unexpectedly introduced computation errors, disrupting the model’s normal probability distribution. Tokens that would ordinarily have been almost impossible to select received abnormally high probabilities, making outputs confused and unpredictable.

In chat and coding, the consequence of an underlying computation error is incoherent text and a damaged user experience. But what if the setting were an autonomous-driving system? If the same output distortion occurred at a critical moment when braking was needed, an incorrect probability value could cause a system failure and threaten safety.

When algorithms face a “crisis of trust” and conventional testing cannot exhaust all possible errors, researchers naturally turn to an approach developed over many years in mathematics and computer science: formal verification.

But bringing that capability into the underlying computations of modern AI systems is far harder than one might imagine. GPU kernels involve complex parallel execution, floating-point arithmetic and hardware optimizations. Large-scale formal verification of high-performance operators actually deployed in production has long been difficult.

Now there is a new breakthrough in addressing that challenge.

On November 20, researchers at CertiK and Columbia University jointly announced TensorLean. The announcement describes it as the first system to use mathematical proofs to verify whether computations in the compiled GPU code (PTX) of production AI operators meet expectations while jointly considering dynamic work assignment, asynchronous data transfer and floating-point error.

The team evaluated 149 compiled GPU kernel instances, of which 83 passed their corresponding Lean specifications on the initial verification attempt. Defects were found in the remaining 66 instances, or 44.3% of this evaluation sample.

The study spans multiple GPU architecture generations and includes DeepSeek’s DeepGEMM and the widely used FlashAttention libraries. The team found 38 correctness issues across six libraries, including two in DeepGEMM and 23 in FlashAttention. A single defect can affect several compiled instances.

Let us take a detailed look at TensorLean’s technical advances.

Tensor-level formalization

TensorLean’s technical advances have three main aspects.

First, verification takes place at the PTX-code level.

A GPU kernel passes through several stages from development to execution. Developers first write source code in a high-level language such as CUDA C++. A compiler then translates it into intermediate instructions called PTX, or Parallel Thread Execution. Finally, NVIDIA’s assembler converts PTX into machine code executed directly by GPU hardware.

During that process, the compiler performs extensive “translation optimizations”: reordering instructions, combining repeated computations and adjusting how data is stored, among others. These optimizations usually make the program faster, but can also introduce errors during translation. In other words, the developer’s source code may be correct while the compiled code that actually executes is wrong.

Article illustration

Conventional verification that checks only source code misses problems introduced by compilers. TensorLean instead verifies the compiled PTX instructions directly.

To do so, the team built a semantic model in the Lean theorem prover for supported PTX instructions and behaviors. It precisely describes GPU floating-point rules, Tensor Core operations, inter-thread memory synchronization and asynchronous data copying in mathematical language, and implements a parser of approximately 1,800 lines of code to automatically convert compiled PTX into a formal representation suitable for mathematical reasoning. Proofs are completed in Lean and can be checked by machine.

Second, it automates the handling of core difficulties in GPU execution.

The first difficulty is concurrency. A GPU kernel typically runs hundreds of threads simultaneously. Each performs part of the computation, and they must exchange data and wait for one another at particular points. Directly reasoning about all threads under every possible schedule is almost infeasible. In FlashAttention-4, for example, two groups of threads take turns using the same temporary storage. Computation proceeds correctly if one group finishes reading before the next writes. But if the next group writes slightly too early, the first may read overwritten data. The team ran a related set of tests 17,760 times on an H100 without ever observing this error found by TensorLean.

TensorLean handles this by “separating roles and choosing representatives.” In most kernels, threads play only a few roles, such as moving data or performing computations. TensorLean groups threads by role and analyzes only one “representative thread” per group, covering the behavior of all threads in that group in one analysis.

What about interactions between groups? TensorLean builds a “happens-before graph” recording which operations are guaranteed to finish before others. It can automatically prove two properties. First, two threads will not concurrently read and write the same memory without synchronization, ruling out data races. Second, all threads can finish normally, ruling out deadlock. Once these properties are proved, the analyses of different groups can safely be combined.

The second difficulty is dynamic behavior. In production kernels, the number of loop iterations and the data each thread handles are determined at runtime, changing with input tensor dimensions and hardware configurations. Verifying only one specific parameter combination would make the proof too narrow.

TensorLean uses loop invariants, applying mathematical induction to prove that “regardless of how many times a loop executes, a certain property holds after every iteration.” This covers parameterized inputs and configurations satisfying the stated constraints, without running a separate test for every sequence length or batch size.

The third difficulty is floating-point precision. Arithmetic in mathematical formulas is exact, but GPU floating-point computations involve rounding errors. More awkwardly, floating-point addition is not associative. Directly comparing a kernel’s floating-point output with the mathematical formula would cause verification complexity to grow exponentially with the number of operations, making it infeasible.

Article illustration

TensorLean designs a two-step verification method. It first introduces an “intermediate reference”: the ideal result that would be obtained if the GPU executed the same instruction sequence using exact real numbers. Step one proves that this ideal result matches the mathematical specification exactly, ruling out algorithmic errors. Step two calculates an upper bound on the accumulated rounding error between actual floating-point computation and the ideal result. Together, the two steps prove that the kernel’s actual output deviates from the mathematical specification only within an acceptable tolerance.

Third, it reduces the cost of writing verification specifications.

Formal verification has a long-standing challenge: specifications are extremely expensive to write. They must describe not only the mathematical operation but also how data is stored in GPU memory. The seL4 microkernel has only about 8,700 lines of C code, yet verification required 20 person-years and 200,000 lines of proof.

TensorLean separates the mathematical computation from the underlying memory layout, allowing researchers to write specifications at a higher level of abstraction.

Specifically, a kernel’s specification is divided into four independent parts:

  • spec_math: what the kernel should compute, described through pure tensor operations;
  • spec_machine: what changes the kernel should leave in GPU memory;
  • Layout: how each tensor is stored in memory—the mapping from elements to memory;
  • Constraints: additional requirements on inputs and outputs.

Once mathematics and memory are separated, researchers writing specifications need only focus on tensor-level mathematical logic, without worrying about the underlying byte arrangement. TensorLean automatically translates tensor-level specifications into PTX-level specifications.

This decoupling also enables reuse. Operations of the same kind have broadly similar mathematical logic and differ mainly in memory layout. The mathematical portion can be reused, with only the memory-layout description added for each implementation.

The team wrote mathematical specifications for 72 open-source kernels. Together, they contain 151,285 lines of source code, corresponding to 10,278 lines of specifications, a ratio of approximately 15:1.

Verifying FlashAttention and DeepSeek operators

In practical verification, the team completed formal verification of 27 DeepSeek-related kernels. It also examined all 37 source kernels from FlashAttention-2 through FlashAttention-4, totaling 102 compiled instances. A single source kernel can compile into multiple instances under different configurations.

FlashAttention has undergone four generations in four years, spanning Ampere through Blackwell, with each generation representing the leading attention-kernel implementation of its time. As a de facto standard attention operator, it is widely deployed in major frameworks such as PyTorch, vLLM and SGLang, supporting training and inference services for many large language models.

That central role means a correctness defect in FlashAttention could potentially affect every model running on those systems.

These 37 source kernels cover the Ampere, Hopper and Blackwell GPU generations and total 55,910 lines of source. 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, from mathematical specifications through compiled PTX instructions, enables TensorLean to capture a broad range of correctness defects. The team groups its findings into eight categories.

  • Algorithm implementation errors. The kernel deviates from the intended algorithm: a formula is wrong, a condition is incorrect or a special case is unhandled. These problems are unrelated to floating-point precision or memory access; the implemented algorithmic logic itself is wrong.
  • Numerical defects. Insufficient precision or 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 leaves some output locations unwritten. This can produce incorrect results or nondeterministic control flow.
  • Memory-access errors. An incorrect tensor memory layout or distributed layout, or missing bounds checks, causes out-of-bounds accesses and memory corruption.
  • Data races. Two threads access the same global or shared memory address, at least one access is a write, and no barrier or fence orders them. Such a race can silently corrupt an output tensor without any error message.
  • Deadlock. Threads form a cycle of waiting, leaving the kernel hung and unable to complete its computation.
  • Compilation errors. A kernel compiler such as NVCC, Triton or CuTe DSL turns correct source code into incorrect executable code. Because TensorLean verifies at the PTX level, it can check compilation errors within the modeled PTX behavior and specification. It does not cover every subsequent assembler error, hardware error or unmodeled behavior.
  • Undefined behavior. An operation falls outside what the language or instruction defines, so the program’s behavior is not guaranteed.

Article illustration

The left chart compares source-code and specification line counts for FlashAttention-3 kernels; the right summarizes FlashAttention-2, -3 and -4. Source: Figure 6 on the TensorLean website.

Some defects surfaced while specifications were being written: as researchers tried to define a kernel’s expected behavior precisely in mathematics, they found discrepancies between its implementation and the mathematical definition.

Other defects emerged during automated proving: the prover could not complete proofs along certain execution paths. Further investigation confirmed that the kernel implementations themselves were at fault. These issues have been reported to the relevant developers. Some have proposed fixes, but upstream merge and release status must be checked individually; it is not correct to say all have been fixed.

Even widely trusted and deployed kernel implementations can contain correctness risks that have not been adequately detected.

Conventional testing checks correctness using a finite set of input samples, making it difficult to exhaust all boundary conditions and execution paths. Through formal verification, TensorLean instead provides mathematical correctness guarantees for all possible inputs within the scope defined by the specification, moving kernel reliability assurance from empirical testing to rigorous mathematical proof.

When formal verification meets AI computation

Formal verification is not a new technology.

More than two decades ago, Airbus was already introducing formal methods into flight-control software development. In chip design, Intel deeply integrated formal verification into processor development after the Pentium FDIV incident. In operating systems, researchers completed a full functional-correctness proof for the seL4 microkernel, investing roughly 20 person-years. It remains a landmark example in formal verification.

These cases show that formal verification has long demonstrated its value in fields with exceptionally demanding correctness and reliability requirements. For AI systems that keep growing larger and more computationally complex, and in which low-level errors can be amplified through successive layers, its potential applications are clearly broader still.

A single frontier-model training run may cost hundreds of millions of dollars, while inference services support the daily use of hundreds of millions of people. Beneath these immense systems are thousands upon thousands of GPU kernels executing basic operations such as matrix multiplication, attention and normalization.

To extract maximum hardware performance, engineers heavily optimize these kernels for different GPU architectures. Data layouts, thread scheduling, computational precision and memory-access patterns may each undergo complex engineering changes.

This also means that several layers of optimization and transformation separate the code ultimately running on a GPU from the mathematical formulas we recognize. A tiny error anywhere can be amplified in large-scale computation.

University of Michigan researchers documented a training incident involving a thousand GPUs. A vision-language model trained for more than 3,000 steps before monitoring metrics raised an alarm. Engineers repeatedly experimented and swapped kernels, yet failed to find the cause after five days. They eventually traced it to a data race in a low-level PyTorch routine that corrupted a few rows of data only under rare combinations of inputs.

TensorLean’s value lies precisely in bringing formal verification into the foundational layer of AI computation.

It directly targets production GPU kernels used in model training and inference, attempting to address complexities specific to high-performance computing, including floating-point computation, concurrent synchronization and dynamic branches.

For large-model development teams, every round of performance optimization brings correctness risks. Changing data layouts, precision formats or thread configurations can cause previously tested code to fail under new operating conditions.

TensorLean offers a verification method that can be repeated as code evolves. First, specify the kernel’s mathematics; after optimization, verify that the new implementation still satisfies it. When the specification remains unchanged, the verification can be reused directly. When an optimization changes preconditions, the specification also needs updating. Engineers pursuing higher performance can thus seek more rigorous correctness guarantees at the same time.

For computing-infrastructure providers, as customers’ AI workloads grow, low-level computation errors can cause expensive rework, wasted computing resources and even reduced reliability of model training results and inference services.

If critical kernels can come with checkable mathematical proofs, computing platforms have an opportunity to offer a stricter, auditable layer of correctness assurance alongside performance and stability.

Epilogue: infrastructure enters a “provable” era

Today, AI systems are becoming increasingly complex. Models keep growing, training and inference frameworks continually evolve, and underlying computations rely ever more heavily on highly customized hardware and software optimizations.

But however powerful a model becomes, it ultimately depends on these low-level programs to turn vast tensor computations into actual results. If even the most basic computations cannot be guaranteed correct, the reliability of the systems above them remains at risk.

GPU kernels are among AI’s lowest-level, most densely computational and hardest-to-inspect components, and form the numerical foundation of all higher-level capabilities. If mathematical proofs can cover correctness at this layer, the resulting assurance can propagate upward through the software stack.

The research path from operating-system kernels to AI kernels spans a decade.

In 2016, Ronghui Gu and Yale University’s Zhong Shao developed CertiKOS together, providing what the article describes as the first full formal verification of a concurrent operating-system kernel. The following year, they co-founded security company CertiK, applying formal verification to smart contracts. By 2022, CertiK had become a unicorn valued at US$2 billion. In 2026, Gu’s Columbia laboratory and CertiK turned their attention to AI infrastructure. Co-first authors Wei Qiang and Ganxiang Yang developed TensorLean with Columbia’s Yi Rong and CertiK’s Xupeng Li, using it to verify GPU kernels actually used by DeepSeek and FlashAttention. TensorLean extends this technical approach into AI infrastructure, preserving the same underlying methodology.

Large-model capabilities are advancing rapidly, and the computing infrastructure supporting them needs equally serious reliability assurance. TensorLean’s step brings production AI code into the reach of formal verification for the first time, in the article’s assessment.

For AI infrastructure, which is still evolving rapidly, this marks the beginning of a new phase.

This article comes from Synced, written by Lengmao.

Related topics

After reading

Join the AINRK community

Read how to join the community and connect with people working in AI.

Community information (opens in a new tab)