arXiv:2610.24548cs.PLOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.24548

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.

1 Introduction

Modern ML model development begins with a high-level specification in frameworks such as PyTorch, which is lowered to hardware-specific kernels by compiler backends or expert engineers. This translation can leave substantial performance unrealised until the software stack catches up: on the same 512 H100 GPUs, NVIDIA reported a 27% year-over-year improvement on MLPerf GPT-3 training from software optimisations alone [8].

KernelBench tasks language models with automating this process by generating optimised GPU kernels directly from PyTorch specifications [19]. However, KernelBench-Verified shows that LLM-generated kernels can exploit weaknesses in finite correctness tests, producing implementations that appear correct and fast under the benchmark distribution but fail under broader inputs [24]. This motivates a verification layer in which the model must make its assumptions explicit and prove that the generated kernel is semantically equivalent to the high-level specification, rather than relying on its own tests or informal reasoning about correctness.

To tackle this problem, we implement an agentic framework making use of a formal verification layer in order to mechanically check semantic equivalence between high-level specifications and generated GPU kernels, as well as verifying the data race freedom of the parallel code. Our contributions are as follows:

∗^{*}Equal contribution.

NeurIPS 2026 Workshop on AI for Verifiable Coding.

  1. We demonstrate that Lean automation combined with language-model-guided proof construction can establish semantic equivalence for a broad set of basic neural-network kernels over floating-point values under explicit assumptions.

  2. We identify semantic failures in LLM-generated GPU kernels that pass conventional correctness tests and verification approaches that reason over R\mathbb{R} or Z\mathbb{Z}.

In Section 2, we briefly review related work in the area. Formal verification of LLM-generated code is a rapidly growing area and ensuring that the formal claims match up with the generated code is a key bottleneck, especially when floating point arithmetic is involved or highly important to the application of the generated code. In Section 3, we move on to describe the architecture of our agentic pipeline. The key components are:

• Deterministic compilers from both PyTorch specifications and a limited set of CUDA to Lean;

• Generator and Prover agents which are designed for creating the resulting CUDA code and proving its semantic equivalence with the PyTorch specification respectively;

• The leveraging of Velvet [10] in order to reason over imperative code in Lean via a Dafny-like manner;

• The VerCors [1] gate which aims to provide thread and memory safety of the generated code.

We also detail the purpose of each of the technologies we employ in our pipeline, and how they assist with our goal of providing a framework for producing verified GPU code. In Section 4, we experiment with setting the underlying model of the framework to both GPT-5.6 Terra and Claude Opus 5, 2^{2} and review some statistics about both runs. In Section 5, we provide representative case studies demonstrating examples in which the harness was able to catch semantic issues. Further case studies are provided in Appendix B. We finally conclude in Section 6 with a summary of our findings and a discussion of the limitations of our approach.