TensorLean Formally Verifies Production GPU Kernels in Lean 4
TensorLean: Formal Verification of Production GPU Kernels
Silent numerical bugs in attention and GEMM kernels can corrupt model training long before they surface in benchmarks, and this work turns kernel auditing from manual inspection into a machine-checked proof. Framework and inference-stack engineers, as well as kernel authors at labs like DeepSeek and FlashAttention maintainers, can now check whether bugs already found in these libraries affect their own deployments. The bug list is likely the most actionable output for anyone running these kernels in production today.
Researchers present TensorLean, described as the first framework to formally verify production GPU kernels, in a paper on arXiv. The system verifies a kernel's compiled PTX against tensor-level specifications that can be shared across kernels and their thousands of instances, with all PTX semantics and soundness proofs mechanized in Lean 4.
TensorLean builds a symbolic happens-before graph over formalized PTX semantics, capturing all valid inputs, launch configurations, and concurrent schedules in a single run. It first proves data-race freedom and termination to reduce concurrent executions to finite sequential ones, then uses a push/pull model with SMT solvers to prove functional correctness of PTX memory updates over the reals. Correctness is extended to actual floating-point PTX through inductive round-off bound inference, with tile-loop invariants inferred automatically and proof goals decomposed via user-provided assertion hints.
The evaluation covers 2,078 kernel instances spanning all 143 kernels in FlashAttention-2, -3 and -4, DeepSeek DeepGEMM, and LinkedIn Liger Kernel. TensorLean proves 1,180 instances correct and uncovers 66 unique, previously unknown correctness bugs across 888 of the remaining instances, all reported to the developers.
TensorLean: Formal Verification of Production GPU Kernels
GPU kernels are the computational core of modern AI, yet a single correctness bug can silently corrupt frontier models and ML frameworks, putting training and inference at risk. Formal verification promises correctness across all inputs, launch configurations, and schedules, but it has never reached production GPU kernels. We present TensorLean, the first framework to formally verify production GPU kernels. To reduce manual effort, TensorLean verifies the kernel's compiled PTX against tensor-level specifications that can be shared across kernels and their thousands of instances. Given the kernel's PTX, TensorLean builds a symbolic happens-before graph over formalized PTX semantics to capture all valid inputs, launch configurations, and concurrent schedules in a single run. On this graph, it first verifies data-race freedom and termination, thereby reducing concurrent executions to finite, sequential ones. It then uses a push/pull model to compute PTX memory updates and proves their functional correctness against the specification over reals with SMT solvers. Finally, TensorLean extends the correctness guarantee to the kernel's actual floating-point PTX via inductive round-off bound inference. For scalability, TensorLean further automatically infers tile-loop invariants and decomposes proof goals via user-provided assertion hints. We mechanize the PTX semantics and soundness proofs in Lean 4 and evaluate TensorLean on 2,078 kernel instances covering all 143 kernels in FlashAttention-2, -3, and -4, DeepSeek DeepGEMM, and LinkedIn Liger Kernel. It proves 1,180 instances correct and uncovers 66 unique, previously unknown correctness bugs in 888 of the remaining instances, all reported to developers.
This report is categorized under AITOP's "Papers" desk, focusing on US frontier AI labs and Silicon Valley technology leaders. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows. Key entities and technical topics under continuous tracking include TensorLean, Lean 4, PTX, FlashAttention.
Primary source verification: published directly by arXiv: DeepSeek with first-party authority. Cross-source corroboration: 2 independent sources have covered this development (including Together AI), confirming industry-wide signal strength.
- Together AI12-03 19:40Source