SentryWard: Formal Verification of Warp-Specialized GPU Kernels

Mengdi Wu, Sreeram Vennam, Stephen Mell, Ziwei Zhou, Advay Kadam, Xinhao Cheng, Francois Costa, Alex Aiken, Oded Padon, Zhihao JiaarXiv 2026

TL;DR

Modern AI runs on hyper-optimized GPU kernels where groups of threads work asynchronously like a high-speed relay team, passing data in the dark without waiting in line. Testing these kernels with random inputs misses rare, schedule-dependent timing bugs, so the authors built SentryWard: a formal verification framework that mathematically proves modern GPU code is free of race conditions and computes the exact right math across all possible execution schedules. Along the way, it caught subtle synchronization bugs lurking in industry-standard libraries like PyTorch, CUTLASS, and vLLM.

What Problem Does This Paper Address?

Traditional GPU kernels operate in lockstep: all threads load data, wait together at a barrier, and then compute. Modern GPUs (like NVIDIA's Blackwell architecture) break this mold to squeeze out maximum speed. Using warp specialization, different groups of 32 threads (warps) take on specialized roles—for instance, "producer" warps fetch memory asynchronously using dedicated hardware (TMAs) while "consumer" warps crunch matrix math on tensor cores.

To coordinate this chaos, modern GPUs use asynchronous transaction barriers called mbarriers. Unlike traditional barriers that simply count arriving threads down to zero, an mbarrier tracks both thread arrivals and byte transactions—meaning its counters can bounce up (when new transfers are announced) and down (when transfers finish) within the same round. If a counter accidentally hits zero prematurely due to a quirk in hardware scheduling, the barrier opens early, causing data races, premature memory deallocation, or silent data corruption. Standard testing can't catch all of these bugs because a kernel might pass 1,500 random tests and only fail under one rare hardware timing schedule. Existing formal verifiers don't model these non-monotonic byte-counting barriers.

Methods

SentryWard takes compiled NVIDIA PTX assembly code, a fixed launch configuration (grid/block sizes and tensor shapes), and a reference PyTorch implementation, then runs a multi-stage verification pipeline:

Figure 3: The pipeline: representations (blue), analyses (white), inputs (grey).
  1. Dual Views: After unrolling loops for the fixed configuration, SentryWard splits the program into an Event View (tracking when instructions issue, execute on async hardware, and update barriers) and a Value View (tracking memory addresses and math expressions).
  2. Synchronization Verification: Rather than brute-forcing every possible thread interleaving, SentryWard simulates one execution trace to build a candidate ordering graph. It then extends prior "well-synchronization" theory by introducing a completion check—cleverly framed as a graph minimum-cut problem—to prove that no mbarrier phase can ever hit zero prematurely across any valid schedule.
  3. Memory Safety & Determinate Reads: With a single, schedule-independent "happens-before" graph established, SentryWard uses an SMT solver to verify that conflicting memory accesses never overlap unordered (race freedom) and hardware resources like tensor memory aren't freed while still in use.
  4. Functional Equivalence: Because race-free, well-synchronized code behaves deterministically, SentryWard symbolically eliminates intermediate memory steps, turning the kernel into pure math formulas over the inputs. It proves equivalence against the PyTorch reference using generating functions and algebraic identity testing.
  5. Indexed Templates: To keep verification from exploding on thousands of threads and massive matrices, repeated thread events and loops are compressed into parameterized templates and mathematical "folds."

Datasets

Rather than training a model, the authors assembled an evaluation benchmark of 189 kernel configurations targeting NVIDIA Blackwell GPUs, drawn from 12 widely used libraries and compilers: CUTLASS, DeepGEMM, FlashAttention, FlashInfer, FlashMLA, PyTorch, TensorRT-LLM, ThunderKittens, TileLang, TIRx, Triton, and vLLM. This suite spans human-written, compiler-generated, and AI-agent-produced kernels covering matrix multiplication (GEMM), attention, linear attention/state-space models, normalization, and softmax.

Key Insights and Ideas

  • One trace to rule them all: Exploring every asynchronous interleaving is intractable. Proving well-synchronization via min-cut on a single reference trace collapses an exponential scheduling nightmare into one deterministic happens-before graph.
  • Non-monotonic barriers can trip early: Splitting transaction byte announcements across multiple steps (instead of announcing total expected bytes upfront) creates a window where fast hardware copies finish early, zeroing out the barrier counter and unleashing consumer threads onto unwritten memory.
  • Compilers and humans over-synchronize, too: Formal verification isn't just a bug-finder; it's an optimizer. Developers often sprinkle defensive barriers into complex code. SentryWard can safely strip away redundant synchronization points while guaranteeing safety.

Key Results

  • Speed & Coverage: SentryWard verified 105 of the 189 configurations (taking a median of 14.9 seconds for successful verifications, and 5.5 seconds across all runs) and flagged 64 configurations with potential correctness issues.
  • Real-World Bug Hunting: The tool uncovered real, previously unknown synchronization, race, and resource-lifetime bugs that were confirmed and fixed upstream by developers in CUTLASS, FlashMLA, FlashInfer, and vLLM, plus historical bugs in PyTorch 2.8 and TensorRT-LLM. In one FlashMLA kernel that passed all 1,534 standard tests, injecting a tiny delay exposed wrong outputs in 637 cases—which SentryWard's fix resolved.
  • Free Speedups: Using SentryWard to greedily remove redundant barriers across 95 kernels eliminated 37.7% of executed synchronization points, speeding up 83 kernels by up to 15% (1.0% median) on an NVIDIA B200 GPU.

Limitations and Future Work

SentryWard relies on four notable assumptions:

  1. Fixed Configurations: Verification applies to one fixed launch configuration and tensor shape at a time, requiring loop unrolling.
  2. Static Control Flow: Branch conditions and loop bounds cannot depend on runtime tensor values (17 benchmark kernels with dynamic control flow were rejected as unsupported).
  3. Strong Memory Model: It assumes writes become globally visible immediately upon execution, leaving weak-memory visibility effects and memory fences unchecked.
  4. Real Arithmetic: Functional equivalence treats floating-point math as exact real numbers, ignoring floating-point rounding discrepancies, and relies on predefined inductive invariants for complex recurrences like online softmax. Future work is not explicitly outlined in the paper, though lifting these assumptions represents the natural frontier.

Summary updated

Abstract

Modern GPU kernels overlap asynchronous data movement, computation on general-purpose cores (e.g., CUDA cores), and computation on specialized cores (e.g., tensor cores) using warp specialization. These asynchronous-overlap optimizations introduce complex synchronization requirements, where incorrect ordering of asynchronous operations can lead to data races, premature resource reuse, and incorrect results. Testing alone cannot guarantee correctness because such errors are nondeterministic and may only manifest in rare execution schedules, and existing GPU formal verification techniques have limited support for warp-specialized kernels. We present SentryWard, a framework for formally verifying warp-specialized GPU kernels. SentryWard integrates synchronization verification, data-race and resource-lifetime analysis, and functional equivalence checking. The key idea is to establish that synchronization induces the same ordering constraints across all possible execution schedules. SentryWard extends this well-synchronization analysis to modern GPU barriers with asynchronous transaction tracking and derives a schedule-independent happens-before graph. It then uses this graph to verify memory safety and construct symbolic output expressions for functional equivalence checking. While SentryWard generally assumes tensor shapes and kernel launch configurations are given and unrolls loops, it uses compact representations of repeated structures across threads and tensor computations to improve scalability. SentryWard is publicly available at https://github.com/gpu-verifier/sentryward.
BibTeX
@misc{wu2026sentryward,
  author = {Mengdi Wu and Sreeram Vennam and Stephen Mell and Ziwei Zhou and Advay Kadam and Xinhao Cheng and Francois Costa and Alex Aiken and Oded Padon and Zhihao Jia},
  title = {{SentryWard: Formal Verification of Warp-Specialized GPU Kernels}},
  year = {2026},
  eprint = {2611.33817},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.33817},
}
Figure