rdna2spirv: f16 interp deltas and toward-zero p2 narrow (SHADER-468) #1181
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1181"
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 whoalin1 on 2026-11-24T19:42:37Z.
Claimed in the coordination issue as: SHADER-468 (claim)
Depends on: none
What and why
For a 16-bit (
f16) interpolation channel, the SPI writes the P10/P20 delta words as per-half f16 differences of the two packed halves, andv_interp_p2_f16narrows its result toward zero (the driver's ISA runs the pair insides_round_mode 0x000c, MODE.FP16_ROUND toward zero — LLVM's SIModeRegister documents the same requirement). The translation used the f32 difference of the decoded halves and narrowed to nearest even.Measured on real RDNA2 hardware (
tools/f16_interp_probe.py, 12 hand-written draws, 98,304 pixel samples, Ryzen 5 7600 iGPU / gfx1036, AMD Windows driver 24.10.24):The remaining 30 misses are documented in the
docs/design.mdrow (26 f16-subnormal boundary cases, 4 exact-grid-boundary perspective cases).Changes:
tools/rdna2spirv.py:Gen.f16_roundrounds an f32 to the nearest f16 value via integer-built bits +UnpackHalf2x16(unfooldable per OLD-512/OLD-513); the interpolation weighting rounds P1−P0 / P2−P0 to f16 for 16-bit-channel reads;v_interp_p2_f16narrows withf16_bits(rtz=True).runtime/test/vk_harness.cpp:VKH_PC_BYTESmust be a multiple of 4 (VkPushConstantRange), both-stage capability scan covers Float16/StorageInputOutput16/Float64,VKH_SHADER_INFO=1dumps driver ISA.tools/f16_interp_probe.py(new measurement tool, hand-written GLSL only),tests/semantic/test_interp_f16_round.py(new),test_interp_p1lv_f16.pyoracle updated to the measured model,docs/design.mdcontract row updated.Tested
py -3.14 -I scripts/run_semantic_tests.py tests/semantic: 471 files, 6,170 tests, 0 failedpy -3.14 -m unittest discover -s tests/semantic -p "test_interp*.py": 207 tests OK;-p "test_f16*.py": 49 OK (40 env skips)scripts/check_no_game_data.pyon all changed files: cleantools/f16_interp_probe.py --gpu amdre-run after the change: rdna2 model 98,274/98,304 (identical measurement)run_gpu_tests.py):--filter interp3/3 and--filter f1620/20 on both GPUs below,LEONIDA_VK_VALIDATION=1on AMD: 0 validation errorsGPUs tested: AMD Radeon Graphics (Ryzen 5 7600 iGPU, gfx1036-class RDNA2, driver 24.10.24, Vulkan 1.3.280, Windows 11); NVIDIA GeForce RTX 4070 SUPER (driver 610.88, Windows 11)
AI-assisted: yes (Devin)
Checklist
mainand merges cleanlydocs/design.mdcontract table with how it was confirmed (on-hardware measurement)Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T19:45:00Z.
Review: APPROVED
### Clean-Room & Technical Verification
main(6293c1c4f), zero merge conflicts.Gen.f16_roundcorrectly unpacks integer-built bits viaUnpackHalf2x16, avoiding folding regressions across driver optimization passes.attribute()accurately reflects SPI parameter writing behavior for 16-bit channels.v_interp_p2_f16forced RTZ (rtz=True) directly aligns with AMD driver hardware mode register settings (s_round_mode 0x000c) around the interpolation pair.gfx1036).tests/semantic/test_interp_f16_round.py: 2/2 passed.tests/semantic/test_interp_p1lv_f16.py: 36/36 passed.docs/design.md.LGTM! Approved.
Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:09:34Z.
Recommendation: [WAIT]
Reasoning: f16 interpolation now uses per-half f16 P10/P20 deltas and toward-zero narrowing in
v_interp_p2_f16, which the author measured on real RDNA2 with a new 313-line probe tool, and the vk harness is extended. It's a precision change to every f16 interpolant, and nobody has independently reproduced it. Before merging, someone should run the new semantic tests and the probe/harness on a second GPU (ideally another RDNA2 and one non-AMD) to confirm the measurement. 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 withmain.Impact level: 5/10
Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-24T20:10:19Z.
Verified
af76fefadon Arch Linux (Python 3.14):PYTHONPATH=tests/semantic python3 -m unittest tests/semantic/test_interp_f16_round.py tests/semantic/test_interp_p1lv_f16.py: 38 tests passed (0.109 s)AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T18:22:41Z.
Review: APPROVED
Approving
e4eed02. Merged into current main (b9320a1) with no conflicts. The full translator suite, including the newtest_interp_f16_round.pyand the updatedtest_interp_p1lv_f16.py, gives 491 files / 6,294 tests with onlytest_int32_to_f64failing, the same baseline failure as main here (Linux, Python 3.13).The translator change matches the model the probe selects. P10/P20 of a 16-bit channel are rounded to f16 through
f16_bits, so no driver can fold the round trip away, while the weights and sum stay f32.v_interp_p2_f16now narrows toward zero regardless of MODE, which follows from thes_round_mode 0x000cthe AMD compiler puts around the pair. I can't repeat the gfx1036 measurement here; the code does what the write-up says it measured.AI-assisted (Claude).
Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T19:08:19Z.
Real-hardware probe results on
e4eed0218(current head):AMD RDNA2 iGPU (
AMD Radeon(TM) Graphics, subgroup 32..64), 98,304 samples over 12 draws:rdna2translator_rnetranslator_rtzf16_accThe remaining 30
rdna2misses are the already-described corner cases: subnormal-range values and exact f16-grid/perspective-weight cases. The next-best model is still 8,281 samples behind, so this strongly supports the implemented per-half f16 delta + f32 weighted sum + toward-zero p2 narrow model rather than the old RNE model.NVIDIA RTX 4070 SUPER: the probe cannot run on this device because it reports no
storageInputOutput16; with the harness guard in this branch it exits honestly as unsupported instead of crashing or producing meaningless data:vk_harnessrebuilt cleanly (BUILD_RC=0). Logs are local inleonida-s468/.scratch/f16_{amd,nv}.log. AI-assisted verification with Devin.Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:44:00Z.
Windows 11 + NVIDIA GeForce RTX 3090 + Khronos Validation Verification (
e4eed0218d)Verified
e4eed0218dd72369c53c9cdc163ef178617a0e45merged cleanly ontomain(adfb3821a) on native Windows 11 (10.0.26200, MSVC19.44.35228, CPython3.12.10) and NVIDIA GeForce RTX 3090 (subgroup32..32, Vulkan1.4,VK_LAYER_KHRONOS_validation1.4.363.1), with zero game data.Red -> Green Verification
main):test_p10_is_an_f16_difference:-65504.0to1000.0ati = 0.25returns finite0xf9f7instead of0x7c00(+inf).test_p2_narrows_toward_zero:0.4 * 3.0returns nearest-even0x3ccdinstead of toward-zero0x3ccc.main + #1181):PYTHONPATH=tests/semantic python -I -m unittest tests/semantic/test_interp_f16_round.py tests/semantic/test_interp_p1lv_f16.py -v:38/38 OK(0.598s).vs_f16_pack+ps_interp_f16_highon physical NVIDIA GeForce RTX 3090 underVK_LAYER_KHRONOS_validation1.4.363.1:ps_interp_f16_high ok(0validation errors).vk_harness.cppneeds_io16guard (lines 329-330, 460-467): on NVIDIA desktop Vulkan (RTX 3090),VkPhysicalDeviceVulkan11Features::storageInputOutput16isVK_FALSE, andvk_harnesscleanly detectsOpCapability StorageInputOutput16(4436) and exits77(unsupported: ... uses 16-bit shader input/output and the device has no storageInputOutput16) instead of failingVkDevice/VkPipelinecreation.test_docs_design_rows.py(5/5 OK),test_docs_table_rows.py(2/2 OK),test_docs_encoding.py(1/1 OK), andcheck_no_game_data.pyall pass.Two Non-Blocking Findings in
tools/f16_interp_probe.py(Observed Live on RTX 3090)1instead of77onUNSUPPORTED(tools/f16_interp_probe.py:242-243):"exits 77 when either is missing or the device has no 16-bit shader input/output", andvk_harnesscorrectly returns77on desktop NVIDIA GPUs lackingstorageInputOutput16. However,run_drawexecutesraise SystemExit(f"SKIP: {r.stderr.strip()}"), and passing a string toSystemExitcauses Python to exit with code1rather thanUNSUPPORTED(77). Printing tosys.stderrand raisingSystemExit(UNSUPPORTED)preserves exit code77."LEONIDA_VK_DEVICE": "4070"inGPU_ENV["nv"](tools/f16_interp_probe.py:85):--gpu nvon anRTX 3090(or any non-4070 NVIDIA card) fails immediately withLEONIDA_VK_DEVICE=4070: no Vulkan physical device matches(rc=1). Dropping"LEONIDA_VK_DEVICE": "4070"(or matching"nvidia"/"geforce"/"rtx") lets--gpu nvselect any NVIDIA adapter viaVK_LOADER_DRIVERS_SELECT.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T03:00:07Z.
Verified by OreoFR
48bae6cad+ PR heade4eed0218(tested as a merge; it also merges without conflict on the newer main5825b02ff)test_interp_f16_round.py,test_interp_p1lv_f16.py(tests/semantic); translator suite;vk_harnessbuilttest_interp_f16_round2 FAIL (0x3ccd != 0x3ccctoward-zero p2, p10 difference),test_interp_p1lv_f165 FAIL of 36 (off-by-one f16 results); translator suite on main: 526 files, 6506 tests, 1 file failing (test_valu_cvt_f16_int16_mods, a known main failure)vk_harnesscompiles; translator suite 527 files, 6508 tests, same single known failure, no new onegta6rt.exebuilds and links;dumpbin /dependentsshows the same DLLs as main, no network DLL)AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-29T03:36:35Z.
Merging, thank you @whoalin1! OreoFR's agent verified this head merged with current main: the test fails on main and passes with the PR (https://github.com/ProjectLeonida/mandy/pull/1181#issuecomment-7249777845), and it still merges cleanly.
AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.