Repository navigation
Ampere instructions checked against an Ampere GPU: a Jetson Orin test suite - #2041
Open
Know-It-All-Brother wants to merge 3 commits into
Open
Know-It-All-Brother wants to merge 3 commits into
Know-It-All-Brother wants to merge 3 commits into
Conversation
…re_orin.py runs about 190 operations, each the GPU compiler's own machine code for one PTX operation, through the translator, spirv-cross, the chain's MSL rewrites and Metal on this Mac's GPU, and compares every output word with what a Jetson Orin (sm_87) computed from the same 1,024 input rows. The translator tests checked the MSL a few encodings give, not the values; this one finds the FSETP.NE, SHFL lane, F2FP, rounding-mode and signed-zero differences the tracking issue lists, which KNOWN names until each fix takes its entry out. dm/gfx/tools/ampere_orin/capture.py records the fixture on any Linux machine with an Ampere GPU and NVIDIA's driver, with no toolkit or compiler on either side
This was referenced Nov 9, 2026
…ules with its functions, so a rewrite that uses one (struct in PR seedds#1902's hfma_msl) runs as it does in a build instead of raising NameError
This was referenced Nov 9, 2026
…I2F to F16 with .RZ / .RM / .RP (signed and unsigned), F2F.F16.F32 with each directed rounding, F2FP.PACK_AB.RZ, and SHFL.UP with a non-zero clamp and with a segment mask, so PR seedds#1800's fixes of those can be checked on the GPU. On main six of them differ (I2F to F16 in 261 to 751 of 2,048 halves, the .RZ pack in 905, SHFL.UP's clamp in 783 of 2,048 lanes) and KNOWN names seedds#1800 for them; with seedds#1800's translator all ten match apart from NaN bits
This was referenced Nov 9, 2026
Know-It-All-Brother
added a commit
to Know-It-All-Brother/nxnative
that referenced
this pull request
Nov 9, 2026
seedds#2041): I2F to F16 and F2F.F16.F32 with directed roundings, F2FP.PACK_AB.RZ and SHFL.UP with a clamp or segment mask; the ones PR seedds#1800 fixes are in KNOWN
2 tasks done
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 1 of the Ampere accuracy series (#2040). Every fix in the series builds on this test.
What and why
Our translator tests check the MSL that a few encodings give, not the values a shader computes, so a meaning read wrong from an encoding, or lost on the way through spirv-cross and Metal, only showed up when a game looked wrong. This adds a test that compares values with real hardware.
test_dmsh_ampere_orin.pytakes 203 operations, each the GPU compiler's own machine code for one PTX operation, recorded on a Jetson Orin (sm_87, CUDA 12.6 driver) with 1,024 input rows and the Orin's outputs. It runs each program through the whole chain: the translator with the build's options, spirv-cross with the chain's arguments, every MSL rewritedmsh_build.py'sfinish()makes (read from its source, so a new rewrite is picked up), and the chain's Metal flags. Then it compares every output word with the Orin's, bit for bit.KNOWNlists the ops that still differ, each with its reason, andAPPROXthe ones that run Metal's own approximation (MUFU and the divisions built on it). The test fails when an op outside both lists differs, and when aKNOWNop matches, so each fix in the series takes its entry out.dm/gfx/tools/ampere_orin/capture.pyre-records the fixture on any Linux machine with an Ampere GPU and NVIDIA's driver. The driver compiles the PTX itself, so neither side needs a CUDA toolkit or a compiler. It rewrites the same machine code for the translator (global loads and stores become shared memory ones, and the CUDA parameter reads become NOPs), and the device'snvdisasmchecks every rewritten program.ampere_orin/ampere_orin.sasslists each program as the translator gets it.Reference entry: "Ampere instructions checked against an Ampere GPU" in
docs/reference/shaders.md.Two commits came after the first:
dmsh_build.py's standard-library imports as well as its functions. HFMA2 rounds once to half, as Ampere does (chain change) #1902'shfma_mslusesstruct, and without the import the test raisedNameErrorwhere a build wouldn't..RZ, and SHFL.UP with a clamp and with a segment mask. On main, six of them differ;KNOWNnames Translator: Ampere forms of PRAGMATA's shaders #1800 for those, and with Translator: Ampere forms of PRAGMATA's shaders #1800's translator all ten match apart from NaN bits.How to verify
It takes about 5 seconds on an M5 Max and prints each op's differing lanes by cause.
AMPERE_ORIN_ONLY=fsetp,shfl_idxruns a few, andAMPERE_ORIN_REPORT=out.jsonwrites everything as JSON. To see that it catches a change both ways, drop an entry fromKNOWN(the op fails as a mismatch) or add a matching op to it (it fails with "take it out of KNOWN"). I checked both.Checked
test_dmsh_ampere_orin.pypasses on main's translator, with all 203 ops. The othertest_dmsh_*tests are unchanged;test_dmsh_ampere_mem.py(3 Pokopia MSL patterns),test_dmsh_meshstage.py(6 integer pass-through errors) andtest_dmsh_pairs.py(1 error) fail on main the same way, with or without this PR.test_docs.pyandlint_python.py --against origin/mainpass with no new findings.regress.py: not run. This PR changes no chain tool and no shader output.--arch sm_86, but I only had the Orin.Docs
docs/reference/shaders.mdhas the entry, andpython3 dm/tools/docs_symptoms.pywas run