Skip to content

fix(ptx-schedule): redux.sync is not a schedule site, so campaigns walk past it - #1111

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:fix/ptx-schedule-redux-warp-collective
Aug 21, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:fix/ptx-schedule-redux-warp-collective

Conversation

@vyncint

@vyncint vyncint commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

What is wrong

classify_instruction recognises every warp-level collective PTX has except one. Its WarpCollective list is activemask, match.any, match.all, vote., elect., shfl. — and redux. is missing.

It is not caught anywhere else either. The red. arm two branches up looks like it would swallow it, but that prefix carries the dot, and redux.sync.add.s32 does not start with red.. So the function returns None — and an unclassified opcode is not a site of any kind. It never reaches analyze_ptx's site list, never gets a nanosleep.u32, and never appears in a campaign report. A redux.sync in a kernel is simply invisible to the tool.

That is the wrong instruction to be blind to. redux.sync is convergent with a participation contract — every non-exited lane named in mask must execute the same instruction with the same qualifiers — which is exactly the class of contract a deterministic schedule perturbation exists to stress.

Measured on PTX the backend emits today

--list-sites before and after, on artifacts built from this tree:

example redux.sync instructions sites before sites after
redux_sum.ptx 2 0 2
redux_minmax.ptx 7 0 7

Both kernels were reported as having no schedule-sensitive site at all.

Completeness

Cross-checking intrinsics/catalog.json against the classifier, redux.sync is the only gap. Of the PTX mnemonics cuda-device's warp module can emit:

classified prefix
activemask.b32 activemask
bar.warp.sync bar.warp (→ Barrier, correctly)
elect.sync elect.
match.{any,all}.sync.b{32,64} match.any / match.all
shfl.sync.{bfly,down,idx,up}.b32 shfl.
vote.sync.{all,any,ballot,uni}.* vote.
the 14 distinct redux.sync.* spellings none

All sixteen redux_sync_* entry points are affected: add, min/max in u32/s32, and/or/xor, and the eight f32 min/max variants with .abs and .NaN.

The change

One prefix, plus a comment recording why the neighbouring red. arm does not cover it — that near-miss is the whole reason this was easy to miss.

Tests

Three, over one fixture holding every warp collective plus the red.* memory reduction whose prefix is the near-miss:

  • every_warp_collective_is_a_site — every instruction in the fixture is a site with the right kind (12 sites; before this, 7)
  • redux_is_a_warp_collective_and_red_is_still_a_reduction — the two are not confused in either direction: one Reduction, five WarpCollective
  • a_redux_site_can_be_perturbed — a focused campaign actually injects at a redux.sync site

All three fail with the one-line change reverted, reporting 7 sites for 12 instructions.

Verification

All local, no GPU needed.

  • cargo test -p ptx-schedule --all-targets: 12 passed, 0 failed
  • cargo fmt --check -p ptx-schedule: clean
  • cargo clippy -p ptx-schedule --all-targets -- -D warnings: clean
  • cargo doc --no-deps -p ptx-schedule, with and without --document-private-items: clean
  • analyze_ptx still parses all 168 example .ptx files in the tree without error

One file, crates/ptx-schedule/src/lib.rs. Checked against every open PR's file list via gh api --paginate — no overlap. My #1108 adds a README to this crate whose site-kind table already lists redux under WarpCollective; different file, and this is what makes that row true.

…lk past it

`classify_instruction` recognises every warp-level collective PTX has except
one. Its `WarpCollective` list is `activemask`, `match.any`, `match.all`,
`vote.`, `elect.`, `shfl.` -- and `redux.` is missing.

It is not caught anywhere else, either. The `red.` arm two branches up looks
like it would swallow it, but that prefix carries the dot, and
`redux.sync.add.s32` does not start with `red.`. So the function returns
`None`, and an unclassified opcode is not a site of *any* kind: it never
reaches `analyze_ptx`'s site list, never gets a `nanosleep.u32`, and never
appears in a campaign report. A `redux.sync` in a kernel is simply invisible
to the tool.

That is the wrong instruction to be blind to. `redux.sync` is convergent with
a participation contract -- every non-exited lane named in `mask` must execute
the same instruction with the same qualifiers -- which is exactly the class of
contract a deterministic schedule perturbation exists to stress. All sixteen
forms are affected: `add`, `min`/`max` in `u32`/`s32`, `and`/`or`/`xor`, and
the eight `f32` min/max variants with `.abs` and `.NaN`.

Measured on PTX the backend emits today, `--list-sites` before and after:

    redux_sum.ptx      2 redux.sync instructions    0 sites -> 2
    redux_minmax.ptx   7 redux.sync instructions    0 sites -> 7

Both kernels were reported as having no schedule-sensitive site at all.

Cross-checking the catalog against the classifier, `redux.sync` is the only
gap. Of the mnemonics `cuda-device`'s `warp` module can emit, `activemask.b32`,
`bar.warp.sync`, `elect.sync`, `match.{any,all}.sync.b{32,64}`,
`shfl.sync.{bfly,down,idx,up}.b32` and `vote.sync.{all,any,ballot,uni}.*` all
classify; the fourteen distinct `redux.sync.*` spellings classify as nothing.

Add the prefix, with a comment recording why the neighbouring `red.` arm does
not cover it.

Three tests, over one fixture holding every warp collective plus the `red.*`
memory reduction whose prefix is the near-miss:

* every instruction in the fixture is a site, and each gets the right kind
  (12 sites; before this, 7);
* `red.` and `redux.` are not confused in either direction -- one `Reduction`,
  five `WarpCollective`;
* a focused campaign actually injects at a `redux.sync` site.

All three fail with the one-line change reverted, reporting 7 sites for 12
instructions.

Verified: 12 tests pass, fmt clean, `clippy --all-targets -- -D warnings`
clean, `cargo doc` clean with and without `--document-private-items`, and
`analyze_ptx` still parses all 168 example `.ptx` files without error.

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

Copy link
Copy Markdown
Collaborator
  • Confirmed the gap on main: redux.sync matches neither the red. arm (the u breaks the prefix) nor the WarpCollective list, so classify_instruction returns None and redux_sum/redux_minmax report zero perturbable sites despite being built around a convergent warp collective. The counts check out: 2/7/24 redux.sync in redux_sum/redux_minmax/redux_f32 with no other site-class opcodes there.
  • One prefix at the crate's single classification chokepoint, reusing the existing SiteKind; the fixture's red.* near-miss row locks the boundary in both directions.
  • Merging ahead of docs(ptx-schedule): the one published crate with no README #1108 so the README's redux row is true when it lands.

@nihalpasham nihalpasham added bug Something isn't working fuzzer Fuzzing infrastructure (rustlantis, difftest) labels Aug 21, 2026
@nihalpasham
nihalpasham merged commit 150adfb into NVIDIA:main Aug 21, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fuzzer Fuzzing infrastructure (rustlantis, difftest)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants