[PR #1181] rdna2spirv: f16 interp deltas and toward-zero p2 narrow (SHADER-468) #1214

Open
opened 2026-11-26 20:20:28 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1181
Author: @whoalin1
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: shader-468-f16-varying


📝 Commits (2)

  • 5657240 rdna2spirv: f16 interp deltas and toward-zero p2 narrow (SHADER-468)
  • e4eed02 f16_interp_probe: reconfigure stdout with errors="replace" (test_tool_stdout_encoding)

📊 Changes

6 files changed (+520 additions, -40 deletions)

View changed files

📝 docs/design.md (+2 -2)
📝 runtime/test/vk_harness.cpp (+76 -15)
➕ tests/semantic/test_interp_f16_round.py (+55 -0)
📝 tests/semantic/test_interp_p1lv_f16.py (+46 -21)
➕ tools/f16_interp_probe.py (+317 -0)
📝 tools/rdna2spirv.py (+24 -2)

📄 Description

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, and v_interp_p2_f16 narrows its result toward zero (the driver's ISA runs the pair inside s_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):

model samples explained
rdna2 (this PR: f16-rounded deltas, f32 sum, toward-zero narrow) 98,274
same model, nearest-even narrow 62,226
same model, f32 deltas (old translation) 89,993
f16 accumulated sum 86,919

The remaining 30 misses are documented in the docs/design.md row (26 f16-subnormal boundary cases, 4 exact-grid-boundary perspective cases).

Changes:

  • tools/rdna2spirv.py: Gen.f16_round rounds 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_f16 narrows with f16_bits(rtz=True).
  • runtime/test/vk_harness.cpp: VKH_PC_BYTES must be a multiple of 4 (VkPushConstantRange), both-stage capability scan covers Float16/StorageInputOutput16/Float64, VKH_SHADER_INFO=1 dumps 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.py oracle updated to the measured model, docs/design.md contract row updated.

Tested

  • py -3.14 -I scripts/run_semantic_tests.py tests/semantic: 471 files, 6,170 tests, 0 failed
  • py -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.py on all changed files: clean
  • tools/f16_interp_probe.py --gpu amd re-run after the change: rdna2 model 98,274/98,304 (identical measurement)
  • GPU suite (run_gpu_tests.py): --filter interp 3/3 and --filter f16 20/20 on both GPUs below, LEONIDA_VK_VALIDATION=1 on AMD: 0 validation errors

GPUs 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

  • Based on current main and merges cleanly
  • One topic; follow-up work goes in a new pull request
  • No game data, keys or decryption — the probe uses hand-written GLSL fixtures only
  • Translator rule change recorded in the docs/design.md contract table with how it was confirmed (on-hardware measurement)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1181 **Author:** [@whoalin1](https://github.com/whoalin1) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `shader-468-f16-varying` --- ### 📝 Commits (2) - [`5657240`](https://github.com/ubiquitarianism/leonida/commit/5657240e3555586eb68589cb9051d8464935609c) rdna2spirv: f16 interp deltas and toward-zero p2 narrow (SHADER-468) - [`e4eed02`](https://github.com/ubiquitarianism/leonida/commit/e4eed0218dd72369c53c9cdc163ef178617a0e45) f16_interp_probe: reconfigure stdout with errors="replace" (test_tool_stdout_encoding) ### 📊 Changes **6 files changed** (+520 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+2 -2) 📝 `runtime/test/vk_harness.cpp` (+76 -15) ➕ `tests/semantic/test_interp_f16_round.py` (+55 -0) 📝 `tests/semantic/test_interp_p1lv_f16.py` (+46 -21) ➕ `tools/f16_interp_probe.py` (+317 -0) 📝 `tools/rdna2spirv.py` (+24 -2) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-468 ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7139740114)) 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, and `v_interp_p2_f16` narrows its result **toward zero** (the driver's ISA runs the pair inside `s_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): | model | samples explained | |---|---| | rdna2 (this PR: f16-rounded deltas, f32 sum, toward-zero narrow) | **98,274** | | same model, nearest-even narrow | 62,226 | | same model, f32 deltas (old translation) | 89,993 | | f16 accumulated sum | 86,919 | The remaining 30 misses are documented in the `docs/design.md` row (26 f16-subnormal boundary cases, 4 exact-grid-boundary perspective cases). Changes: - `tools/rdna2spirv.py`: `Gen.f16_round` rounds 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_f16` narrows with `f16_bits(rtz=True)`. - `runtime/test/vk_harness.cpp`: `VKH_PC_BYTES` must be a multiple of 4 (VkPushConstantRange), both-stage capability scan covers Float16/StorageInputOutput16/Float64, `VKH_SHADER_INFO=1` dumps 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.py` oracle updated to the measured model, `docs/design.md` contract row updated. ### Tested - `py -3.14 -I scripts/run_semantic_tests.py tests/semantic`: **471 files, 6,170 tests, 0 failed** - `py -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.py` on all changed files: clean - `tools/f16_interp_probe.py --gpu amd` re-run after the change: rdna2 model 98,274/98,304 (identical measurement) - GPU suite (`run_gpu_tests.py`): `--filter interp` 3/3 and `--filter f16` 20/20 on **both** GPUs below, `LEONIDA_VK_VALIDATION=1` on AMD: 0 validation errors GPUs 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 - [x] Based on current `main` and merges cleanly - [x] One topic; follow-up work goes in a new pull request - [x] No game data, keys or decryption — the probe uses hand-written GLSL fixtures only - [x] Translator rule change recorded in the `docs/design.md` contract table with how it was confirmed (on-hardware measurement) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1214
No description provided.