Repository navigation
fix(ptx-schedule): redux.sync is not a schedule site, so campaigns walk past it - #1111
Merged
nihalpasham merged 1 commit intoAug 21, 2026
Merged
Conversation
…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]>
Collaborator
|
nihalpasham
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is wrong
classify_instructionrecognises every warp-level collective PTX has except one. ItsWarpCollectivelist isactivemask,match.any,match.all,vote.,elect.,shfl.— andredux.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, andredux.sync.add.s32does not start withred.. So the function returnsNone— and an unclassified opcode is not a site of any kind. It never reachesanalyze_ptx's site list, never gets ananosleep.u32, and never appears in a campaign report. Aredux.syncin a kernel is simply invisible to the tool.That is the wrong instruction to be blind to.
redux.syncis convergent with a participation contract — every non-exited lane named inmaskmust 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-sitesbefore and after, on artifacts built from this tree:redux.syncinstructionsredux_sum.ptxredux_minmax.ptxBoth kernels were reported as having no schedule-sensitive site at all.
Completeness
Cross-checking
intrinsics/catalog.jsonagainst the classifier,redux.syncis the only gap. Of the PTX mnemonicscuda-device'swarpmodule can emit:activemask.b32activemaskbar.warp.syncbar.warp(→Barrier, correctly)elect.syncelect.match.{any,all}.sync.b{32,64}match.any/match.allshfl.sync.{bfly,down,idx,up}.b32shfl.vote.sync.{all,any,ballot,uni}.*vote.redux.sync.*spellingsAll sixteen
redux_sync_*entry points are affected:add,min/maxinu32/s32,and/or/xor, and the eightf32min/max variants with.absand.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: oneReduction, fiveWarpCollectivea_redux_site_can_be_perturbed— a focused campaign actually injects at aredux.syncsiteAll 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 failedcargo fmt --check -p ptx-schedule: cleancargo clippy -p ptx-schedule --all-targets -- -D warnings: cleancargo doc --no-deps -p ptx-schedule, with and without--document-private-items: cleananalyze_ptxstill parses all 168 example.ptxfiles in the tree without errorOne file,
crates/ptx-schedule/src/lib.rs. Checked against every open PR's file list viagh api --paginate— no overlap. My #1108 adds a README to this crate whose site-kind table already listsreduxunderWarpCollective; different file, and this is what makes that row true.