Authors’ overview
GPU kernels are the computational core of modern AI, yet a single data race can silently violate the integrity of training and inference. Formal verification promises data-race freedom, but no existing automated verifier handles asynchronous operations across general kernel inputs. We present TensorRace, the first automated framework to verify data-race freedom of modern GPU kernels. TensorRace builds a happens-before graph of the kernel to capture both synchronous and asynchronous operations as nodes and their orderings as edges. To build the graph soundly and efficiently, TensorRace proposes five well-formedness conditions for kernels. When a kernel satisfies them, TensorRace can soundly order asynchronous operations by comparing their static occurrence counts, without directly reasoning about runtime barrier phases and thread interleavings. TensorRace then proves a kernel race-free by checking with SMT solvers that the happens-before graph orders every pair of conflicting memory operations. We also introduce a series of optimizations for SMT solving precision and efficiency. We mechanize soundness proofs in Rocq and evaluate TensorRace on 345 real-world GPU kernels from four libraries, including components of frontier models such as DeepSeek V4 and Kimi Linear, and common machine learning operators. TensorRace verifies each GPU kernel for NVIDIA Hopper and Blackwell architectures. In verification, we find 12 new harmful races, all confirmed by developers and fixed.
Introduction
GPU kernels serve as the computational core of modern AI. These programs implement a model’s tensor operators, such as matrix multiplication and attention, and perform nearly all the computation for training and inference. A data race in GPU kernels occurs when two unsynchronized memory operations access the same address and at least one is a write. It can silently corrupt output tensors and put months of training at risk.
Formal verification can prove data-race freedom over all kernel inputs and thread interleavings, but modern GPU kernels are hard to verify. The complexity stems from the asynchronous operations introduced by modern GPU architectures: a kernel can issue an asynchronous data copy that executes as if by another thread, and threads can observe its completion via barriers. Verification thus requires reasoning about the runtime barrier phases at each asynchronous operation. However, existing automated verifiers either support synchronous barriers only or compute concrete phases on fixed inputs, leaving modern kernel verification beyond reach.
We introduce TensorRace, the first automated framework to verify data-race freedom for unmodified, modern GPU kernels. First, to capture the behaviors of both synchronous and asynchronous operations, TensorRace constructs a happens-before graph for each kernel. Each graph node is one execution of a memory or barrier operation, and a directed edge indicates that one node always happens-before the other. A data race thus occurs between two memory nodes if they access the same address, at least one is a write, and no path orders them with happens-before edges in either direction. For every pair of memory nodes, TensorRace checks for a race between them with an SMT solver. If all pairs are race-free, the kernel is race-free.
The major challenge of verifying data-race freedom is to soundly derive the happens-before edges: an edge asserts that one node happens-before another in all interleavings. For two same-thread nodes, TensorRace simply derives edges from the thread’s program order. For two cross-thread nodes, the ordering depends on the barrier phase at each node. A phase is a runtime value that varies with the thread interleaving. Directly deciding an edge for cross-thread nodes requires enumerating interleavings, causing state-explosion. To solve it, we propose five well-formedness conditions for GPU kernels. When a kernel satisfies all five, every node carries a static occurrence count, which TensorRace uses as a sound estimate for a barrier’s phase at that node. TensorRace thus derives each cross-thread edge by comparing the two nodes’ static occurrence counts, without enumerating interleavings. We prove all edge derivations sound in Rocq.
To scale this sound reasoning to production GPU kernels, TensorRace employs a suite of optimizations. First, it automatically infers each occurrence count as a closed form over the loop variables, thereby verifying kernels built on complicated program patterns such as software pipelining and warp specializations without unrolling large or unbounded loops. Second, proving a pair race-free normally requires searching a happens-before path across the whole graph. TensorRace avoids this expensive search for most pairs with an alias analysis: two nodes that access disjoint addresses cannot race, so TensorRace proves them race-free without the search, reducing verification time by orders of magnitude. Third, in real-world kernels, data-race freedom can also depend on functional properties over inputs that cannot be inferred from the kernel body alone. TensorRace allows declaring these functional constraints to rule out spurious races, and checks their validity at runtime.
Overview
For each pair of memory operations, TensorRace encodes Race as an SMT query and solves it by running multiple solvers in parallel (§6.1). A satisfying model is a concrete data race counterexample, providing the racing threads, loop iterations, and input parameter values that trigger the race; an unsatisfiable query proves the pair race-free.
Functional Constraints. The above occurrence count inference and alias analysis allow TensorRace to scale to real-world kernels, but the solver can still report spurious races, i.e., false positives. The root cause is that a kernel’s race freedom can depend on a property of its input parameters that is guaranteed by host-side code and cannot be inferred from the kernel body alone. TensorRace lets developers declare such properties as functional constraints. It then adds them as assumptions in SMT queries to rule out these spurious race reports and checks them at every kernel launch (§6.3).
Building the Happens-Before Graph
Here, each operation type (OpType) corresponds to a family of NVIDIA GPU primitives, classified in the Type column.A synchronous operation takes effect at issue, i.e., when its thread executes it. An atomic operation is an indivisible read-modify-write that also takes effect at issue. The hardware serializes concurrent atomics to the same address so they never race with each other. An asynchronous operation is issued by a thread but executed as if by another. Its memory effect becomes visible only at a separate completion event, observed by any thread’s mbarrier.wait or the same thread’s wait_group. A barrier operation signals an event (arrive, commit_group), or blocks its thread until the event happens (wait, wait_group, __syncthreads).
Cross-Thread Barrier Synchronization. Modern GPU kernels synchronize threads by mbarriers. Each mbarrier b counts down from a constant expected arrival count to zero as participating threads call b.arrive. When the countdown reaches zero, b completes its current phase and advances to the next, resetting the countdown. Each b.wait(p) blocks the calling thread until b’s phase parity differs from p.
From the hardware semantics above, we know barrier b’s phase increases with time, so any b.arrive happens-before any b.wait when the b.arrive’s phase is strictly less than the b.wait’s. However, the barrier phase at each node is a runtime value too complicated to reason about precisely: GPU hardware exposes only phase parity, and real-world kernels launch hundreds of concurrent threads that interleave arrives and waits over control-flows (Figures 1–2).
Cross-Thread Asynchronous Completion. Modern GPU kernels use asynchronous operations to overlap data movement with computation. Each asynchronous operation’s memory effect becomes visible only at its completion. On NVIDIA GPUs, the completion is tracked by either the mbarrier-based or the async-group mechanism.
Well-Formedness and Soundness
In practice, TensorRace checks Write-Independence with a taint analysis: the sources are the kernel’s writes; the sinks are the branch conditions, loop bounds, and synchronization arguments. Write-Independence holds if and only if no tainted value reaches a branch condition, a loop bound, or a synchronization argument.
The above five well-formedness conditions accept most synchronization patterns in modern GPU kernels, including the producer–consumer mbarriers of warp specialization, the multi-stage barriers of software pipelining, block-wide __syncthreads, and their combinations. In evaluation, all 345 real-world GPU kernels are proved to be well-formed (§7.1). We discuss limitations of well-formedness conditions in §9.
Closed-Form Count Inference
Building the happens-before graph requires each operation’s occurrence count to estimate barrier phases (§3). However, the challenge is that for an arbitrary kernel, an operation’s occurrence count per se can depend on thread interleaving, creating a circular dependency: the kernel’s control flow (e.g., loop bounds, branch conditions) may depend on shared memory whose contents vary across thread interleavings.
SMT Encoding
Second, to verify data-race freedom, TensorRace constructs an SMT query for each pair of memory-access nodes in the graph (lines –). Each query encodes all happens-before constraints and the corresponding Race condition (lines –, also §2). A satisfiable query yields a concrete race example. If all such queries are unsatisfiable, the kernel is race-free.
Memory Alias Analysis
Solution. TensorRace first checks same_addr alone as a memory alias analysis. This check is quantifier-free, so the SMT solver decides it in milliseconds under the quantifier-free bit-vector theory. If solvers prove same_addr to be always unsatisfiable, then it indicates that the two memory operations’ addresses will never conflict. Thus, TensorRace soundly verifies the pair race-free and never builds and proves the entire Race query. Only same-address memory operation pairs require solving the entire Race query.
Functional Constraints
Without any constraint, t2p may map two block indices to the same i, causing an inter-block write–write race, as in the figure above. In practice, this race never occurs, because the host-side code builds t2p to be injective, mapping every blockIdx.x to a distinct slot index i. This injectivity property holds on input t2p, thus cannot be inferred from kernel body code alone. TensorRace models each input parameter as an unconstrained symbol; so the solver can pick a colliding t2p and report a spurious race that never happens in real execution.
TensorRace encodes each declaration as an assertion in every SMT query, thus removing spurious races by ruling out the interpretations that make t2p non-injective. TensorRace also checks each assertion against the actual inputs at every kernel launch and rejects launching with any violation.
Evaluation
We answer the following questions: (1) Does TensorRace scale to modern GPU kernels? (§7.1); (2) Can TensorRace discover real races? (§7.2); (3) How does TensorRace compare to other verifiers? (§7.3); (4) How much manual effort does TensorRace require? (§7.4); (5) How critical are the TensorRace optimization techniques, both individually and in combination? (§7.5)
Experimental Setup. All experiments were run on a workstation with a 16-core AMD Ryzen 9 9950X CPU and 128 GB of RAM, running Ubuntu 20.04 with Linux kernel 6.18. We compile all kernels to TVM TIR with TileLang v0.1.12. TensorRace solves each SMT query with Z3 4.15.4 and cvc5 1.3.3 in parallel, under a three-minute per-query timeout.
Verifying Real-World GPU Kernels
All kernels are written in TileLang and compiled to TVM TIR for TensorRace to verify. We verify each kernel on the NVIDIA Hopper (sm_90) and Blackwell (sm_120) architectures it targets. This is because race freedom of the kernel compiled for one architecture does not imply race freedom for others. We reuse the official, default kernel configurations in the upstream library, including model tensor shapes, software pipeline stages, etc. TensorRace verifies each of them, with a total of 4,372 configurations in all 345 kernels.
Finding Data Races and Bugs
The four races share one root cause: the TileLang compiler misrecognizes the whole if-else branch (lines 6–17) as straight-line code that every thread runs from top to bottom. In that view, W2 and R1,R2 belong to one thread and never conflict, and W1 is already ordered before R1,R2 by an inner-loop barrier (line 8); so TileLang inserted no barrier.
Here block bid reads dvhat_buf[bid+1] (line 3, p=2), while block bid+1 writes the same address (line 4). Nothing synchronizes the two blocks, so whenever the write happens first, block bid reads the incorrect, overwritten value of dvhat_buf.
All threads within the block read and write mean[bx] concurrently (line 2), and the kernel is expected to update mean[bx] exactly once. So whenever a thread finishes its write, a later thread will read the updated mean[bx], thereby incorrectly updating mean[bx] twice and silently corrupting the result.
Security Implications of Harmful Races. The 12 harmful races silently corrupt model training and inference. In training, two DeepSeek V4 backward kernels in TileLang and TileOPs compute incorrect gradients. In inference, six forward kernels of Qwen 3.6, Kimi Linear, and DeepSeek models produce incorrect outputs. Moreover, the race in TileOPs’ BatchNormFwdTrainKernel corrupts the running mean during training, and propagates the corrupted value into inference. All bugs are confirmed by developers and fixed upstream.
Comparison with State-of-the-Art Verifiers
Result. TensorRace detects all 24 harmful races and proves each upstream-fixed kernel race-free. In comparison, none of the four prior verifiers captures all races. The first race checker is TileLang’s verify_parallel_loop pass. It checks only source-level races inside T.Parallel loop bodies and runs before barrier insertion and other TileLang-to-CUDA passes. So it misses all TileLang-introduced races. Among the three TileLang-source, developer-introduced races, it captures only the MHCPostKernel’s race. FaialAA and GPUVerify take each kernel’s CUDA source as input. They model single-stage __syncthreads and atomics but no asynchronous operations, so both fail on every kernel that uses mbarriers or asynchronous copies. GPUVerify is moreover unsound, claiming the 2 Megatron-LM harmful races to be race-free. Lastly, Weft takes each kernel’s PTX as input. It models Kepler-era named barriers, but lacks support for modern PTX instructions these kernels require.
The root difference between TensorRace and these verifiers is that TensorRace orders asynchronous operations by estimating their runtime barrier phases (§3–5). In contrast, these verifiers either model synchronous barriers only, whose phases are determined by the program structure alone; or compute the concrete phases of every node, failing to scale to real-world GPU kernels with large or non-constant loop bounds.
Manual Verification Efforts
In practice, developers define each functional constraint based on knowledge from the race report and host-side source code. When TensorRace reports a race, it provides the concrete input values that trigger the race. Developers then review the host-side code to understand whether such input values can ever be produced at launch time, and declare correct constraints. An incorrect declaration will be rejected at kernel launch and thus cannot violate the soundness. We defined all constraints for the 16 kernels in a few days.
Related Work
Static GPU Race Verification. GPUVerify verifies CUDA and OpenCL kernels in Hoare Logic with Boogie. PUG encodes CUDA kernels into SMT, but unsoundly misses cross-iteration races, while ESBMC-GPU applies context-bounded model checking. FaialAA checks race freedom via behavioral memory-access protocols to eliminate false positives. Volta checks ML kernel equivalence and race freedom by symbolic evaluation, and M2K extracts host-side shape constraints to symbolically execute CUDA kernels. All six model synchronous barriers only. Weft verifies kernels with Kepler-era named barriers, and SentryWard checks warp-specialized PTX kernels, but both unroll loops to compute concrete barrier phases on fixed inputs. TxVerify proves compiled PTX kernels interactively in Lean with manual per-kernel proofs and hardware axioms. In contrast, TensorRace automatically verifies modern GPU kernels across general inputs by estimating barrier phases with static occurrence counts.
Another line prevents races by defining domain-specific languages (DSLs). Accelerate, Futhark, and Lift use functional data-parallel languages to reject conflicting memory accesses, while Descend and Exo-GPU enforce safe memory and Tensor Core scheduling via ownership and effect types. Cypress and tile-level DSLs such as TileLang and cuTile delegate synchronization to the DSL compiler, which can cause races per se. In contrast, TensorRace verifies compiled TVM TIR, capturing races caused by both compilers and developers.
Dynamic GPU Race Detection. Another line of work detects kernel races by monitoring execution. NVIDIA Compute Sanitizer is the de facto standard. Research tools such as CURD, ScoRD, iGUARD, HiRace, SuperCollider, and CuFuzz cover more memory spaces and synchronization scopes. These detectors can find real races but cannot prove data-race freedom: a race is reported only when the tested input and interleaving trigger it. In contrast, TensorRace soundly verifies data-race freedom over all legitimate kernel inputs and thread interleavings (§4).
Ordering by Counting. Vector clocks decide happens-before by comparing per-thread event counts. The Bulk Synchronous Parallel model orders computation by superstep number. X10 clocks and phasers order each signal before the waits of later phases. All the counts above are runtime state. Static analyses of barrier programs count at compile time, but target synchronous barriers only. In contrast, TensorRace is the first to order modern GPU kernels’ asynchronous operations by static occurrence counts (§4).
Limitations and Future Work
Future Work. TensorRace’s applicability can be broadened by porting it to other kernel languages. Manual efforts can be reduced by inferring functional constraints from host code. Extending TensorRace to verify functional correctness and other properties is future work.


