ProofWright: Towards Agentic Formal Verification of CUDA
Bodhisatwa Chatterjee, Drew Zagieboylo, Sana Damani, Siva Hari, Christos Kozyrakis
TL;DR
ProofWright addresses the reliability gap in AI-assisted CUDA kernel generation by combining automated formal verification with LLM-based code generation. It introduces a VerCors Agent to establish memory safety and data-race freedom, and a Semantic Equivalence Framework backed by Rocq to prove that CUDA implementations semantically match PyTorch specifications. On KernelBench L1, ProofWright verified memory and thread safety for 74% of kernels and established semantic equivalence for 14% of kernels, with modest per-kernel overhead dominated by verification time. Together, these results demonstrate that scalable, automated formal verification of GPU code produced by LLMs is feasible, enabling trustworthy high-performance code without sacrificing developer productivity.
Abstract
Large Language Models (LLMs) are increasingly used to automatically generate optimized CUDA kernels, substantially improving developer productivity. However, despite rapid generation, these kernels often contain subtle correctness bugs and lack formal safety guarantees. Runtime testing is inherently unreliable - limited input coverage and reward hacking can mask incorrect behavior - while manual formal verification is reliable but cannot scale to match LLM output rates, creating a critical validation bottleneck. We present ProofWright, an agentic verification framework that bridges this gap by integrating automated formal verification with LLM-based code generation. ProofWright provides end-to-end guarantees of memory safety, thread safety, and semantic correctness for LLM-generated CUDA kernels. On KernelBench L1, ProofWright verifies safety properties for 74% of generated kernels, uncovers subtle correctness errors missed by conventional testing, and establishes semantic equivalence for a class of element-wise kernels. With a modest overhead of 3 minutes per kernel, ProofWright demonstrates that scalable, automated formal verification of LLM-generated GPU code is feasible - offering a path toward trustworthy high-performance code generation without sacrificing developer productivity.
