rdna2spirv: the binary64 VALU ops take clamp and nothing else from their omod (SHADER-F64-OMODS-CARRY) #1112
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1112"
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?
Imported from ubiquitarianism/leonida. Originally posted by klikso on 2026-11-24T18:43:03Z.
Claimed in the coordination issue as: SHADER-F64-OMODS-CARRY
What and why
This carries #475 by @fiestorra onto current
main: its three commits (9948f1f2f,e3a5bea41,e983b38f6), cherry-picked in order with their author kept and no change of mine. #475 was verified by @Len1k (tests guard the change) and by @moffington on an RTX 3060, reproduced by the author on a Radeon 780M (gfx1036), and then closed by its author on 24 November when he left the project.mainstill models the omods, and no open pull request carries the change.The binary64 VALU ops (
v_add_f64,v_rcp_f64,v_rsq_f64,v_sqrt_f64,v_trunc_f64,v_ceil_f64,v_rndne_f64,v_floor_f64) can namemul:2,mul:4ordiv:2in their omod field. The author measured on gfx1036 hardware that those omods do nothing for these ops in the mode the translator assumes (binary64 denormals kept); onlyclampapplies. The translator now passes only the clamp part of the modifier list for these ops, and the fixtures, tests and thedocs/design.mdrows say so.@fiestorra: this is your work. If you want it back, say so and I will close this.
Tested
Windows 11 26200.9974, Python 3.13.14 (pytest 9.2.0),
llvm-mc23.1.6 (conda-forge, AMDGPU target), SPIRV-Tools v2026.4. Runtime test programs built frommain3aa975421with MSVC 19.44; this change does not touchruntime/srcor the shims.The five changed test files, run against
main's translator and against this branch's:maintranslatortests/semantic/test_f64_round.pytests/semantic/test_valu_add_f64.pytests/test_f64_diff.pytests/test_f64_output_modifiers.pytests/test_f64_transcendentals.pyrun_gpu_tests.py --filter f64, each tree judged by its owncheck.py, native and withLEONIDA_W64_EMULATE=1(the two modes give the same words):maincs_f64_add(high word of themul:2result)0x40040000(2.5)0x3ff40000(1.25)ps_f64_modsps_f64_round,cs_div_fmas_f64,cs_div_fmas_f64_rtThe
cs_f64_addpair is the one @moffington reported on the RTX 3060 (1.25 with the change, 2.5 on the merge base). Note what this does and does not show: an NVIDIA device runs the translated SPIR-V, so it confirms the translator emits what the new rule says; the rule itself rests on the author's gfx1036 measurement.python -I scripts/check_no_game_data.pyon the eleven changed files: no hits.git diff --check: clean.python -I tests/test_text_write_line_endings.py: pass.GPUs tested: NVIDIA GeForce RTX 3060 Ti (Ampere), driver 621.14, Vulkan 1.4.357, Windows 11 26200
AI-assisted: yes (Claude Code; run and measured on the machine above)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed: the commits update the three f64 rows there, confirmed by the author's GPU measurement on gfx1036.🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:48:48Z.
Review: APPROVED
Reviewed and verified. Accurately reflects measured RDNA2 hardware semantics (gfx1036 oracle): when 64-bit denormals are preserved (denorm_mode_16_64 == 3), mul:2, mul:4, and div:2 omods are ignored by hardware on binary64 VALU ops, while clamp is respected. Emitting only clamp fixes spurious double-scaling in SPIR-V output. Accompanied by comprehensive updates to semantic test suites and docs/design.md. 100% clean-room compliant.
Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-24T19:30:43Z.
Tested
b30c72899on Arch Linux + NVIDIA RTX 3060 Ti (595.58.03 / Vulkan, Python 3.14):PYTHONPATH=tests/semantic python3 -m unittest discover -s tests/semantic -p "test_*f64*.py": 814 tests ran, OK (skipped=2)python3 -m unittest tests/test_f64_output_modifiers.py tests/test_f64_diff.py tests/test_f64_transcendentals.py: 35 tests passedpython3 scripts/run_gpu_tests.py --build runtime/build/linux --filter f64 --require-pass(native): 5/5 passed (cs_div_fmas_f64,cs_div_fmas_f64_rt,cs_f64_add,ps_f64_mods,ps_f64_round)LEONIDA_W64_EMULATE=1 ... --filter f64 --require-pass: 5/5 passedAI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:16:40Z.
Recommendation: [MERGE]
Reasoning: Carries #475: the binary64 VALU ops honour only clamp from their omod field, matching hardware, with fixture/test updates across nine files. Behaviour change for f64 shaders, but it was verified on the original PR (RTX 3060, Radeon 780M) and again here by madhyn (814 f64 tests OK on RTX 3060 Ti). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with
main. Merge once the queued checks are green.Impact level: 5/10
Imported from ubiquitarianism/leonida. Originally posted by klikso on 2026-11-25T01:04:42Z.
Rebased onto
mainb4b7756e8; the head moved fromb30c72899to1a3a65e0d. Two things differ from before, both because of commit26d010b41(SHADER-ROUND-F64-SPECIALS), which rewrote the binary64 rounding ops onmain:tools/rdna2spirv.pyand the rounding row ofdocs/design.md.mainnow selects NaN and subnormal sources by hand and then applies the output modifiers to the selected value. The carried change is applied at that new place: onlyclampis handed toclamp_mods_f64there. The row keepsmain's new text about NaNs and subnormals and takes the two sentences this pull request changed. The three commits by @fiestorra keep their author.1a3a65e0d:main's newtest_a_subnormal_is_rounded_as_the_hardware_doeschecked thatmul:2doublesv_ceil_f64of a subnormal to 2. With the omod dropped the result stays 1, so the check says that and gains aclampcase (v_floor_f64of the smallest negative subnormal, -1, clamps to 0).Measured again on the rebased head (Windows 11, RTX 3060 Ti 621.14, test programs built from
b4b7756e8with MSVC 19.44):main's translatorrun_gpu_tests.py --filter f64, native andLEONIDA_W64_EMULATE=1cs_f64_addreads0x0 0x3ff40000,ps_f64_modsandps_f64_round4096/4096 pixels)check_no_game_data.pyon the changed files: no hits.git diff --check: clean. AI-assisted (Claude Code).Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T18:36:57Z.
Review: APPROVED
Approving. Merged into current main (
b9320a1) with no conflicts. The updatedtests/test_f64_output_modifiers.py,tests/test_f64_transcendentals.pyandtests/test_f64_diff.pypass (36 tests), and the full translator suite gives 490 files / 6,293 tests with onlytest_int32_to_f64failing, the same baseline failure as main here (Linux, Python 3.13).The change is consistent at every site.
v_add_f64, the rcp/rsq/sqrt ops and the four rounding ops now pass onlyclamptoclamp_mods_f64, and callers whose own design row measured an omod keep passing it. That matches RDNA2 ignoring f64 omod while denormals are kept. I can't repeat the hw_oracle runs here; the code does what the design row records.AI-assisted (Claude).
Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T10:44:03Z.
#1112 | head
1a3a65e0d39f1dbe4ccc9d13c85d07e83b02b7e1|python3 -m unittest discover -s tests/semantic -p test_f64_round.py -v,python3 -m unittest discover -s tests/semantic -p test_valu_add_f64.py -v,python3 -I tests/test_f64_diff.py -v,python3 -I tests/test_f64_output_modifiers.py -v,python3 -I tests/test_f64_transcendentals.py -v| red: 54 run, 24 failures | green: 55 passed | Red → green. Vulkan red → green on AMD and RTX, both wave settingsThe five test files exercised binary64 output modifiers, rounding and differential checks. The compute and fragment fixtures also reproduced the error on both physical devices.
Captured 2 distinct complete SPIR-V module(s) emitted while rerunning test_f64_output_modifiers.py on the merged tree. All assembled and passed spirv-val for Vulkan 1.2 with --allow-offset-texture-operand.
Each adapter ran cs_f64_add and ps_f64_mods with the default wave setting and with LEONIDA_W64_EMULATE=1. All eight baseline fixture runs failed. All eight merged runs passed, including 4096/4096 exact pixels per fragment run.
Windows Vulkan adapters: AMD Radeon(TM) Graphics (26.11.2) and NVIDIA GeForce RTX 5070 Ti (610.74).
tests/semantic/test_f64_round.pytests/semantic/test_valu_add_f64.pytests/test_f64_diff.pytests/test_f64_output_modifiers.pytests/test_f64_transcendentals.pyAdditional commands
python scripts/run_gpu_tests.py --filter cs_f64_add --require-pass --assembler spirv-as --build <build> --work <work>python scripts/run_gpu_tests.py --filter ps_f64_mods --require-pass --assembler spirv-as --build <build> --work <work>Base
3bd936ecd98995bca3e1da83d5e28d2343001aefwas merged into the recorded PR head for the second run. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Native runs used Windows 11, Python 3.12.10. Counts include unittest subtest events where applicable. AI-assisted with OpenAI Codex. Batch claim.Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T11:52:24Z.
Merged, thank you @klikso! This translator PR (rdna2spirv: the binary64 VALU ops take clamp and nothing else from their omod (SHADER-F64-OMODS-CARRY)) passed its own tests with main merged in during sodove's verification of this batch, so it went in with the batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.