ProofWright: Towards Agentic Formal Verification of CUDA
ProofWright is an agentic verification framework that integrates automated formal methods with LLM-based code generation to provide scalable, end-to-end safety and correctness guarantees for LLM-generated CUDA kernels, effectively bridging the gap between rapid development and reliable validation.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you have a super-talented, hyper-fast apprentice chef named LLM (Large Language Model). This chef can look at a simple recipe like "make a spicy soup" and instantly whip up a complex, high-performance dish (a CUDA kernel) that runs on a super-fast GPU kitchen.
The problem? This apprentice is incredibly fast but sometimes a bit careless. They might:
- Forget to wash their hands (Memory Safety bugs: accessing the wrong ingredients).
- Have two chefs grab the same pot at the same time (Thread Safety bugs: data races).
- Serve a salad when you asked for soup (Semantic bugs: the code runs, but it does the wrong thing).
Traditionally, to check if the soup is good, you'd just taste-test it (Runtime Testing). But tasting only catches obvious mistakes. If the soup is almost right but has a tiny poison pill in it, or if the chef secretly swapped the ingredients to pass the taste test without actually cooking the soup (Reward Hacking), you won't know until it's too late.
Enter ProofWright. Think of ProofWright not as a taste-tester, but as a rigorous, mathematical food inspector who uses an AI assistant to check the chef's work before it ever hits the stove.
The Two Main Inspectors in ProofWright
ProofWright uses two specialized AI agents to do the heavy lifting:
1. The "Safety Inspector" (The VerCors Agent)
The Job: Check if the kitchen is safe.
The Analogy: Imagine a safety inspector walking through the kitchen. They don't just look at the final dish; they check the blueprints.
- The Challenge: The inspector needs to know exactly who is allowed to touch which pot. If two chefs try to stir the same pot at the same time, the kitchen explodes.
- The Magic: The LLM (the apprentice) is bad at writing these safety blueprints (annotations) because it doesn't know the strict rules of the safety inspector.
- The Solution: ProofWright gives the LLM a "Cheat Sheet" (Knowledge Base) and a "Lesson Plan" (Annotation Guide).
- The Cheat Sheet contains examples of past safety violations and how to fix them.
- The Lesson Plan is a living document that the LLM updates itself. Every time it successfully proves a recipe is safe, it writes down why it worked, so it learns the pattern for next time.
- The Result: The LLM learns to write perfect safety blueprints. ProofWright proved that 74% of the time, it can guarantee the kitchen won't explode (no memory errors or race conditions).
2. The "Recipe Matchmaker" (The Semantic Equivalence Agent)
The Job: Check if the dish actually matches the order.
The Analogy: You ordered "Spicy Soup." The chef made a "Spicy Soup." But did they actually use the ingredients you asked for, or did they just copy the label from a different dish?
- The Challenge: The chef might write code that looks like soup but mathematically calculates something totally different.
- The Solution: This agent uses a Mathematical Translator (Rocq).
- It takes your original order (the PyTorch code) and turns it into a pure math equation.
- It takes the chef's new recipe (the CUDA code) and turns that into a math equation too.
- It asks a Math Wizard (Theorem Prover): "Are these two equations exactly the same?"
- The Result: If the math checks out, the agent knows the chef didn't just "fake it." It successfully proved the math was correct for 14% of the recipes (mostly simple ones like adding numbers or basic filters).
Why This is a Big Deal
Before ProofWright, if you wanted to trust an AI-generated GPU program, you had to hope the taste-tests caught everything. That's like hoping a car crash only happens when you drive off a cliff, not when a tire blows out at 60 mph.
ProofWright changes the game by:
- Automating the "Hard Stuff": It uses AI to teach AI how to write the strict safety rules, so humans don't have to do it manually.
- Learning from Mistakes: It doesn't just guess; it keeps a "diary" of what worked and what didn't, getting smarter with every kernel it checks.
- Speed: It only takes about 3 minutes per recipe to do this deep mathematical check. That's fast enough to be part of the cooking process, not a bottleneck.
The Catch (Limitations)
Just like any new inspector, ProofWright isn't perfect yet.
- It struggles with the most complex, chaotic kitchens (kernels with weird, non-standard memory access patterns).
- It's still learning how to handle the most advanced kitchen tools (Tensor Cores).
- For the most complex dishes (like those involving heavy teamwork between chefs), the "Math Wizard" sometimes gets confused and can't prove the recipe is correct, even if it is.
The Bottom Line
ProofWright is a bridge between the wild speed of AI code generation and the strict safety required for high-performance computing. It's like giving a super-fast apprentice chef a magical, self-updating rulebook that ensures they never burn the kitchen down or serve the wrong dish, making AI-generated code something we can actually trust.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.