Performance measurement · Research feature

Study Validates GPU Kernels Using Testing, Reduction, and Formal Proof

A new method combines testing and formal verification to validate GPU kernels across languages and frameworks, uncovering bugs that traditional approaches miss.

Adapted from research by Ashkan Vedadi Gargary, Guido Martínez, Sebastian Burckhardt and colleagues.

arXiv preprint revision · 2026-10-05 · Attribution & reuse
In this article
Editorial illustration of processor die.

Editor’s introduction

The RESOLVE framework evaluates GPU kernels through three stages: first, it detects nondeterminism using binary instrumentation to expose race conditions; second, it rewrites kernels into simpler, bitwise-identical ‘reduced-concurrency’ versions; third, it formally proves equivalence using the F*/Pulse framework, eliminating reliance on numeric tolerances. This approach successfully validated a range of kernels from KernelBench and identified four previously unreported issues, including two clear bugs, in complex fused GEMM operations across CUTLASS, Triton, and Gluon. The study demonstrates that RESOLVE can detect synchronization faults and validate optimized kernels in production-like settings. A key limitation is that the binary-level instrumentation cannot perturb certain asynchronous operations or intra-warp races due to hardware-level synchronization constraints like BSSY and BSYNC, and cannot address conflicts between CTAs that are never co-resident.

Introduction

GPU kernels determine much of the performance of modern AI workloads. Recent systems have shown that AI agents can generate and optimize these kernels, producing candidates far faster than humans can review them for correctness. Kernel generation is therefore creating a new validation bottleneck: an optimization that cannot be trusted cannot safely be deployed, regardless of its speed.

The predominant method for validating GPU kernels is reference-based testing: execute a candidate and a trusted reference on representative inputs and compare their outputs. This approach is often effective for machine-learning kernels, whose behavior is determined largely by tensor shapes, data types, layouts, and other discrete configurations that can be sampled systematically. Nevertheless, two challenges remain even with broad input coverage.

First, concurrency bugs may manifest only under rare thread or warp schedules and therefore remain hidden across repeated executions. Second, valid optimizations may reorder floating-point operations and produce outputs that are not bitwise identical to the reference. Testing must consequently compare outputs using a numerical tolerance, but a permissive tolerance can conceal bugs while a restrictive one can reject valid optimizations.

Formal verification can instead establish equivalence for all inputs covered by a specification. Its applicability, however, is limited by the verifier’s semantic coverage. Modern kernels rely on warp intrinsics, asynchronous memory operations, tensor-core instructions, and synchronization patterns that existing verification frameworks do not fully model. Because GPU programming models and hardware features evolve faster than their formalizations, directly verifying optimized production kernels remains impractical.

This paper presents RESOLVE, a GPU-kernel validation framework that bridges the gap between the broad applicability of testing and the rigorous guarantees of formal verification. RESOLVE’s central idea is to separate concurrency correctness from functional correctness, and to use a different validation technique for each. This decomposition exploits a key property of machine-learning kernels: they are generally intended to be deterministic, producing the same output for a given input regardless of thread schedule. This allows RESOLVE to focus on capturing a broad set of concurrency issues as schedule-dependent nondeterminism, while deferring functional equivalence to a formal proof.

GPU Background and Setup

A GPU is built from many simple cores and gets its performance from running enormous numbers of threads. Recent GPUs also have fixed-function tensor cores that perform a small matrix multiply in a single instruction. A GPU function is called a kernel, and many thousands of threads run it at once. Threads are grouped into warps of 32 that advance together, warps into cooperative thread arrays (CTAs, also called blocks) whose threads share a fast on-chip scratchpad, and CTAs into a grid that covers the device. The newest hardware adds a cluster level between the CTA and the grid. Memory follows the same levels: each thread has private registers, each CTA has shared memory that only its own threads can reach, and every thread can reach a large global memory. Launching a kernel runs one grid to completion.

Most kernels are still written in CUDA, but a lot of performance work now happens in languages above it. Triton lets a kernel be written over tiles and leaves the compiler to assign work to threads and to place data in shared memory. Gluon sits on the same compiler but exposes layouts, memory movement and asynchrony, so the programmer controls what Triton decides. CUTLASS is a C++ template library of hand-tuned building blocks for matrix multiply and its epilogues. Vendor libraries such as cuBLAS and cuDNN ship as binaries, with no source or PTX to inspect. The only common foundation is SASS, the relatively undocumented binary code for NVIDIA GPUs, unique to each architecture.

Kernels have been getting larger. A single operation is usually limited by memory rather than arithmetic: it reads its inputs from global memory, computes, and writes the result back for the next operation to read again. Fusing several operations into one kernel removes those round trips. Fusion used to mean a matrix multiply with an activation attached to it. Now it means the whole MLP block of §6.3, the multi-layer perceptron that follows attention in every transformer layer of a modern LLM, or the mega-kernels of §6.4, which put an entire model in one launch. Two of those mega-kernels implement a mixture of experts, which replaces the MLP block with many copies of it and routes each token to a few.

Fusing more work into one kernel puts more concurrency in it, and spreads that concurrency across more scopes. This paper is concerned with races: memory conflicts, at least one of them a write, unordered by synchronization. A race gives a different outcome depending on the scheduler. Races can occur at every level of the hierarchy, and each level has its own way of ordering accesses: threads in a warp advance together, threads in a CTA can be ordered with __syncthreads, and separate CTAs need a grid-wide barrier or atomics. The memory scopes match, so shared memory can only be raced on from inside one CTA and global memory from anywhere. Asynchronous copies and TMA transfers add another boundary, between issuing a transfer and the point at which its result is safe to read.

Reasoning about GPU programs almost always requires reasoning about floating-point computation, which does not behave like real arithmetic. Addition is not associative, so summing the same values in a different order changes the last bits, and any kernel that splits a reduction across threads is choosing an order. Fast-math flags widen the gap by letting the compiler reassociate, contract a multiply and an add into one fused operation, and replace a division by a reciprocal. Transcendental functions have no exact implementation, so an exponential ends up as a polynomial or a Taylor series, and two kernels can choose different ones. Tensor cores accumulate in their own precision and their own order, so a matrix multiply run on them does not agree bit for bit with the same multiply built out of ordinary fused multiply-adds. Two kernels that compute the same mathematical function may not produce the same bits.

Does the schedule change the output?

The third pass inserts the delays: NVBit places a call before a selected memory instruction, and that call stalls the issuing thread for up to a set number of cycles, with a configured probability so that not every execution is delayed.

Perturbing a schedule to expose a concurrency bug is an old idea, and the search has to be bounded somehow: by systematic exploration, by randomized scheduling with a probabilistic guarantee, by directing it at reported races, or on GPUs by bounding the number of delays and directing them at conflicting atomics. We bound ours by scope, using the trace to decide where a delay could matter, which keeps the binary as the only thing we need.

RESOLVE is configured with a memory region, global or shared, and a scope, and delays only the instructions the trace placed there. An inter-block delay derives the stall from the CTA index; an intra-block delay derives it from the warp identifier. A conflict across CTAs is exposed by separating CTAs, not by reordering warps inside one. How many CTAs to perturb is a configuration knob here too. The cycle count and probability are parameters we fixed rather than results. Surprisingly, neither mattered: §6.2 shows detection did not change across the ranges we swept.

RESOLVE compares the perturbed runs against an unperturbed baseline, byte for byte on the same input, stops at the first difference, and reports that difference and nothing else. Turning it into a root cause is separate work. In §6.4 agents did that from these reports, and each proposed fix was validated by running the same test again.

Limitations

RESOLVE does not perturb every scope, and the gaps follow from working at the binary level. We have no way to slow an asynchronous load through what NVBit exposes. We attempted to perturb intra-warp races and could not: every instrumentation site is bracketed by BSSY and BSYNC, the SASS instructions that synchronize and reconverge warp control flow, so the independent thread scheduler never gets the chance to interleave differently. Conflicts between CTAs that are never resident at the same time are also out of reach; SuperCollider shuffles block identifiers to bring such pairs together, which needs compiler access that we do not want to require. A clean campaign is not a proof of race freedom, but surviving it is strong, language-agnostic, black-box evidence that the kernel computes a deterministic function, which is what the rest of RESOLVE needs.

Reduction

Concurrency, more than size, is what puts a fully optimized GPU kernel out of reach of a verifier. The functional properties of asynchronous copies, TMA, producer-consumer pipelines and the barriers coordinating them have not been formalized, especially the corner cases that arise when using these synchronization constructs. Modeling each new construct as it arrives has not kept pace with the hardware. However, verification tools do work on much simpler programs, so RESOLVE reduces the kernel to one of those.

Reduction runs on a candidate that passed determinism testing (§3) and whose output differs from the reference. When their outputs agree bitwise on every test, RESOLVE stops there: the candidate has been tested to compute a function, and that function matches the reference. Reduction could produce the same program from both sides, and the proof step would add nothing. This is not unusual, since 15 of the 100 pairs in RKB are bitwise identical (§6.2).

Reduction usually reaches a single thread, but not always. The exact floating-point behavior of tensor cores is difficult to model in one thread, especially across data types, and could evolve across architectures. We expect the future to bring more such instructions. Rather than reduce away from them, we allow the least concurrency the instruction requires, which for a tensor core is a single warp, and for the warpgroup instructions on Hopper is four. Modern verification tools such as Kuiper provide semantics for these instructions over the reals, so the reduction can keep them rather than imitate them. The floor is set by the instruction, which is why the rule is as little concurrency as possible and not a single thread.

A reduction is accepted only if it reproduces the output of the original, bitwise, on every tested input. There is no tolerance, no epsilon and no normalization in this comparison. We have found modern agents, with the testing tooling available to them, very capable of producing reductions that pass. The result is now a simplified program that a verifier can reasonably handle.

Evaluation

The RESOLVE stages vary in how much time and tokens they consume. The determinism tester is cheap: it samples rather than tracing everything, prunes the scopes where a kernel can have no conflict, and works on the compiled binary. That leaves it fast enough to run in a tight loop, or inside a full application wherever a deterministic output can be logged and checked (§6.4). Reduction, specification and proof are agent tasks and are much slower and more costly. In our context, this is acceptable, given that the primary goal of RESOLVE is to validate kernels as part of a larger automatic optimization system which can run without human interaction, not an interactive tool for hunting bugs.

Catching synchronization bugs

Next we investigate how RESOLVE’s determinism tester fares on kernels containing synchronization errors. In particular, we were interested to see how many and what type of synchronization errors manifest as nondeterminism and subsequently get flagged. We first build a suite called RKB-Mutant by instructing an agent to inject a single synchronization fault into each RKB candidate, using four mutators in two groups.

Applying every mutator to every kernel gives 400 attempts, which we filter in two stages. An agent critic discards the attempts where the mutator had no site to apply to, such as a kernel with no barrier to remove or no shared destination to alias, which accounts for 202. Of the 198 that remain, a further 55 fail to run and are excluded. This leaves 143 mutant kernels.

The determinism tester flagged 92 of the 143 synchronization mutants. Testing one took 405 seconds on average, ranging from 88 to 4,587. A catch costs less than a clean run, because the tester stops at the first mismatch: the 92 it caught averaged 256 seconds and none took longer than 1,091.

We reviewed all 51 misses with the help of an agent, and they fall into three groups. Three are mutants injected into code that never runs, so there is no fault to catch. Twenty-eight introduce a race that never changes the value the kernel finally writes. The mutated kernel is still deterministic, which is the property RESOLVE checks, so it has nothing to report, and these 28 are exactly the case §3 makes when it separates a data race from a nondeterministic result.

The remaining 20 place their conflict inside a single warp, where no delay we can insert will separate two threads and we know of no perturbation an NVBit-based tool could apply to expose them. Every mutant that made a kernel nondeterministic and lay within reach of binary instrumentation was caught. Reaching inside the warp needs compiler support or a static analysis, and is future work. Per-mutant results are given in the artifact.

A Fused MLP Kernel

Our reference is PyTorch in eager mode, where the three operations run as three kernels. Against it we place three aggressively optimized variants, one each in Triton, Gluon and CUTLASS, each fusing the work into a single kernel and each written with the help of an agent. They are the fastest implementations of this operation we are aware of. We validate them at a representative size, a hidden dimension of 8,192 and an FFN intermediate size of 29,568 against 4,096 rows of activations. None of the three matches the reference bitwise, because the fusion reorders the reductions, and all three are intricate enough that correctness cannot be taken for granted. Gluon and Triton do match each other bitwise, so we carried only Gluon through specification and proof.

As far as we are aware, these kernels are out of reach for existing rigorous validation, on both halves of the problem. For concurrency, Compute Sanitizer runs on all three and reports nothing, which is the answer we expect and also all it can offer: a clean race report says neither that the kernel is deterministic nor that it computes the reference function. SuperCollider reaches individual accesses through a CUDA compiler pass, which two of our three variants cannot go through because they are not written in CUDA. For functional correctness, the kernels are built out of asynchronous memory copies and tensor core instructions, which verification tools such as ProofWright do not model.

New languages and compilers for writing this kind of code keep appearing, and which one produces the fastest kernel for a given operation keeps changing as they develop. An agent optimizing a kernel should be able to move it from any one of these languages to another and still know it computes the same function, which is what RESOLVE gives it.