哥大与CertiK推出TensorLean验证GPU内核
哥伦比亚大学和 CertiK 的研究人员推出了 TensorLean,一个在 PTX 层面进行 GPU 内核形式化验证的框架。TensorLean 是一个基于 Lean 的验证器,可证明编译后的内核与张量级数学规格相符。研究团队检查了 149 个内核实例,包括 FlashAttention-2、-3 和 -4 的每个内核以及 DeepGEMM。它证明其中 83 个正确。其余 66 个导致了 38 个正确性 bug。
TensorLean 是一个在 PTX 层面进行 GPU 内核形式化验证的框架。
它从未经修改的源代码开始。开发人员用 Lean 编写张量级规格。随后 TensorLean 证明 4 个属性:无数据竞争、终止性、输出在容差范围内正确,以及其他位置的内存未被改动。
规格构建在 Lean 的 Mathlib 之上。张量算子沿用 PyTorch 命名,因此 @ 表示 torch.matmul。每个规格包含 5 个部分:spec_math、spec_mut、spec_layout、spec_tol 和 requires。数学部分与内存布局保持分离。
该流水线分 7 个步骤运行:
GitHub README 列出了 38 个 bug,均已上报至上游。FlashAttention 占 23 个。Liger Kernel 有 7 个,TileOPs 3 个,TileLang 2 个,DeepGEMM 2 个,Triton 1 个。
按类别划分,该网站报告了 19 个内存访问错误和 13 个数值 bug。它还统计了 7 个数据竞争、5 个未初始化内存读取和 5 个未定义行为。另有 3 个算法错误、2 个错误编译和 1 个死锁。一个 bug 可以归入多个类别。
在 102 个 FlashAttention 实例中,56 个通过了全部 4 个属性。其余 46 个均因源代码中的某个 bug 导致一个证明目标失败。
与 Volta 相比,关键差距在于配置覆盖范围。TensorLean 表示,等价性检查器一次只针对一个具体设置展开循环。它改用符号参数。
查看项目页面、GitHub 仓库和 X 上的公告。你可以通过我们的 GPULeaderboard.com Chrome 扩展程序在这里查看部署选项和规格。
需要与我们合作推广你的 GitHub 仓库、Hugging Face 页面、产品发布或网络研讨会等?请联系我们。
文章《来自哥伦比亚大学和 CertiK 的研究团队推出用于 GPU 内核形式化验证的 TensorLean》首次发布于 MarkTechPost。
译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。
查看英文原文(A Team of Researchers from Columbia and CertiK Introduce TensorLean for Formal Verification of GPU Kernels)
Researchers from Columbia University and CertiK have introduced TensorLean, a framework for formal verification of GPU kernels at the PTX level. TensorLean is a Lean-based verifier that proves compiled kernels match a tensor-level math spec. The research team checked 149 kernel instances, including every kernel of FlashAttention-2, -3 and -4 plus DeepGEMM. It proved 83 correct. The remaining 66 led to 38 correctness bugs.
TL;DR
- Size: 1.8K-line PTX parser. Specs total 10,278 lines against 151,285 lines of kernel source, a ratio near 15:1.
- Runs on: A 16-core workstation. It checks PTX compiled for A100, H100 and B200 kernels.
- Performance: 83 of 149 kernel instances proved correct, 38 bugs found across 6 projects.
- Best: Caught a FlashAttention-4 data race that never appeared in 17,760 test runs.
What is TensorLean?
TensorLean is a formal verification framework for GPU kernels at the PTX level.
It starts from unmodified source code. A developer writes a tensor-level spec in Lean. TensorLean then proves 4 properties: no data races, termination, correct output within tolerance, and untouched memory elsewhere.
How does TensorLean verify a GPU kernel?
Specs build on Lean’s Mathlib. Tensor operators follow PyTorch names, so @ means torch.matmul. Each spec has 5 parts: spec_math, spec_mut, spec_layout, spec_tol and requires. The math stays separate from the memory layout.
The pipeline runs in 7 steps:
- Start from unmodified source.
- Write the tensor-level spec.
- Compile to PTX and load a PTX semantics.
- Build a happens-before graph to check races and termination.
- Symbolically execute to get final memory, identical across schedules.
- Lower the spec to PTX-memory level.
- Discharge proofs with Lean’s kernel, Z3 and cvc5.
Which techniques make it scale?
- Concurrency to sequential: Race-freedom proofs on the happens-before graph cover all CTAs, threads and loop iterations symbolically.
- Loop invariants over semirings: Closed forms for tiled, accumulating loops, such as online softmax, need 1 SMT query per loop.
- Tolerance proofs: Algebraic error is proved zero. Round-off error is bounded separately, then combined.
- Assertions as hints: Developers add
tensorlean_assertin source. Each is proved once, then reused.
What bugs did TensorLean find?
The GitHub README lists 38 bugs, all reported upstream. FlashAttention accounts for 23. Liger Kernel has 7, TileOPs 3, TileLang 2, DeepGEMM 2 and Triton 1.
By category, the site reports 19 memory access errors and 13 numerical bugs. It also counts 7 data races, 5 uninitialized memory reads and 5 undefined behaviors. There are 3 algorithm errors, 2 miscompilations and 1 deadlock. One bug can sit in several categories.
Of 102 FlashAttention instances, 56 passed all 4 properties. The other 46 each failed a proof goal on a source bug.
How does it compare with other GPU kernel verifiers?
| Feature | TensorLean | Volta | ProofWright | PTX in Lean (Koska et al.) |
|---|---|---|---|---|
| Builders | Columbia, CertiK | MSR India, Stanford | Not disclosed | SF Tensor |
| Code level | PTX | PTX | CUDA | PTX |
| Checks against | Lean tensor spec | Reference kernel | Safety + equivalence | Lean proofs |
| Kernels verified | 149 instances, FA-2/3/4, DeepGEMM, Liger | Tutorial reductions, SGEMM, FA-style, TileLang | KernelBench L1, safety for 74% | 3 simple kernels |
| Async ops (wgmma, TMA) | Yes, FA-3 and FA-4 | Out of scope | Not disclosed | Yes |
| New bugs reported | 38 | Races, OOB reads | Not disclosed | Not disclosed |
| Check time | ~10 min median, 50 min max | 0.007 s to ~570 s | ~3 min per kernel | Not disclosed |
The key gap versus Volta is configuration coverage. TensorLean says equivalence checkers unroll loops for one concrete setup at a time. It uses symbolic parameters instead.
Key Takeaways
- TensorLean proves GPU kernels correct at the PTX level using Lean, Z3 and cvc5.
- 83 of 149 kernel instances proved correct; 38 bugs found.
- 23 bugs sit in FlashAttention-2, -3 and -4.
- Specs run about 15x smaller than the kernel source.
Check out the project page, GitHub repo and announcement on X. You can check the deployment options and specs here through our GPULeaderboard.com chrome extension.
Also, feel free to follow us on Twitter and don’t forget to join our 150k+ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well.
Need to partner with us for promoting your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar etc.? Connect with us
The post A Team of Researchers from Columbia and CertiK Introduce TensorLean for Formal Verification of GPU Kernels appeared first on MarkTechPost.
正文保留英文原文,标题与摘要由机器翻译。
原文发布于 MarkTechPost(A Team of Researchers from Columbia and CertiK Introduce TensorLean for Formal Verification of GPU Kernels),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。