Skip to content

ptx-schedule: classify the asynchronous proxy pipeline as schedule sites - #1195

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:feat/ptx-schedule-async-proxy-sites
Aug 30, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:feat/ptx-schedule-async-proxy-sites

Conversation

@vyncint

@vyncint vyncint commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Closes #1113.

classify_instruction covered the synchronous ordering primitives and nothing from the asynchronous proxy. An opcode that classifies as nothing is not a site of any kind, so it received no injection and never appeared in a report — the pipeline a Hopper or Blackwell kernel is built around was the part a campaign could not reach.

Why none of the existing arms reached these

Each family misses for its own reason, which is why this was not a one-line oversight:

instruction why it fell through
cp.async.bulk.tensor...mbarrier::complete_tx::bytes carries mbarrier in its qualifiers but spells it mbarrier::, so it never matches the barrier arm's mbarrier.
wgmma.fence.sync.aligned a fence that does not start with fence.
tcgen05.ld.sync.aligned... splits to a base of tcgen05, so the ordered-memory arm returns before the ld/st test
clusterlaunchcontrol.try_cancel.async completes through an mbarrier like the bulk copy, and matches nothing at all

Adds SiteKind::AsyncProxy and one prefix arm for the four families. Taking each family whole matches how bar./mbarrier. and the warp collectives are already handled, and keeps the consumer halves (tcgen05.ld, clusterlaunchcontrol.query_cancel) as sites alongside the issues and waits they read.

Two corrections to the issue, both making the gap larger

372 instructions, not the 227 I filed. That figure came from a line-anchored grep; 120 of these sit inside single-line inline-asm blocks, which the parser finds and the grep did not. Measured with analyze_ptx over the 167 .ptx the corpus builds:

before:  total_sites=2093   async_proxy_sites=0
after:   total_sites=2465   async_proxy_sites=372

Per example: gemm_sol 206, gemm_sol_final 118, tcgen05_matmul 14, cp_async_zfill 3, wgmma 3, tma_copy 2, tma_multicast 1.

clusterlaunchcontrol.* is a fourth family the issue did not name — 25 instructions, same pipeline. Splitting it out would have meant two PRs editing the same match arms, so it is folded in and the issue is updated.

The perturbed PTX still assembles

The real risk in classifying these is emitting something ptxas rejects, and it is a risk I cannot answer by running the kernels: every affected example needs sm_80 or above, and the six Hopper/Blackwell ones cannot execute anywhere I have access to. So I assembled instead. Each of the 7 affected examples was perturbed at intensity 1.0 under 3 seeds and fed to ptxas for its own target:

perturbed:  21/21 assembled   (sm_80, sm_90a, sm_100, sm_100a)
originals:   7/7  assembled   (control)

Negative control, so the 21/21 is not vacuous — corrupting one injected instruction makes ptxas reject it:

$ sed 's/nanosleep\.u32/nanosleep.BOGUS/' wgmma__7.ptx | ptxas -arch=sm_90a
ptxas line 36; error : Unknown modifier '.BOGUS'
ptxas line 36; error : Unexpected instruction types specified for 'nanosleep'

Tests

Three, following redux_is_a_warp_collective_and_red_is_still_a_reduction — the closest precedent, since it also added a classification and had to prove it did not steal from a neighbour. Every opcode spelling in the fixture is taken verbatim from PTX the backend emits, not hand-written.

Mutations, each applied to the fixed tree:

mutation result
drop cp.async from the prefix list caught
drop wgmma. caught
drop tcgen05. caught
drop clusterlaunchcontrol. caught
add ld. (would swallow ordered memory) caught
relax the fence arm to contains() (would steal wgmma.fence) caught

That last one is what the negative-control test is for. I checked the symmetric case too and am reporting it accurately rather than claiming more: relaxing the barrier arm to contains() changes nothing, because the bulk-tensor opcode spells the qualifier mbarrier:: and so never contains mbarrier.. The test's comment says so.

Scope

  • The crate README carries the SiteKind table, so it gains the row in the same position; the two lists agree in order and content.
  • SiteKind has no exhaustive match anywhere, so the new variant breaks no caller; it is additive in the serialized report.
  • No GPU evidence. cp_async_zfill (sm_80) is the only affected example that could run on hardware I can reach, and g5 spot capacity was exhausted in both permitted regions throughout this session; the T4 alternative is sm_75, below what cp.async needs. Rather than claim a run I did not make, the validity argument rests on the ptxas assembly above, which covers all four affected targets — including the two no one here can execute.

Test plan

  • cargo test -p ptx-schedule — 19 passed (16 pre-existing + 3 new), plus the 3 binary tests.
  • cargo clippy -p ptx-schedule --all-targets -- -D warnings — clean.
  • cargo fmt --check — clean.
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p ptx-schedule — clean.

vyncint and others added 2 commits August 30, 2026 14:25
…ule sites

`classify_instruction` covered the synchronous ordering primitives -- atomics,
`red.*`, the `bar.*`/`barrier.*`/`mbarrier.*` family, `membar.*`/`fence.*`, the
warp collectives and ordered `ld`/`st` -- and nothing from the asynchronous
proxy. An opcode that classifies as nothing is not a site of any kind, so it
received no injection and never appeared in a report: the pipeline a Hopper or
Blackwell kernel is built around was the part a campaign could not reach.

None of the existing arms reach these, and each for its own reason:

  * `cp.async.bulk.tensor...` carries `mbarrier::complete_tx::bytes` in its
    qualifier list, but spells it with `::`, so it never matches the barrier
    arm's `mbarrier.`;
  * `wgmma.fence.sync.aligned` is a fence that does not start with `fence.`;
  * `tcgen05.ld...` splits to a base of `tcgen05` rather than `ld`, so the
    ordered-memory arm returns before seeing it;
  * `clusterlaunchcontrol.try_cancel.async` completes through an mbarrier just
    as the bulk-tensor copy does, and matches nothing at all.

Adds `SiteKind::AsyncProxy` and one prefix arm for the four families. Taking
each family whole matches how `bar.`/`mbarrier.` and the warp collectives are
already handled, and keeps the consumer halves (`tcgen05.ld`,
`clusterlaunchcontrol.query_cancel`) as sites alongside the issues and waits
they read.

Across the 167 `.ptx` the example corpus builds, this takes the analyzer from
2093 sites to 2465: 372 ordering instructions that were previously invisible.

The crate README carries the `SiteKind` table, so it gains the row in the same
position; the two lists agree in order and content.

Signed-off-by: Vyncint Ng <[email protected]>
The new arm matched "cp.async" but not the TMA reduce family: mir-lower's
inline-asm template emits
cp.reduce.async.bulk.tensor.{n}d.global.shared::cta.{op}.{mode}.bulk_group,
where "reduce" sits before "async", so "cp.async" walks past it.

Before/after for a kernel using TMA tensor reduce:

  cp.reduce.async.bulk.tensor.2d...bulk_group   ->  (no site)   ->  AsyncProxy
  cp.async.bulk.commit_group                    ->  AsyncProxy  ->  AsyncProxy
  cp.async.bulk.wait_group 0                    ->  AsyncProxy  ->  AsyncProxy

That left the issue classified as nothing while its commit/wait pair became
sites: the half-covered condition issue NVIDIA#1113 describes. Adds the prefix,
one fixture line spelled verbatim from the mir-lower template, and extends
the existing assertions. No example emits cp.reduce today, so corpus site
counts are unchanged (verified: no count constants reference the corpus).

Signed-off-by: nihalpasham <[email protected]>
@nihalpasham
nihalpasham force-pushed the feat/ptx-schedule-async-proxy-sites branch from 819baca to 1eed4d2 Compare August 30, 2026 10:10
@nihalpasham

Copy link
Copy Markdown
Collaborator

Reviewed in depth; this is exactly the fix #1113 needed and the evidence work (corpus recount, 21/21 ptxas on perturbed output with a negative control, the mutation table) made it easy to trust. One gap found, and we patched it on your branch rather than round-tripping.

The gap: cp.reduce.async was still half-covered

mir-lower's TMA reduce path emits an instruction your prefix list can't match, while its ordering pair can:

cp.reduce.async.bulk.tensor.2d.global.shared::cta.add.tile.bulk_group
^^^^^^^^^^^^^^^ "cp.async" doesn't match (reduce sits before async)

cp.async.bulk.commit_group;   <- matches, becomes a site
cp.async.bulk.wait_group 0;   <- matches, becomes a site

An issue the fuzzer can't delay against a wait it can perturb is the same half-covered condition your issue describes. No example emits it today (counts unchanged), but the API is user-reachable, so it would have bitten the first kernel that used TMA reduce.

What we stacked on your branch (your commit untouched underneath)

  • cp.reduce.async added to the AsyncProxy prefix arm, with a comment bullet quoting the emitted opcode
  • one fixture line spelled verbatim from mir-lower's inline-asm template, site-count assert 14 -> 15
  • README AsyncProxy row extended

Validation

  • cargo test -p ptx-schedule (19 unit + 3 CLI), clippy -D warnings, fmt: all clean
  • live campaign on an RTX 5090: fuzz-schedule cp_async_zfill, report now shows AsyncProxy=3, Barrier=2, baseline + 5 seeds all pass

Two adjacent families our verification turned up that are deliberately NOT in this arm: griddepcontrol.wait/launch_dependents (PDL grid ordering) and tensormap.replace.* (tensormap proxy). Different ordering mechanisms, semantically wrong to fold into AsyncProxy; we'll file follow-up issues. CI approval + landing next.

@nihalpasham nihalpasham added enhancement New feature or request fuzzer Fuzzing infrastructure (rustlantis, difftest) cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) labels Aug 30, 2026
@nihalpasham
nihalpasham merged commit 6c2219a into NVIDIA:main Aug 30, 2026
52 checks passed
nihalpasham added a commit to drbh/cuda-oxide that referenced this pull request Aug 31, 2026
The B200 evidence for PR NVIDIA#1066 previously lived only in the PR description.
scripts/regress-gemm-sol-schedule.sh (just regress-gemm-sol) makes it
repeatable: the default pass-after mode runs the mbarrier-focused
fuzz-schedule campaign on the current tree with --fail-on-finding and
asserts from summary.json that the baseline was Usable (a Declined baseline
also exits 0), every variant ran, and AsyncProxy sites were classified
(post-NVIDIA#1195 coverage incl. tcgen05 commit/wait). The opt-in
--fail-before <ref> mode rebuilds the pre-fix tree in a throwaway worktree
and asserts the race is CONFIRMED there. Seeds are per-build (site
renumbering), so the pinned defaults document the lineage they were
confirmed on and stay overridable. Gated on sm_100 hardware; skips cleanly
elsewhere.

Signed-off-by: nihalpasham <[email protected]>
nihalpasham added a commit that referenced this pull request Aug 31, 2026
* fix: synchronize phase 4b tile metadata

The gemm_sol_clc producer warp republished the TILE_INFO mailbox after
signaling TILE_READY without waiting for the MMA and epilogue warps to
copy the current tile coordinates. Add a TILE_INFO_FREE mbarrier
(arrival count 5, one leader per reader warp) that the producer waits
on before each republish, including the final has_work = 0 publish.

Found by the schedule perturbation campaign: seeds 56 and 135 of a
0..140 --focus mbarrier sweep on a B200 (sm_100a) failed the phase 4B
validator 3/3; with this fix the same sweep is clean and phase 4b
throughput is unchanged within noise.

Signed-off-by: David Holtz <[email protected]>

* fix: extend tile-metadata handshake to phases 4a, 4c, 4d

Signed-off-by: David Holtz <[email protected]>

* fix(gemm_sol): lane-0 CLC decode behind a cluster rendezvous in 4D; tile-distinct Walsh validator for the CLC phases

Phase 4D decoded the CLC response in all 32 producer lanes with no proxy
fences and no rendezvous, unlike 4B/4C: the leader's next
clc_try_cancel_multicast can overwrite both CTAs' CLC_RESPONSE while slow
follower lanes still hold the old one, so is_canceled diverges and the warp
hangs at the K-loop sync (reachable when k_iters == 4). Adopt the 4C
pattern: CLC_READY cluster rendezvous armed before the local TILE_INFO_FREE
wait, lane-0-only decode with async-proxy fences, and shuffle broadcast so
the cancel branch is warp-uniform by construction. The TILE_INFO_FREE
barrier itself stays CTA-scope; a comment now pins the CTA-locality
invariant and the escalation path.

The CLC correctness phases also swap their periodic inputs (every 128x128
output tile byte-identical - blind to exactly the tile permutations the
mailbox race causes) for the 12-bit Walsh fingerprint validator with a full
exact-BF16 output scan. A quadrant scale on A breaks the affine-code twin
symmetry (code(x+2048) = code(x) ^ 0x800) that would otherwise leave each
tile a byte-identical twin 16 tiles away; all values stay exact in
f16/f32/bf16 in any accumulation order.

Signed-off-by: nihalpasham <[email protected]>

* test: committed schedule-fuzz regression for the gemm_sol mailbox race

The B200 evidence for PR #1066 previously lived only in the PR description.
scripts/regress-gemm-sol-schedule.sh (just regress-gemm-sol) makes it
repeatable: the default pass-after mode runs the mbarrier-focused
fuzz-schedule campaign on the current tree with --fail-on-finding and
asserts from summary.json that the baseline was Usable (a Declined baseline
also exits 0), every variant ran, and AsyncProxy sites were classified
(post-#1195 coverage incl. tcgen05 commit/wait). The opt-in
--fail-before <ref> mode rebuilds the pre-fix tree in a throwaway worktree
and asserts the race is CONFIRMED there. Seeds are per-build (site
renumbering), so the pinned defaults document the lineage they were
confirmed on and stay overridable. Gated on sm_100 hardware; skips cleanly
elsewhere.

Signed-off-by: nihalpasham <[email protected]>

---------

Signed-off-by: David Holtz <[email protected]>
Signed-off-by: nihalpasham <[email protected]>
Co-authored-by: Claude (subagent) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda-feature A CUDA hardware/toolkit feature (TMA, tcgen05, WGMMA) enhancement New feature or request fuzzer Fuzzing infrastructure (rustlantis, difftest)

Projects

None yet

2 participants