tests: the f64 rcp/rsq/sqrt/cvt oracle files check the translator, and spirv_interp divides doubles as doubles (TEST-F64-ORACLES-TRANSLATE) #746

Manually merged
github merged 1 commit from gh-pr/746/head into gh-pr/746/base 2026-11-26 09:19:13 +00:00
Owner

@⁠qhukz13 on GitHub · 2026-11-24 13:23 UTC · original
qhukz13:cont/f64-oracles-translate → main · +189 −5 · 7 files · 1 commits · merged 2026-11-24 16:06 UTC

Claimed in the coordination issue as: TEST-F64-ORACLES-TRANSLATE

What and why

tests/semantic/test_valu_{rcp,rsq,sqrt}_f64.py and test_valu_cvt_f32_f64.py were private oracles, exempted in tests/test_semantic_translator_use.py ("should translate a listing"): nothing in them ran the translator. tools/semantic_mutants.py --op v_rcp_f64 (and rsq, sqrt, cvt_f32_f64) showed it: swapping the high and low word of the f64 source in the shared f64() helper (rdna2spirv.py line 8487) failed none of the four files.

  • Each file gets a TranslatorMatchesOracle class: the instruction is translated (tests/semantic/f64_translate.py), run in tests/spirv_interp.py, and its word checked against the file's own oracle. Inputs are the ones whose SPIR-V result is defined (docs/design.md rows for these ops): no NaN; no zero divisor for rcp, nothing below zero for the roots, no binary32 subnormal or overflow for cvt. Both signs, subnormals, infinities, neg/abs and clamp are covered.
  • The four exemptions are removed from tests/test_semantic_translator_use.py.

Doing this found a bug in tests/spirv_interp.py: its F64 table had no OpFDiv, so a binary64 division fell through to the binary32 table. The translated v_rcp_f64 of 3.0 gave 0x3fd5555560000000 instead of 0x3fd5555555555555, and of 1e300 gave 0. OpFDiv is added to F64 (x / 0 as the binary32 one does), and OpFConvert is added (binary64 to binary32 rounds to nearest even, binary32 to binary64 is exact).

The oracles are correctly rounded, which matches the translator's contract (GLSL Sqrt/InverseSqrt, OpFDiv). RDNA2's own v_sqrt_f64 is not correctly rounded (docs/design.md), and none of the four ops occurs in the game listings, so this checks the translation against its documented contract, not against hardware.

Tested

  • The four files: OK under python -m unittest discover -s tests/semantic -p ... and as python -I scripts. Against main's spirv_interp.py the new classes fail (rcp: 19 failures; cvt: 34 errors, no OpFConvert).
  • python -I tests/test_semantic_translator_use.py: OK without the four exemptions.
  • semantic_mutants --op v_rcp_f64 / v_rsq_f64 / v_sqrt_f64 / v_cvt_f32_f64 with the matching file: the line-8487 hi -> lo mutant is now caught by each (survived all four before). The four survivors left are v_add_f64 code in the same shared branch (lines 8508, 8516), which test_valu_add_f64.py covers.
  • Other spirv_interp users: the tests/semantic files pass, and the five pytest files (test_f16_hw_words, test_f16_op_sel_values, test_mode_round, test_u16_high_half, test_values) pass, 330 tests.
  • tests/test_text_write_line_endings.py, tests/test_ci_registration.py, scripts/check_no_game_data.py, compileall: OK.

Linux, CPU only; no GPU, no game files.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

**@⁠qhukz13** on GitHub · 2026-11-24 13:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/746) `qhukz13:cont/f64-oracles-translate` → `main` · +189 −5 · 7 files · 1 commits · merged 2026-11-24 16:06 UTC Claimed in the coordination issue as: TEST-F64-ORACLES-TRANSLATE ### What and why `tests/semantic/test_valu_{rcp,rsq,sqrt}_f64.py` and `test_valu_cvt_f32_f64.py` were private oracles, exempted in `tests/test_semantic_translator_use.py` ("should translate a listing"): nothing in them ran the translator. `tools/semantic_mutants.py --op v_rcp_f64` (and rsq, sqrt, cvt_f32_f64) showed it: swapping the high and low word of the f64 source in the shared `f64()` helper (`rdna2spirv.py` line 8487) failed none of the four files. - Each file gets a `TranslatorMatchesOracle` class: the instruction is translated (`tests/semantic/f64_translate.py`), run in `tests/spirv_interp.py`, and its word checked against the file's own oracle. Inputs are the ones whose SPIR-V result is defined (docs/design.md rows for these ops): no NaN; no zero divisor for rcp, nothing below zero for the roots, no binary32 subnormal or overflow for cvt. Both signs, subnormals, infinities, neg/abs and clamp are covered. - The four exemptions are removed from `tests/test_semantic_translator_use.py`. Doing this found a bug in `tests/spirv_interp.py`: its `F64` table had no `OpFDiv`, so a binary64 division fell through to the binary32 table. The translated `v_rcp_f64` of 3.0 gave `0x3fd5555560000000` instead of `0x3fd5555555555555`, and of 1e300 gave 0. `OpFDiv` is added to `F64` (x / 0 as the binary32 one does), and `OpFConvert` is added (binary64 to binary32 rounds to nearest even, binary32 to binary64 is exact). The oracles are correctly rounded, which matches the translator's contract (GLSL `Sqrt`/`InverseSqrt`, `OpFDiv`). RDNA2's own `v_sqrt_f64` is not correctly rounded (docs/design.md), and none of the four ops occurs in the game listings, so this checks the translation against its documented contract, not against hardware. ### Tested - The four files: OK under `python -m unittest discover -s tests/semantic -p ...` and as `python -I` scripts. Against `main`'s `spirv_interp.py` the new classes fail (rcp: 19 failures; cvt: 34 errors, no `OpFConvert`). - `python -I tests/test_semantic_translator_use.py`: OK without the four exemptions. - `semantic_mutants --op v_rcp_f64 / v_rsq_f64 / v_sqrt_f64 / v_cvt_f32_f64` with the matching file: the line-8487 hi -> lo mutant is now caught by each (survived all four before). The four survivors left are `v_add_f64` code in the same shared branch (lines 8508, 8516), which `test_valu_add_f64.py` covers. - Other `spirv_interp` users: the `tests/semantic` files pass, and the five pytest files (`test_f16_hw_words`, `test_f16_op_sel_values`, `test_mode_round`, `test_u16_high_half`, `test_values`) pass, 330 tests. - `tests/test_text_write_line_endings.py`, `tests/test_ci_registration.py`, `scripts/check_no_game_data.py`, `compileall`: OK. Linux, CPU only; no GPU, no game files. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
test_valu_{rcp,rsq,sqrt}_f64.py and test_valu_cvt_f32_f64.py were private oracles exempted in
test_semantic_translator_use.py: nothing in them ran the translator, so swapping the high and low word of the f64
source in rdna2spirv.py's shared f64() helper failed no test. Each now has a TranslatorMatchesOracle class that
translates the instruction (tests/semantic/f64_translate.py), runs it in tests/spirv_interp.py and checks the word
against the file's own oracle, on inputs whose SPIR-V result is defined (no NaN; no zero divisor for rcp, nothing
below zero for the roots, no binary32 subnormal or overflow for cvt): both signs, subnormals, infinities, neg/abs and
clamp. The four exemptions are dropped.

Doing that found that spirv_interp had no binary64 OpFDiv: the op fell through to the binary32 table, so the
translated v_rcp_f64 of 3.0 gave 0x3fd5555560000000 instead of 0x3fd5555555555555, and of 1e300 gave 0. OpFDiv joins
the F64 table (x / 0 as the binary32 one), and OpFConvert is added (binary64 -> binary32 rounds to nearest even).

semantic_mutants --op v_rcp_f64 (and rsq, sqrt, cvt_f32_f64): the line-8487 hi -> lo mutant of f64() now fails each
file (it survived all four before).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:19:11 +00:00
github manually merged commit ee4dfb04c7 into gh-pr/746/base 2026-11-26 09:19:13 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 13:26 UTC · original · approved these changes

LGTM. Outstanding work on f64 VALU translation verification: adds 64_translate.py bridge, fixes spirv_interp.py binary64 OpFDiv / OpFConvert handling, and hooks
cp_f64,
sq_f64, sqrt_f64, and cvt_f32_f64 into active translator testing.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 13:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/746#pullrequestreview-6040001270) · **approved these changes** LGTM. Outstanding work on f64 VALU translation verification: adds 64_translate.py bridge, fixes spirv_interp.py binary64 OpFDiv / OpFConvert handling, and hooks cp_f64, sq_f64, sqrt_f64, and cvt_f32_f64 into active translator testing.
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 13:27 UTC · original · reviewed

Independent CPU-only verification of PR head ee4dfb04c7de6a6a8858b0d8ef9b43f8c9c3b91e on base 2d73c242fddfe26d57b52ee150704e6c3b23cff4: all four affected f64 oracle modules passed (237 tests total), and tests/test_semantic_translator_use.py passed 3/3. This exercises the new translated v_rcp_f64, v_rsq_f64, v_sqrt_f64, and v_cvt_f32_f64 cases through the SPIR-V interpreter; no GPU or game data used.

I also ran the complete semantic suite: 6,116 tests across 465 files, with two files failing only because spirv-as/spirv-val are absent from PATH (test_sopc_validation, test_unary_f16_validation). The remaining files completed without reported failures. These are local environment failures, not attributed to this PR. At the latest hosted-check refresh, label, no-game-data, and change-scope checks were still queued. AI-assisted independent verification.

**@⁠KernelSmoker** on GitHub · 2026-11-24 13:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/746#pullrequestreview-6040006914) · **reviewed** Independent CPU-only verification of PR head `ee4dfb04c7de6a6a8858b0d8ef9b43f8c9c3b91e` on base `2d73c242fddfe26d57b52ee150704e6c3b23cff4`: all four affected f64 oracle modules passed (237 tests total), and `tests/test_semantic_translator_use.py` passed 3/3. This exercises the new translated `v_rcp_f64`, `v_rsq_f64`, `v_sqrt_f64`, and `v_cvt_f32_f64` cases through the SPIR-V interpreter; no GPU or game data used. I also ran the complete semantic suite: 6,116 tests across 465 files, with two files failing only because `spirv-as`/`spirv-val` are absent from PATH (`test_sopc_validation`, `test_unary_f16_validation`). The remaining files completed without reported failures. These are local environment failures, not attributed to this PR. At the latest hosted-check refresh, label, no-game-data, and change-scope checks were still queued. AI-assisted independent verification.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 13:30 UTC · original · approved these changes

Audited and verified. Clean-room compliant.

  • Adds f64_translate.py linking VALU double-precision oracle files to spirv_interp execution.
  • Verifies translated SPIR-V output matches mathematical oracles for v_cvt_f32_f64, v_rcp_f64, v_rsq_f64, and v_sqrt_f64.
  • Removes translated files from test_semantic_suites_translate.py exemption list.
**@⁠abnalstlll-byte** on GitHub · 2026-11-24 13:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/746#pullrequestreview-6040064557) · **approved these changes** Audited and verified. Clean-room compliant. - Adds f64_translate.py linking VALU double-precision oracle files to spirv_interp execution. - Verifies translated SPIR-V output matches mathematical oracles for v_cvt_f32_f64, v_rcp_f64, v_rsq_f64, and v_sqrt_f64. - Removes translated files from test_semantic_suites_translate.py exemption list.
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 13:32 UTC · original

Follow-up to my review: I reran the full semantic suite in the project's Fedora 45 tool container with SPIRV-Tools available. python3 -I scripts/run_semantic_tests.py tests/semantic -j 16 completed 465 files, 6,116 tests, 0 files failed in 90 seconds. Environment: Python 3.15.2 and SPIRV-Tools v2026.2. This supersedes the earlier local run where two files could not find spirv-as/spirv-val; those were environment failures, not project failures. The four affected f64 oracle modules still passed 237/237, and the translator-use guard passed 3/3.

**@⁠KernelSmoker** on GitHub · 2026-11-24 13:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/746#issuecomment-7132984580) Follow-up to my review: I reran the full semantic suite in the project's Fedora 45 tool container with SPIRV-Tools available. `python3 -I scripts/run_semantic_tests.py tests/semantic -j 16` completed **465 files, 6,116 tests, 0 files failed** in 90 seconds. Environment: Python 3.15.2 and SPIRV-Tools v2026.2. This supersedes the earlier local run where two files could not find `spirv-as`/`spirv-val`; those were environment failures, not project failures. The four affected f64 oracle modules still passed 237/237, and the translator-use guard passed 3/3.
This discussion has been locked. Commenting is limited to contributors.
No description provided.