syncsan
syncsan finds data races in GPU megakernels. It runs your CUDA program unchanged under
NVBit and reports every pair of memory accesses that no barrier, fence,
release/acquire or async-copy wait puts in order. With SYNCSAN_ADVERSARIAL=1 it also hands each racy load the stale
value the PTX memory model allows, so you can see what the race does to your output.
Megakernels need this more than most code. They run a whole model in one launch and pass activations between SMs through counters in global memory. A missing fence in one of those handoffs rarely fails on today's GPUs, so it survives testing.
Quick start
You need Linux, an NVIDIA GPU of compute capability 7.5 or newer (T4, RTX 20 series and later), and CUDA 12. It runs
on Colab's free T4:
pip install syncsan
syncsan build --arch 90 # once; your GPU's compute capability: 75 T4, 80 A100, 90 H100, 100 B200, 120 RTX 50xx
syncsan run -- python generate.py
To see it work before pointing it at your own code, try examples/handoff.cu. It is the most common megakernel bug in 30 lines: one block writes data, fences and bumps a counter, and another block spins on the counter and reads the data with no fence after the spin.
$ nvcc -arch=sm_90 -lineinfo -o handoff examples/handoff.cu
$ ./handoff
sum = 32896 (expected 32896): correct
$ syncsan run -- ./handoff
syncsan: RACE (write then read) at 0x7ef8ffe00300
block 1 warp 2: STG.E desc[UR6][R2.64], R5 ; [handoff(unsigned int*, int*, int*)+0x1e0 handoff.cu:15]
block 0 warp 2: LDG.E R2, desc[UR6][R2.64] ; [handoff(unsigned int*, int*, int*)+0x120 handoff.cu:26]
sum = 32896 (expected 32896): correct
$ SYNCSAN_ADVERSARIAL=1 syncsan run -- ./handoff
sum = 0 (expected 32896): WRONG
The kernel gives the right sum on the GPU, syncsan points at the write on line 15 and the read on line 26, and
adversarial mode shows the wrong sum the memory model allows. Rebuild with -DFIXED, which adds the fence after the
spin, and syncsan reports nothing. Build your own kernels with -lineinfo so the reports name source lines.
--kernel NAME checks only the kernels whose name contains NAME, --exitcode 1 makes a race fail your CI
(example workflow), and --sample k checks one in k plain accesses when the full
check is too slow. syncsan run --help lists the rest.
What it has found
The clearest case is SuperLU_DIST. A commit that fixed a dropped fence in its GPU triangular solve restored the consumer's acquire but left out the producer's release. syncsan flagged the producer's decrement, and in adversarial mode the solve came back with an error of 0.7. On the fixed commit the error is 6e-15. The maintainers confirmed it and fixed it the same day (xiaoyeli/superlu_dist#261).
In Hazy Research's Llama-1B megakernel, activations move between SMs
through a TMA store, a relaxed atomicAdd on a counter and a volatile spin, with no gpu-scope fence. syncsan
reports 25 racing pairs, and in adversarial mode the model stops making sense (H100, 8 tokens):
| Build | Mode | Output |
|---|---|---|
| original | native | "Why did the cookie go to the" |
| original | adversarial | "iteriteriter abstractجرineronde" |
| original | control | "Why did the cookie go to the" |
| release/acquire counters | adversarial | "Why did the cookie go to the" |
The control run redirects the same loads but hands them their current values, so the redirection itself is not what
breaks the output. This race also fails on real hardware. When silu_out is filled with NaN before each step, the
original megakernel reads the NaN in all 1,000 generations and the fixed one in none. Making the counters
release/acquire fixes it at a 9% latency cost
(HazyResearch/Megakernels#16).
The other finds:
- AutoMegaKernel waits with
atomicAdd(c, 0), which a comment calls an acquire but PTX treats as relaxed. In adversarial mode its own--verifycheck fails (RightNow-AI/AutoMegaKernel#6). - megakernel-zoo and Lucebox
release correctly but spin on a
volatileload with no fence after it. In both, the adversarial output is garbage and a fence after the spin fixes it (dangxingyu/megakernel-zoo#3, Luce-Org/lucebox#1075). - Mirage MPK's argmax reduction has no barrier between warp 0 reading the per-warp maxima and the other warps writing the next row's (mirage-project/mirage#843).
- Magni VM had an admission race that 3,200 passing test runs never hit (Bobliuuu/mvm#97).
- On CUTLASS 3.6.0, syncsan finds the known Stream-K race from issue #2027, and it finds nothing in the fixed 3.7.0.
Each one has a write-up in docs/findings and a script in reproduce that reruns it on a rented GPU. The summary of every run is in results.
What it checks
syncsan follows the PTX memory model for global memory between thread blocks and for shared memory between warps,
including mbarriers and the Hopper and Blackwell copy engine (TMA, cp.async.bulk, cp.async). It does not check
races between lanes of one warp, distributed shared memory, or ordering across kernels and streams. It is slow: a
4-token decode of the Hazy megakernel takes 54 s under syncsan and 14 s without it.
docs/how-it-works.md describes the model and its limits, and
docs/prior-work.md compares syncsan with Barracuda, iGUARD, SuperCollider and compute-sanitizer.
Tests
tests/run_tests.sh sm_90 runs 51 cases with known answers on a local GPU. All 51 pass on an H100; on a T4, the 33 that
don't need newer instructions pass and the other 18 are skipped. tests/cuhadron adds six
cross-block synchronization tests to NVIDIA's cuHadron race benchmark.
License
Apache 2.0. To cite syncsan, see CITATION.cff.
Metadata
Release files for syncsan 0.10.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| syncsan-0.10.5.tar.gz | 44.4 kB | Without provenance | Details for syncsan-0.10.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| syncsan-0.10.5-py3-none-any.whl | Python 3 | none | any | Details for syncsan-0.10.5-py3-none-any.whl |
Total release size: 90.5 kB
Release files / syncsan-0.10.5.tar.gz
| Download URL | syncsan-0.10.5.tar.gz |
|---|---|
| Size | 44.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1743542f75f38eada039ca3ded7d6ae1ad62624620c748aeb2da6333899fe9b
|
|
BLAKE2b-256 checksum How to use checksums |
beaffb9946022656c25b2ac9a0508b4534c4dd193bc34d1c668c3a649e127702
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / syncsan-0.10.5-py3-none-any.whl
| Download URL | syncsan-0.10.5-py3-none-any.whl |
|---|---|
| Size | 46.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ac232629ea1af28ab113bd4a573dd3b4021c5c0d1c3f7493835692647f35d2d
|
|
BLAKE2b-256 checksum How to use checksums |
855a61692335f77d68a8907f750dd341f93c13d57fde53d4ed7da66b6f036a28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for syncsan 0.10.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.