AIFeed

AI-written GPU kernels: 14 of 31 that pass their tests race under the PTX model

Original text(via HN AI)

Data races in AI-written GPU kernels that pass their tests

Language models now write GPU kernels that synchronize thread blocks through global memory: grid barriers, flags, tickets, last-block reductions. Those handoffs need a release and an acquire under the PTX memory model, and a missing one rarely changes the output on today's GPUs, so a kernel can pass its tests and still be wrong under the model. We checked every public model-written kernel we could find that passes its tests and synchronizes across blocks.

Result

Of 31 test-passing, model-written kernels that synchronize across thread blocks, 14 contain a data race under the PTX memory model:

  • 10 are missing a release or an acquire in a handoff between blocks;
  • 4 have a race in shared memory inside one block (a buffer reused with no barrier in between).

In 7 of them, returning at the racing loads the stale values the PTX model allows (syncsan's adversarial mode) makes the benchmark's own correctness check fail, while the control run, which redirects the same loads but returns current values, passes. None of the 31 failed its check when run normally (1 to 4 runs each).

Every synchronization shape behind these verdicts is written as a litmus test and checked with Dartagnan's formal PTX models (6.0, 7.5 and stock 7.5): the racy shapes are racy and allow the stale read under all three, and the clean ones are clean.

This does not mean these kernels give wrong answers on current hardware; we never saw one do so. It means their correctness depends on an ordering the PTX model does not promise. Each model has one to three kernels here, so the data says nothing about which model writes better kernels.

Where the kernels come from

We counted kernels that pass their tests and synchronize blocks through global memory, reading each one.

SourceTest-passing kernelsWith cross-block sync
Sakana AI CUDA Engineer archive16,4590
KernelBench samplesabout 13,0000
CUDA-L11,2500
flashinfer-trace agent solutions3930
kernelbench.com Mega (Kimi-Linear decode megakernels)6931
KernelBench-Hard493

The older collections have none: their kernels are single-block-at-a-time operators. All of these come from 2026 frontier-model megakernel work. Of the 34, one had its cooperative path switched off, one failed its check natively on our setup, and one timed out under syncsan, which leaves 31.

The bugs

ShapeKernelsWhat is missing
Grid barrier polls a volatile counter, no fence after the spin4, 11, 27acquire
Grid barrier arrival is a relaxed atomicAdd with no fence before it5, 7release
Last block reads the other blocks' partials, but its only fence comes before its ticket (CUDA's threadFenceReduction shape)13, 15, 27acquire
Last arriver bumps the generation or sets the flag right after its relaxed ticket13, 19acquire
Fences in every thread, then a barrier, then a relaxed arrival by thread 06release (racy under PTX, probably harmless on current GPUs)
A block zeroes a buffer other blocks may still be reading34ordering between the phases
Shared-memory buffer rewritten with no barrier after it was read12, 17, 19, 21, 26__syncthreads()

A fence (__threadfence()) in the right place, or an ld.acquire / atom.release instead of the relaxed access, fixes each cross-block case; a __syncthreads() fixes each shared-memory case.

Per kernel

H100 and B200 kernels ran with the benchmark's graded random seeds only, because its newer attention cases stop with a grader error on H100 before any solution runs. Kernels graded on an RTX PRO 6000 ran on one.

#ModelNormal runAdversarial / controlVerdict
4GLM 5.2passfail (0.338) / passrace: no acquire after the spin
5GLM 5.3passfail (non-finite) / passrace: no release before the arrival
6Claude Fable 5.1passfail (0.94-0.97) / passrace under PTX only
7Muse Spark 1.3passfail (0.009-0.018) / passrace: no release before the arrival
11Claude Fable 5.2passfail (0.14-0.21) / passrace: no acquire after the spin
13Ergo 1.0passfail (0.85-0.89) / passrace: generation bump and last-block reads
15Claude Fable 5 (paged attention)passfail / passrace: last block reads without an acquire
19Kinetic-0715passpassrace: flag set without a fence; shared-memory race
27DeepSeek Flashpasspassrace: no acquire after the spin
34Gemini 4 Neonpassfails under instrumentation alonerace: buffer zeroed while still read
12, 17, 21, 26Gemini 4 Carbon, GPT-5.6 Sol (2), GPT-6 Astra Propassnothing to substituteshared-memory race inside a block
17 othersClaude Fable 5, 5.1, Opus 5.5, Sonnet 5.5, GPT-6 Sol, 6.1 Sol, 6.2 Astra (2), Gemini 3.8 Flash (2), Grok 4.5, 4.7, Muse Spark 1.3, Kinetic 1m, ...passno race found

The numbers in parentheses are the check's error measure against its tolerance. Case 4's adversarial failure is from syncsan's default mode only; the other six held with SYNCSAN_WARP_ORDER=0.

What syncsan got wrong

syncsan also reported pairs in kernels that are correct, and we did not count them:

  • Its default warp-order mode reported pairs across correct handoffs in two kernels (49 pairs in one, 5 across grid.sync() in another). They vanish with SYNCSAN_WARP_ORDER=0, and in one of them adversarial mode then broke the output with values the model forbids. So an adversarial failure here counts only once its pairs are shown to be real by reading the code and by the litmus test of its shape.
  • A counter reset after an acq_rel ticket, and write-after-read pairs across release/acquire barriers, in two more.

Every verdict above rests on reading the source against the PTX model, with syncsan pointing at the lines.

Reproducing

syncsan 0.11.1 from PyPI, built for the GPU each kernel was graded on, run through Modal: reproduce/ai_kernels. The kernels and their checks are MIT-licensed, from Infatoshi/kernelbench.com. The source lines behind each verdict are in VERDICTS.md.

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗