tests: the three frexp_f64 oracle files check the translator, and pin where their oracle models IEEE=1 (TEST-FREXP-ORACLES-TRANSLATE) #810

Manually merged
github merged 3 commits from gh-pr/810/head into gh-pr/810/base 2026-11-26 09:22:30 +00:00
Owner

@⁠qhukz13 on GitHub · 2026-11-24 14:05 UTC · original
qhukz13:cont/frexp-oracles-translate → main · +359 −35 · 10 files · 3 commits · merged 2026-11-24 16:06 UTC

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

Depends on: #746 (the f64_translate.py helper and the spirv_interp binary64 fixes), #764 (neighbouring DEBT entries). This branch is on top of both, so their commits show here until they are merged.

What and why

tests/semantic/test_valu_frexp_f64.py, test_valu_frexp_mant_f64.py and test_valu_frexp_exp_i32_f64.py were DEBT private oracles that never ran the translator. Each gets a TranslatorMatchesOracle class that runs the translated v_frexp_mant_f64 / v_frexp_exp_i32_f64 (f64_translate.py, spirv_interp) and checks it against the file's own oracle: normals, subnormals, zeros, infinities and quiet NaNs, both signs, abs/neg and clamp.

Comparing the two over 402 inputs, they disagree in two places, and in both docs/design.md sides with the translator. The v_frexp_mant_f64 row records gfx1036 measurements in the game's MODE (IEEE 0, denorm_mode_16_64 3):

  • a signalling NaN passes through unchanged; the oracles quiet it (0x7FF0000000000001 -> 0x7FF8000000000001), which is the IEEE=1 behaviour;
  • mul:2 / mul:4 / div:2 are ignored; the oracles scale the mantissa, which is the denorm_mode_16_64=0 behaviour.

The new classes pin those two measured behaviours instead of the oracle, and each file's module docstring now says that its oracle's sNaN/omod rules model IEEE=1. The oracles' own tests are not changed; aligning them with the game's MODE is left to their authors. The three DEBT entries are dropped.

Tested

  • The three files: OK as python -I scripts (the new classes run 5, 4 and 2 tests).
  • python -I tests/test_semantic_translator_use.py: OK without the three entries.
  • tools/semantic_mutants.py --op v_frexp_mant_f64 (the shared mant/exp branch): 92 of 134 mutants caught with test_valu_frexp_f64.py, 77 with test_valu_frexp_mant_f64.py, 42 with test_valu_frexp_exp_i32_f64.py (exponent only). Before, none of the three reached the translator.
  • compileall, tests/test_text_write_line_endings.py, scripts/check_no_game_data.py: OK.

tests/semantic/test_alu_frexp_f64.py already checks this translation against gfx1036 words; these classes add the oracle files' input classes to it.

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

AI-assisted (Claude Code).

🤖 Generated with Claude Code

**@⁠qhukz13** on GitHub · 2026-11-24 14:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/810) `qhukz13:cont/frexp-oracles-translate` → `main` · +359 −35 · 10 files · 3 commits · merged 2026-11-24 16:06 UTC Claimed in the coordination issue as: TEST-FREXP-ORACLES-TRANSLATE Depends on: #746 (the `f64_translate.py` helper and the `spirv_interp` binary64 fixes), #764 (neighbouring DEBT entries). This branch is on top of both, so their commits show here until they are merged. ### What and why `tests/semantic/test_valu_frexp_f64.py`, `test_valu_frexp_mant_f64.py` and `test_valu_frexp_exp_i32_f64.py` were DEBT private oracles that never ran the translator. Each gets a `TranslatorMatchesOracle` class that runs the translated `v_frexp_mant_f64` / `v_frexp_exp_i32_f64` (`f64_translate.py`, `spirv_interp`) and checks it against the file's own oracle: normals, subnormals, zeros, infinities and quiet NaNs, both signs, `abs`/`neg` and `clamp`. Comparing the two over 402 inputs, they disagree in two places, and in both `docs/design.md` sides with the translator. The `v_frexp_mant_f64` row records gfx1036 measurements in the game's MODE (IEEE 0, denorm_mode_16_64 3): - a signalling NaN passes through unchanged; the oracles quiet it (`0x7FF0000000000001` -> `0x7FF8000000000001`), which is the IEEE=1 behaviour; - `mul:2` / `mul:4` / `div:2` are ignored; the oracles scale the mantissa, which is the denorm_mode_16_64=0 behaviour. The new classes pin those two measured behaviours instead of the oracle, and each file's module docstring now says that its oracle's sNaN/omod rules model IEEE=1. The oracles' own tests are not changed; aligning them with the game's MODE is left to their authors. The three DEBT entries are dropped. ### Tested - The three files: OK as `python -I` scripts (the new classes run 5, 4 and 2 tests). - `python -I tests/test_semantic_translator_use.py`: OK without the three entries. - `tools/semantic_mutants.py --op v_frexp_mant_f64` (the shared mant/exp branch): 92 of 134 mutants caught with `test_valu_frexp_f64.py`, 77 with `test_valu_frexp_mant_f64.py`, 42 with `test_valu_frexp_exp_i32_f64.py` (exponent only). Before, none of the three reached the translator. - `compileall`, `tests/test_text_write_line_endings.py`, `scripts/check_no_game_data.py`: OK. `tests/semantic/test_alu_frexp_f64.py` already checks this translation against gfx1036 words; these classes add the oracle files' input classes to it. 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]>
By the guard's own _reaches, 26 of the DEBT files already run the translator (the eight saveexec files,
add_sub_co, alignbyte, perm, sad_u32, lerp_u8, mul_hi, dot4/dot8, cndmask_b64, int_to_float, and the f16
fract/pack/pk_*/rcp/rsq/sqrt files), and test_lds_add_sub_src2_u32.py no longer exists. Their entries kept those
files out of the check they now pass, so a file that stopped calling the translator would go unnoticed. DEBT keeps
the nine files that still model the answer themselves. The DEBT comment's design is unchanged: an entry still does
not have to be removed by the PR that fixes the file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_valu_frexp_f64.py, test_valu_frexp_mant_f64.py and test_valu_frexp_exp_i32_f64.py were DEBT private oracles that
never ran the translator. Each gets a TranslatorMatchesOracle class (tests/semantic/f64_translate.py, run in
tests/spirv_interp.py) that checks the translated v_frexp_mant_f64 / v_frexp_exp_i32_f64 against the file's own
oracle on normals, subnormals, zeros, infinities and quiet NaNs, both signs, abs/neg and clamp.

On two points the oracles model IEEE=1 / denorm_mode_16_64=0, not the game's MODE: they quiet a signalling NaN and
scale the mantissa by mul:2 / mul:4 / div:2. The v_frexp_mant_f64 row of docs/design.md records that gfx1036 under
IEEE 0 and denorm_mode_16_64 3 passes a signalling NaN through and ignores those modifiers, and so does the translator;
the classes pin those two measured behaviours instead of the oracle, and each file's docstring says so. The oracles'
own tests are unchanged. The three DEBT entries are dropped.

semantic_mutants --op v_frexp_mant_f64 (the shared mant/exp branch): 92 of 134 caught with test_valu_frexp_f64.py,
77 with test_valu_frexp_mant_f64.py, 42 with test_valu_frexp_exp_i32_f64.py (exponent only); none of the three
reached the translator 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:22:28 +00:00
github manually merged commit 80328dca77 into gh-pr/810/base 2026-11-26 09:22:30 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.