vikrant69g blog

Someone built a formal verifier for LLM-written CUDA code

A new tool checks if ChatGPT's GPU kernels are actually correct before you run them in production.

Abstract representation of mathematical verification symbols overlaid on GPU architecture diagrams

A research team just released a verifier for LLM-generated GPU kernels that uses formal methods to prove correctness. The tool takes CUDA code from an LLM and mathematically verifies it matches the spec before you compile anything. This is wild because most people treat LLM-generated code as suspect by default. You read it, you test it, you hope the edge cases do not burn you. Formal verification skips the hope part. It proves the kernel is correct or tells you exactly where it breaks. The contract-grade bit means you specify what the kernel should do in a formal language, then the verifier checks if the generated code actually does that. No runtime bugs from off-by-one indexing. No silent data races. No “it worked on my laptop” disasters when you scale to 8 GPUs. GPU kernels are a perfect target for this. They are small, deterministic, and expensive to get wrong. A matrix multiplication bug in a training loop can cost you days of compute before you notice the loss curve looks weird. Formal verification catches that before the first kernel launch. The catch is writing the formal spec. You still need to know what correct looks like. The verifier does not invent requirements. It just checks if the code matches the contract you wrote. That’s harder than it sounds when the spec is “make this model train faster without breaking anything”. I would use this if I were generating CUDA kernels for production. The cost of a verified kernel is front-loaded: you write the spec once, then every LLM iteration gets checked automatically. The cost of an unverified kernel is back-loaded: you find out it was wrong after it already ran on customer data.


Source: A Contract-Grade Verifier for LLM-Generated GPU Kernels