Repository navigation
test(examples): pin DPX-shaped integer min/max chains to native PTX min/max - #951
Merged
nihalpasham merged 2 commits intoAug 17, 2026
Merged
Conversation
almightychang
force-pushed
the
dpx-s32-minmax-regression
branch
from
August 16, 2026 16:52
ebd4a67 to
d215abb
Compare
8 tasks done
almightychang
force-pushed
the
dpx-s32-minmax-regression
branch
from
August 17, 2026 07:18
d215abb to
8628383
Compare
…in/max Hopper's DPX instructions (SASS VIMNMX/VIMNMX3) have no PTX spelling of their own: ptxas builds them by fusing dataflow-adjacent min.s32/max.s32/ min.u32/max.u32 chains. How far that fusion goes is a property of the ptxas in use; what the backend must guarantee — and what this example pins — is the canonical PTX shape those chains must keep to stay fusable: native min/max instructions rather than compare/select or branches. (With CUDA 12.0 ptxas at sm_90, plain Rust x.max(y).max(z) was observed to produce the same min/max SASS shape as the CUDA __vimax3_s32 intrinsic family.) One kernel per issue-338 Phase 4 s32/u32 item (vimax3, vimin3, vimnmx, viaddmax, viaddmin x s32/u32; vimnmx is the issue's pattern name -- CUDA's public API has no __vimnmx), verified numerically on the device against a shared host reference, including hand-computed pins for the explicit MAX+1 / MIN-1 wrapping lanes, plus a verify-code-shape.sh that asserts each kernel keeps exactly its chain's min/max instructions in the PTX. The .relu and 16x2 DPX variants have no dedicated NVVM intrinsics and are left to a follow-up; see issue NVIDIA#338. Signed-off-by: almightychang (Sam, Joochul Chang) <[email protected]>
Signed-off-by: almightychang (Sam, Joochul Chang) <[email protected]>
almightychang
force-pushed
the
dpx-s32-minmax-regression
branch
from
August 17, 2026 12:20
8628383 to
bb732d8
Compare
Collaborator
|
Validated the latest push on a 5090:
The exact-count assertions will fail loudly if a future opt/llc bump changes instruction selection. That's the point of the test, so fine as is. CI runs are approved. Merging once green. |
nihalpasham
approved these changes
Aug 17, 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.
Part of #338
Summary
No compiler code is changed. Hopper DPX operations are SASS
VIMNMX-family instructions without dedicated PTX instructions; ptxas recognizes and fuses adjacent native integer min/max chains. Therefore, the five s32/u32 items in Phase 4 of #338 are covered here as code-generation regression tests rather than new compiler intrinsics.The example contains ten kernels:
vimax3,vimin3,vimnmx,viaddmax, andviaddmin, each in s32 and u32 forms.vimnmxis not a CUDA API name; it is the issue's name for the mixed min/max SASS pattern.The runtime test validates every lane numerically and includes hand-computed pins for explicit
MAX + 1andMIN - 1wrapping cases.verify-code-shape.shchecks each kernel's PTX body for the exact expected count and signedness of nativemin.*andmax.*instructions, preventing regressions to compare/select or branch lowering.SASS evidence
With CUDA 12.0.140 ptxas targeting
sm_90, the Rust chains and the corresponding__vimax3_s32-family CUDA intrinsics produced the same SASS shape:VIMNMXx2 for three-input min/max andIADD3+VIMNMXfor add/min-max. All ten Rust kernels usedVIMNMX/VIMNMX.U32for their result calculation; none degraded to compare/select.The CI contract intentionally stops at the canonical PTX shape. SASS fusion is a property of the ptxas version in use and may select newer fused opcodes in other toolkit versions.
The ReLU and 16x2 variants have no dedicated NVVM intrinsics and remain tracked by #338.