New tool finds hidden bugs in AI's brain cells before they break models
A team caught 38 serious errors in popular code used by DeepSeek, FlashAttention and others—errors that tests missed entirely.

A program that uses math to prove the tiny codes inside graphics chips run correctly.
AI models are only as good as the code behind them. When Google DeepMind recently found numerical bugs in standard PyTorch functions that could crash training, it highlighted a growing problem: the mathematical engines powering today's biggest AI systems often contain hidden errors that traditional testing cannot catch.
Now a new system called TensorLean has shown how to find these bugs before they cause damage.
What you could do with it
- A researcher could run formal verification on GPU kernel code to mathematically prove it handles every possible input and hardware schedule without data races or crashes 1.
- An AI developer working on kernels for projects like FlashAttention or DeepSeek could use TensorLean to catch silent correctness bugs long before they corrupt model training 2.
- A team building large-scale AI models could verify their production GPU kernels ahead of deployment, preventing expensive training failures that might cost millions in wasted GPU hours 1.
Catching bugs that tests miss
The team tested TensorLean against 149 real-world kernel instances from popular AI libraries. They proved 83 were completely correct—but the remaining 66 contained bugs that developers had overlooked for months or even years 12.
Among the findings were 38 distinct correctness bugs across several major projects:
- A data race in FlashAttention-4 that only appeared under rare hardware schedules, despite 17,760 normal test runs passing 2
- Memory access errors that caused crashes when processing very large batches
- Numerical bugs that could zero out gradients during training
- Undefined behavior that might seem fine until a specific configuration triggered it
With Tensor Lean, we checked 149 real-world open-source kernel instances and proved 83 of them correct. During verification, we also found 38 bugs of different types in state-of-the-art kernels that had escaped testing for months or even years.
The bugs weren't theoretical—they existed in production code used by major AI systems, including FlashAttention, DeepSeek, Liger Kernel, and others 2.
149 AI kernels checked: how many passed, how many had hidden bugs
TensorLean results on kernels from FlashAttention, DeepSeek, Liger Kernel, and other open-source AI libraries
Making mathematical proofs practical
n Formal verification has long been seen as too expensive for everyday use. Proving a simple microkernel took 20 person-years of effort, compared with 2.5 years to build 1. For complex GPU code handling massive parallelism, floating-point arithmetic, and intricate memory layouts, the problem seemed insurmountable.
TensorLean changed this by reducing the gap between code size and proof size to about 15:1 3. Instead of writing proofs from scratch, developers write specifications in plain tensor language—the same kind of notation they already use—then the system handles the mathematical heavy lifting.
The pipeline works in seven steps: start from unmodified source code, write a tensor-level specification, compile to PTX assembly (the intermediate language used by NVIDIA GPUs), then systematically verify properties like data-race freedom, termination, and output correctness within floating-point tolerance 13.
What this means for AI development
As AI models become essential infrastructure—for science, medicine, business—the cost of silent failures grows. A corrupted model trained over thousands of GPU hours wastes both time and money, sometimes millions of dollars 1.
Formal verification offers a way forward, but only if it scales. TensorLean's approach shows this is possible. The team found bugs in systems ranging from FlashAttention-2 through version 4, covering kernels designed for different NVIDIA architectures including the A100, H100, and B200 chips 12.
The researchers plan to release their paper and open-source implementation, including the PTX semantics and all specifications and proofs, so other developers can reuse the work 12.
If you are struggling, help is available: in Italy call 112 or Telefono Amico on 02 2327 2327; elsewhere, your local emergency number.
Corrections and updates
- Updated on 26 November 2026. The story reports 38 bugs found by TensorLean, but the source paper states the count is 44.
Key facts
- 149 GPU kernels analyzed from major AI libraries including FlashAttention, DeepSeek, Liger Kernel
- 83 kernels proven mathematically correct; 66 found to contain bugs
- 38 distinct correctness bugs discovered that evaded existing test suites
- One bug caught: a data race in FlashAttention-4 that never appeared in 17,760 normal test runs
- System scales to ~15:1 ratio of spec lines to kernel source lines
Sources
If this story concerns you or your company, or uses something that belongs to you, ask for a correction or for it to be taken down. How requests work
Keep reading
Apps and productsGoogle opens TorchTPU, a native PyTorch backend for cloud TPUsHerald of AIhttps://github.com/soumith, CC BY-SA 4.0, via Wikimedia Commons
Google opens TorchTPU, a native PyTorch backend for cloud TPUs
A new open-source stack lets developers run PyTorch models directly on Google's TPU chips, replacing the older PyTorch/XLA system.
The weekThis Week in AI New Models Flood In and Agents Get SaferHerald of AI
This Week in AI New Models Flood In and Agents Get Safer
Big open-weight releases, speed breakthroughs, and a push to make AI agents more reliable and secure.
Apps and productsDeepSeek Open-Sources DeepInfer, Its High-Performance Inference EngineHerald of AI
DeepSeek Open-Sources DeepInfer, Its High-Performance Inference Engine
The Chinese AI lab released the framework behind its production services under an Apache 2.0 license, giving developers access to large-scale serving optimizations.