Skip to main content

TensorLean Proves GPU Kernels Correct and Finds 38 FlashAttention and DeepGEMM Bugs

TensorLean, from researchers at Columbia University and CertiK, formally verifies NVIDIA GPU kernels at the compiled PTX level using Lean. Across 149 kernel instances from libraries including FlashAttention and DeepSeek's DeepGEMM, it proved 83 correct and surfaced 38 previously unknown correctness bugs, such as data races and silent KV cache corruption. The code and paper are not released yet.

On this page

What TensorLean verifies

TensorLean is a framework for proving that GPU kernels do what they are supposed to do, checked on the PTX assembly that NVIDIA's compiler actually produces rather than on the source code. The project was announced on 20 November by Wei Qiang, Ganxiang Yang and Yi Rong of Columbia University, Xupeng Li of CertiK, and Ronghui Gu, who is affiliated with both.

A developer writes a tensor-level specification of what the kernel computes, kept separate from how the kernel lays out memory. TensorLean then tries to prove, for every input and every thread schedule, that the PTX is free of data races, terminates, and matches the specification within a floating-point tolerance. The proofs are machine checked in Lean, with the Z3 and cvc5 solvers discharging many of the goals.

The targets are the kernels that sit under modern model serving. The team covered every kernel in FlashAttention 2, 3 and 4, compiled for A100, H100 and B200 GPUs, plus kernels from DeepGEMM, Liger Kernel, Triton, TileLang and TileOPs.

The numbers and the bugs

The team verified 149 compiled kernel instances. It proved 83 of them correct, and the remaining 66 each failed a proof goal because of a bug in the source. The project site and CertiK's announcement put the total at 38 previously unknown correctness bugs, while the GitHub table lists 39 entries, so the exact count depends on how a few related issues are grouped.

FlashAttention accounts for most of them: 102 of the instances, with 23 bugs in the GitHub table. The site says 19 of those 23 only appear in particular configurations, which is why tests that check one configuration at a time missed them.

Some examples from the published list show why this matters:

  • A data race in a FlashAttention 4 block sparsity routine that can silently drop blocks; the site says its tests passed thousands of runs without catching it.
  • Silent corruption of the KV cache in a FlashAttention 3 path that combines a KV cache with non-interleaved rotary embeddings.
  • A latent deadlock in the FlashAttention 3 Hopper forward kernel caused by a missing warp synchronization.
  • A DeepGEMM FP8 einsum path on Hopper that quietly drops an input term and returns the wrong result.

The repository says every bug has been reported to the developers, and several entries link to fix pull requests. Whether each fix has been merged and shipped is not stated, so anyone pinned to an older version of these libraries should check the linked issues.

Why this matters for local and self-hosted AI

If you run models on your own GPU, these kernels are not abstract. FlashAttention and its relatives sit inside many popular inference and fine-tuning stacks, and a numerical bug or a race here does not crash your program. It produces slightly wrong outputs, a corrupted cache, or a hang that only appears on certain sequence lengths or head sizes. That class of failure is exactly what ordinary unit tests are bad at finding. TensorLean's pitch is that proofs cover every input and schedule, not just the cases someone thought to test.

There is also a hardware angle. Several bugs are tied to specific GPU generations, and one TileLang issue is a compiler level miscompilation on newer consumer class hardware. As local AI users move between GPU generations, kernels that pass on one card can misbehave on another.

Limits and what is still missing

The authors are clear that the work is not finished. Neither the paper nor the code is public yet; the site and README say both will be released soon, including the PTX semantics, specifications and proofs. No license has been announced.

The trusted base includes NVIDIA's PTX documentation and compiler, the tensor core rounding model, the hand-written specifications, and the solvers themselves. The tool cannot yet handle randomized kernels such as dropout or top-p sampling, or kernels that synchronize through atomic flags, such as communication libraries. It is sound but incomplete, so it can fail to prove a correct kernel, and some loops still need developer-supplied invariants. Coverage so far rests on the team's own write-up, as AI Weekly notes.

CuriousLM runs supported AI models locally on your device. Try CuriousLM.