r/CUDA • u/Schermaiolo • 49m ago
r/CUDA • u/shre_1308 • 19h ago
14 of 31 AI-written GPU kernels that pass their tests race under the PTX memory model (most often a grid barrier with no fence after the spin)
I build syncsan, a race detector for GPU kernels whose thread blocks hand data to each other through global memory. Those handoffs need a release and an acquire under the PTX memory model, and when one is missing the kernel usually still gives the right answer on today's GPUs, so tests don't catch it.
Models now write kernels like this (megakernels with grid barriers, flags, last-block reductions), so I ran syncsan on every public, test-passing, model-written kernel I could find that synchronizes across blocks. The older bulk datasets (Sakana's archive, KernelBench samples, CUDA-L1) had none; all 34 came from kernelbench.com's megakernel track and KernelBench-Hard, and 31 reached a verdict.
14 of the 31 race under the PTX model: 10 miss a release or acquire between blocks (most often a grid barrier that spins on a volatile counter with no fence after the spin), and 4 reuse shared memory without a barrier. In 7, handing the racing loads the stale values the model allows makes the benchmark's own check fail, while a control run passes. None failed in normal runs, so this is about what the memory model permits, not failures seen on hardware. Each bug shape is checked with Dartagnan's formal PTX model, and syncsan's own false positives on this set are listed in the write-up. There are 1 to 3 kernels per model, so this says nothing about which model is better.
Write-up with per-kernel verdicts and source lines: https://github.com/ShreshthRajan/syncsan/blob/main/docs/findings/ai-kernels.md (I'm the author of syncsan.)