shader: lower the 16-bit three-operand float VOP3 ops in pixel_aot #1466
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!1466
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1466/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@agilesh08 on GitHub · 2026-11-24 12:01 UTC · original
agilesh08:feat/shader-vop3-f16-ternary→main· +598 −6 · 8 files · 1 commits · closed without mergingSummary
Lowers the three remaining unlowered 16-bit float ternary
VOP3math instructions (v_min3_f16,v_max3_f16, andv_med3_f16) intools/pixel_aot.pyacross their unsuffixed and_e64spellings, completing RDNA2VOP3ternary floating-point coverage.Implementation Details
Lowering (
tools/pixel_aot.py):widen16(hf...).precisemode using HLSL intrinsics:min(min(a, b), c)forv_min3_f16,max(max(a, b), c)forv_max3_f16, andmax(min(a, b), min(max(a, b), c))forv_med3_f16.narrow16(hs...)and tags the destination as("half16", alu).half16_arith_source(accepting proven inline constants, numeric literals, scalar constant registers, and priorhalf16arithmetic results).f16_min3_max3_med3_resultwith signed-zero tie breaking (-0.0 < +0.0).Scanner & Tooling (
tools/scan_unsupported_shaders.py,tests/rdna2_tools_check.py,tests/pso_readiness_check.py):PIXEL_VOP3_F16_TERNARYin opcode tables and adds syntax parsing regex forv_min3_f16,v_max3_f16,v_med3_f16.tests/rdna2_tools_check.pyand tracking assertions intests/pso_readiness_check.py.Form Coverage (
tests/form_coverage_check.py):("VOP3", "v_min3_f16"),("VOP3", "v_max3_f16"), and("VOP3", "v_med3_f16")are counted as covered in bothgfx1013.tsvandrdna2.tsvwhen translated withtranslate_f16, and remain uncovered without the accepted fixtures.Draw Fixture & CMake (
tests/pixel_aot_check.py,CMakeLists.txt):draw-f16-ternarytest harness covering 18 programs (all 6 strict permutations of values, negative values, mixed signs, subnormals, all 4 tie shapes, and chained arithmetic results) through bit-exactR32G32B32A32_UINTreadback.med3_as_min3,med3_as_max3,max3_as_min3,min3_as_max3, andsource_high).pixel_aot_f16_ternary_${adapter}with timeout and form coverage logging inCMakeLists.txt.Documentation (
docs/experiments.md):half16result tagging, draw harness, and mutation testing.Evidence
All local verification checks pass on Windows:
All checks exit with code
0.Checklist
Lower the ternary binary16 VOP3 operations v_min3_f16, v_max3_f16, and v_med3_f16 across their unsuffixed and _e64 spellings in tools/pixel_aot.py. Each source is widened with widen16, evaluated using min16_num, max16_num, or the nested median expression under precise, and narrowed to binary16 with narrow16. min16_num and max16_num enforce -0.0 < +0.0 IEEE total ordering on signed-zero ties at bit level. The operands require finite proofs via half16_arith_source, and the destination is tagged (half16, alu). The translator tracks chained operations using exact rational evaluation. Update tools/scan_unsupported_shaders.py to recognize the forms, add syntax tests in tests/rdna2_tools_check.py, and verify form coverage in tests/form_coverage_check.py against gfx1013.tsv and rdna2.tsv. Add draw-f16-ternary in tests/pixel_aot_check.py, register it in the CLI mode dispatch guard, and wire pixel_aot_f16_ternary_${adapter} in CMakeLists.txt. Document the lowering and test coverage in docs/experiments.md.@ChazY11 on GitHub · 2026-11-24 13:21 UTC · original
The two tests this PR registers cannot run:
draw-f16-ternaryis not an accepted modeIndependent reviewer, not the author. I built
da9be0efclean and ran the tests the PR adds.Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, LLVM gfx1013 tooling
available (
pixel_aot_region_scalar_load_warppasses on this machine, so the binary path works here).The registration passes
draw-f16-ternary:and the mode dispatch in the same commit knows only
binary,draw,draw-core,draw-e64,three-wayandbuffer-color, so the run stops before any lowering is exercised. The fixture data itself is present in that file(
F16_TERNARY_WORDS,F16_TERNARY_GROUPS,F16_TERNARY_CHAIN,F16_TERNARY_MED_CHAIN,f16_ternary_ops), which iswhy this reads like a missing
elif mode == "draw-f16-ternary":hunk rather than a wrong test name.Two consequences worth checking on your side:
tools/pixel_aot.pyis unverified by these tests — they never reach it. Sov_min3_f16,v_max3_f16andv_med3_f16have no executed coverage in this commit, whatever the diff says._warpcase should run in the Windows job, but a missing DXC/LLVM on a runnerturns these into capability skips, which is exactly the failure mode
AGENTS.mdasks to report separately.I have not pushed anything. Once the dispatch exists I am happy to re-run the pair plus a mutation of the
v_med3_f16formula to confirm the tests actually reject a wrong lowering — that is the check I was going to do before I hit this.
Verdict
Not mergeable as it stands: the two registered cases fail on a clean local build with a
ValueErrorfrom the harness,before reaching the code under test. Everything else I could check is in order (
tools/pixel_aot.py, the docs line andthe other Python checks load fine).
@ChazY11 on GitHub · 2026-11-24 13:31 UTC · original
Addendum — the mapping exists, but the dispatch chain never consults it
Correction to the cause in my review above, found while re-checking at the same head
da9be0ef. The behaviour is thesame (both tests still fail), but my "missing
elif" reading was one step short of the actual defect.No build or
ctestneeded to see it:The mode is declared in this commit, at line 21521:
but
main()does not read that mapping. Its hand-written chain runsdraw-e64-spellings,draw-e64,draw-e64-approx,draw-sdwa-unary, thenbinary,bits,draw/draw-core,three-way,buffer-color, and falls through to theValueErrorabove.draw-f16-ternarymatches none of the branches, so the declared handler is unreachable.So the fix is one branch in that chain (or routing the chain through the mapping table), not a new handler. The rest of
the review stands: the two registered cases fail before reaching the lowering, and the fixture data plus the handler
already exist in the file.
I have not pushed anything.
@agilesh08 on GitHub · 2026-11-24 14:18 UTC · original
@R0Y00 @tedin7 @ChazY11 Thank you for the detailed diagnostics and hardware/WARP runs! Updated PR #1466 with both fixes:
@tedin7,@ChazY11,@R0Y00): Added"draw-f16-ternary"to theif mode in (...)dispatch guard intests/pixel_aot_check.py(main()) sopixel_aot_f16_ternary_warpandpixel_aot_f16_ternary_hardwareexecutecheck_f16_ternary_drawinstead of falling through toValueError. Added unit verification asserting"draw-f16-ternary"is in the dispatch guard tuple.@R0Y00): Under IEEE total ordering, native RDNA2v_min3_f16/v_max3_f16/v_med3_f16order-0.0(0x8000) strictly below+0.0(0x0000). Updatedmin16_numandmax16_numintools/pixel_aot.pyto enforce-0.0 < +0.0bit-level ordering whena == 0.0f && b == 0.0f(asfloat(asuint(a) | asuint(b))for min,asfloat(asuint(a) & asuint(b))for max), and loweredv_min3_f16,v_max3_f16, andv_med3_f16usingmin16_num/max16_numinstead of bare HLSLmin/max. Added unit test assertions across all permutations of the four signed-zero tie cases ((-0.0, -0.0, +0.0),(-0.0, +0.0, +0.0),(-1.0, -0.0, +0.0),(-0.0, +0.0, +1.0)) verifying exact bit agreement with the reference oracle.Verified all platform-independent checks (
form_coverage_check.py,rdna2_tools_check.py,pso_readiness_check.py,pixel_aot_check.py,docs_links_check.py,bidi_controls_check.py) with exit code 0. Assisted by AI.@R0Y00 on GitHub · 2026-11-24 14:27 UTC · original
Retested
46704adain Release. The CLI now reaches both draws. WARP passes, but RTX 4060 Laptop driver 32.0.16.1656 still fails main-13 at (0,0), median channel 2: expected 0x0000, got 0x8000. Debug layer enabled, zero messages. Please verify the exact native median result for the zero permutations with the instruction specification or an independent raw-word native run. Then preserve the selected half as integer bits through the final write and rerun both draw backends. The Python oracle and the WARP pass alone leave the RTX discrepancy open.@ChazY11 on GitHub · 2026-11-24 14:55 UTC · original
Dispatch is fixed —
_warpnow passes with all four mutations caught;_hardwarefails on my adapterRe-checked at the new head
46704ada. The blocking finding in my earlier review is resolved, and one narrower issue replacesit.
Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, RTX 5080 Laptop
(32.0.15.8142) for the
hardwarecase, in-box WARP forwarp.What now works
draw-f16-ternaryis in the dispatch table, and the warp case runs the whole fixture: the reference draw passes and allfour in-tree mutations are detected.
That is the check I said I would do once the dispatch existed: the
v_med3_f16formula and the min/max distinctions areeach noticed. Good.
What fails
The hardware case dies on the reference draw, before any mutation:
run_pixel_batchcompares the GPU readback againstf16_ternary_expected(...)computed in Python, so this is thelowered output disagreeing with the fixture's own model on this adapter, not a disagreement with WARP's pixels. WARP
agrees with the model; this GPU does not.
Two possibilities and I cannot separate them from here:
min3/max3/med3differently from the HLSL the translator emits, which would bea real finding for half-precision ternary coverage;
Either way it is worth knowing before merge, because CI excludes
_hardware, so this case would land green.If it helps: tell me which of the
F16_TERNARY_PROGRAMSkeys is the first to mismatch and I will narrow it to a singlecomponent (I did not modify the harness to print it, since that is your file).
Verdict
Reviewed
46704ada. The dispatch fix is correct and the warp case is now a real check with four mutation detections. Thehardware case fails on my adapter at the reference comparison; I would not merge with that unexplained, even though the
CI job cannot see it.
@Makto94 on GitHub · 2026-11-24 16:03 UTC · original
Independent run of
46704adaon another NVIDIA adapter (RTX 3070 Ti, desktop), Debug build. The hardware case fails with the same signature as R0Y00's Release retest:main-13, pixel (0,0), channel 2 expected0x0000, got0x8000.Environment: commit
46704adaaa031ca53c7dd6752d0935b5431fcb84, presetdev(Debug); NVIDIA GeForce RTX 3070 Ti (10de:2482), driver 32.0.16.2101 (621.01); Windows 11 Pro 10.0.26300.9974; DXC 1.9.2602.17 (Windows SDK 10.0.26100);debug_layer=enabled,debug_errors=0 debug_warnings=0.pixel_aot_f16_ternary_warp: passed. The reference draw passes and all 5 mutations are detected.pixel_aot_f16_ternary_hardware: failed on the reference drawmain-13, before any mutation ran.Not measured here: the native result for the zero permutations, and any non-NVIDIA adapter.
@tedin7 on GitHub · 2026-11-25 12:44 UTC · original
@agilesh08 could you rebase this branch onto current
mainand force-push?GitHub reports head
46704adaas conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(b1a644ae):docs/experiments.mdtests/pixel_aot_check.pyCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-24 12:20 UTC · original · reviewed
Reviewed PR #1466 (
da9be0ef):Findings
tests/pixel_aot_check.py(main()):"draw-f16-ternary"was added to thedraw = {...}dispatch dictionary (line 21521), but it was omitted from theif mode in (...)guard tuple (lines 21483–21494). As a result, invokingtests/pixel_aot_check.py draw-f16-ternary ...falls through toelse:and raises: Bothpixel_aot_f16_ternary_warpandpixel_aot_f16_ternary_hardwarefail immediately because of this.Verification
da9be0ef:tests/form_coverage_check.py: PASS (45.39s)cmake --build --preset dev --target offscreen_check: PASSctest --preset dev -R '^pixel_aot_f16_ternary_': 0/2 passed, 2 failed (pixel_aot_f16_ternary_warpandpixel_aot_f16_ternary_hardwareboth failed with theValueErrorabove).da9be0ef:tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check origin/main..HEAD: PASStests/rdna2_tools_check.py: PASS (141tests,18skipped)tests/pso_readiness_check.py: PASStests/pixel_aot_check.py(check_controls): PASSllvm-mc-19,llvm-objcopy-19,libLLVM-19.so) assembly/disassembly/translation roundtrip of all 23f16_ternary_opsandF16_TERNARY_PROGRAMS: PASSCode Audit Notes
tools/pixel_aot.py:VOP3_F16_TERNARY,f16_min3_max3_med3_result, and the lowering path look clean and consistent with the existinghalf16finite-proof and-0.0 < +0.0tie-breaking contracts.tools/scan_unsupported_shaders.py,tests/rdna2_tools_check.py,tests/pso_readiness_check.py,tests/form_coverage_check.py: clean and well-scoped.Once
"draw-f16-ternary"is added to themode in (...)tuple intests/pixel_aot_check.pyand thepixel_aot_f16_ternary_*CTest targets pass on Windows, this looks ready.@R0Y00 on GitHub · 2026-11-24 13:53 UTC · original · requested changes
I locally added draw-f16-ternary to the main draw-mode branch so both registered cases execute. They both fail main-13 on RTX and WARP: median channel 2 expects +0 (0x0000) and returns -0 (0x8000). Please include the CLI dispatcher fix and establish which signed-zero tie result the native instruction yields under this profile. Then preserve that bit result in the generated path and keep this case strict.
@tedin7 on GitHub · 2026-11-24 16:55 UTC · original · reviewed
Re-review of head
46704ada.Previous blocker
"draw-f16-ternary"was missing from themode in (...)guard inmain(). It is now in that tuple and in thedrawdispatch (tests/pixel_aot_check.py), andCMakeLists.txtregisters thedraw-f16-ternaryruns. I could not run those on Windows, so the fix is confirmed by reading and by the Linux run below, not by the WARP run.Observations, none blocking
min16_numandmax16_numare shared helpers. The diff changes them for every user, not only the new ops: a+0/-0pair now returns-0for min (sign bits ORed) and+0for max (ANDed). That is the documented tie order and matches the new proof function, but it also changes the output of the existingv_min_f16/v_max_f16lowerings in the tie case. Worth one sentence in the PR body.check_f16_ternary_loweringreads the source ofmain()withinspect.getsourceand searches for the mode string. The draw tests already fail if the mode is missing, so this text search duplicates them and breaks on a harmless reformat.llvm-mc-19 -mcpu=gfx1030gives opcodes 0x351, 0x354 and 0x357 forv_min3_f16,v_max3_f16andv_med3_f16, the same onestools/disasm_rdna2.pylists. Withclampset the encoding differs (bit 15 of the second byte), which the lowering refuses.Checks run (Linux only; the draw runs need Windows and were not run)
git diff --check origin/main...HEAD: clean.python3 tests/docs_links_check.py: self-test passed, 16 files, 344 links.python3 tests/bidi_controls_check.py: self-test passed, 1247 files, no bidirectional controls.python3 tests/pso_readiness_check.py: passed.python3 tests/pixel_aot_check.py: exit 0.python3 tests/rdna2_tools_check.py: 141 tests, OK, 18 skipped.med3lowered asmin3intools/pixel_aot.py: KILLED (a lowering assertion fails). It is caught by a text assertion on the emitted HLSL, not by evaluating the shader.min16_num: SURVIVED the Linux run. Only the Windows draw cases can see it, so the WARP result on Windows is what actually covers that behaviour.Verification is Linux-only.
AI-assisted; commands listed were executed locally.
Pull request closed