Back to articles

TensorLean Brings Formal Verification to Production GPU Kernels

2 min read

GPU kernels carry out much of the computation behind modern AI training and inference. A defect in one can silently produce wrong results rather than an obvious crash, putting models and software frameworks at risk. Testing can exercise only selected inputs and execution conditions; formal verification aims to establish that a program follows its specification across a defined range. TensorLean takes that goal to production GPU kernels by checking compiled PTX, rather than reasoning only about source code.

How the verification works

  • Reusable tensor-level specifications. TensorLean compares PTX with a specification expressed in terms of tensor behavior. The same specification can be shared across kernels and their many instances, reducing the need to create a separate specification for every variant.
  • Concurrency is part of the model. Using formalized PTX semantics, the system constructs a symbolic happens-before graph intended to represent valid inputs, launch configurations, and concurrent schedules in one analysis. It checks data-race freedom and termination first, reducing concurrent executions to finite sequential ones for later reasoning.
  • Functional and numerical checks are staged. A push/pull model computes PTX memory updates, which SMT solvers check against the specification over the reals. TensorLean then uses inductive round-off-bound inference to extend the correctness argument to the kernel’s actual floating-point PTX.
  • Automation helps with scale. The framework automatically infers tile-loop invariants and can split proof goals using assertion hints supplied by users. Its PTX semantics and soundness proofs are mechanized in Lean 4.

The evaluation covers 2,078 kernel instances from 143 kernels in FlashAttention-2, -3, and -4, DeepSeek DeepGEMM, and LinkedIn Liger Kernel. TensorLean proved 1,180 instances correct. Among the other 888 instances, the researchers uncovered 66 unique, previously unknown correctness bugs and reported them to developers. The 66 figure counts distinct bugs, not necessarily affected instances; likewise, failure to prove an instance correct does not by itself establish that it is buggy.

Why it matters—and what remains open

The notable step is verifying at the compiled-instruction level while addressing concurrency, termination, functional behavior, and floating-point effects in one workflow. Shared specifications and inferred invariants offer a route toward checking large families of kernel variants. Still, the abstract does not report proof runtimes or the range of hardware configurations covered. Those details matter when assessing practical deployment. TensorLean therefore demonstrates a promising verification approach, while its operational cost and boundaries remain important questions.

Hugging Face Daily Papers

Comments

Checking sign-in status...

Loading comments...

Related articles

CCTest · Blog
TorchTLX Brings Architecture-Specific GPU Kernels to TorchInductor
Frameworks & Tools
cctest.ai

TorchTLX Brings Architecture-Specific GPU Kernels to TorchInductor

TorchTLX adds architecture-specific TLX kernels and richer fusion options to TorchInductor while preserving the familiar torch.compile workflow. The PyTorch post reports up to 1.2x speedups for specialized GEMM and attention templates, and up to 1.5x for richer fusion in its presented benchmarks.

Read more