Proving LLM-Generated GPU Kernels Correct and Safe: Floating-Point Verification in Lean and VerCors
Archibald Browne, Eugene Lee, Cristopher Salvi
Abstract
Modern statistical model development begins with a high-level specification in an automatic differentiation framework such as PyTorch, JAX, or TensorFlow, which is then lowered to a target backend by a compiler or implemented manually by a research engineer. In this paper, we study whether frontier language models can correctly perform the latter task by generating GPU kernels from high-level benchmark specifications. We introduce a framework in which a language-model agent uses Velvet, a program verifier for imperative programs embedded in Lean, to prove semantic equivalence between a high-level specification and a generated CUDA kernel under an explicit set of assumptions. It also asks the LLM to prove thread safety and data race freedom of the generated kernel in VerCors, a deductive verifier for parallel code. Our main contribution to the formal verification of LLM- generated GPU kernels is showing that a combination of Lean automation and language-model-guided proof construction can verify a broad set of basic neural- network building blocks over floating-point values, allowing LLMs to implement semantically correct and safe kernels. In our framework, floating-point verifications never rely on compiled code and are always checked via the Lean kernel.
Create a lesson
Related papers
Metamorphic Testing for Floating-Point Performance Issues in SMT Solvers
Shared title terminology · Rosa Abbasi, Eva Darulova
Crustify: Repository-Level Generation of Safe Rust Bindings with LLM Agents and Coverage-Guided Testing
Shared title terminology · Marius Momeu, Marius Arvinte, Cory Cornelius et al.
PastaLean: Deterministic transpilation from Python to Lean for Verification
Shared title terminology · Anirudh Gupta, Petros Markopoulos, Siddhartha Gadgil
What is a Good Projection?: Correctness and Separation Results of End-Point Projections
Shared title terminology · Jake Masters, Nobuko Yoshida
Validating Concurrent Correctness Witnesses with Ghosts by Thread-Modular Abstract Interpretation
Shared title terminology · Michael Schwarz, Zhendong Ang, Umang Mathur
Python Code Generation for Isabelle/HOL
Shared title terminology · Nikolaus Huber, Roly Perera, Dominic Orchard