f32_fuzz: judge v_mul_legacy_f32 omod -0 against the +0 the translator models #1459

Open
github-bot wants to merge 1 commit from github-bot/gh-1459 into main AGit
Owner

@⁠PierreEbele on GitHub · 2026-11-25 00:39 UTC · original
PierreEbele:f32-fuzz-legacy-omod-zero → main · +20 −0 · 2 files · 1 commits · open

tools/f32_fuzz.py reports a false translator mismatch for v_mul_legacy_f32 with an output modifier when the product underflows to -0.

Reproducer on main (CPU only): python3 -I tools/f32_fuzz.py --programs 1500 --seed 53 exits 1:

--- program 246: v_mul_legacy_f32_e64 v8, v1, v3 mul:2
    inputs: v1=0x1da20776(4.288875738331329e-21) v3=0x819d422d(-5.776764917635499e-38)
    model v8/vcc:      0x80000000(-0.0) 0x00000000(0.0)
    translated v8/vcc: 0x00000000(0.0) 0x00000000(0.0)

The translator's +0 is intended. Its v_mul_legacy_f32 branch in tools/rdna2spirv.py applies the measured IEEE-off omod rule (a -0 result becomes +0 under mul:2/mul:4/div:2; docs/design.md rows "v_mul_legacy_f32 default-mode f32 denormal flushing" and "Output modifiers on hardware"). The fuzzer's hardware side already treats this as the known deviation dev_omod_neg_zero. The translator-side check(), however, still compared against the ISA-text model's -0.

Change: check() now expects +0 in that case (only for the ops listed in TRANSLATOR_OMOD_POS_ZERO, currently v_mul_legacy_f32). model() and the hardware path are unchanged, and v_mul_f32, whose translation keeps -0, is still judged as before.

Tests (Linux arm64, no GPU):

  • New test_legacy_mul_omod_turns_an_underflowed_minus_zero_into_plus_zero in tests/test_f32_fuzz.py: fails on main (3 subtests: mul:2, mul:4, div:2) and passes on this branch. The whole file gives 30 tests, OK (1 skipped: needs the hw oracle).
  • python3 -I tools/f32_fuzz.py --programs 1500 --seed 53: exit 1 on main, exit 0 here.
  • scripts/check_no_game_data.py on both files: clean.

The case was found by a translator-oracle fuzzing campaign (seeds 41–56). No game data is involved and no GPU is needed.

AI-assisted.

Claimed in the coordination issue as: F32-FUZZ-LEGACY-OMOD-ZERO

🤖 Generated with Claude Code

**@⁠PierreEbele** on GitHub · 2026-11-25 00:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1459) `PierreEbele:f32-fuzz-legacy-omod-zero` → `main` · +20 −0 · 2 files · 1 commits · open `tools/f32_fuzz.py` reports a false translator mismatch for `v_mul_legacy_f32` with an output modifier when the product underflows to -0. **Reproducer on main** (CPU only): `python3 -I tools/f32_fuzz.py --programs 1500 --seed 53` exits 1: ``` --- program 246: v_mul_legacy_f32_e64 v8, v1, v3 mul:2 inputs: v1=0x1da20776(4.288875738331329e-21) v3=0x819d422d(-5.776764917635499e-38) model v8/vcc: 0x80000000(-0.0) 0x00000000(0.0) translated v8/vcc: 0x00000000(0.0) 0x00000000(0.0) ``` The translator's +0 is intended. Its `v_mul_legacy_f32` branch in `tools/rdna2spirv.py` applies the measured IEEE-off omod rule (a -0 result becomes +0 under `mul:2`/`mul:4`/`div:2`; docs/design.md rows "`v_mul_legacy_f32` default-mode f32 denormal flushing" and "Output modifiers on hardware"). The fuzzer's hardware side already treats this as the known deviation `dev_omod_neg_zero`. The translator-side `check()`, however, still compared against the ISA-text model's -0. **Change**: `check()` now expects +0 in that case (only for the ops listed in `TRANSLATOR_OMOD_POS_ZERO`, currently `v_mul_legacy_f32`). `model()` and the hardware path are unchanged, and `v_mul_f32`, whose translation keeps -0, is still judged as before. **Tests** (Linux arm64, no GPU): - New `test_legacy_mul_omod_turns_an_underflowed_minus_zero_into_plus_zero` in `tests/test_f32_fuzz.py`: fails on main (3 subtests: `mul:2`, `mul:4`, `div:2`) and passes on this branch. The whole file gives 30 tests, OK (1 skipped: needs the hw oracle). - `python3 -I tools/f32_fuzz.py --programs 1500 --seed 53`: exit 1 on main, exit 0 here. - `scripts/check_no_game_data.py` on both files: clean. The case was found by a translator-oracle fuzzing campaign (seeds 41–56). No game data is involved and no GPU is needed. AI-assisted. Claimed in the coordination issue as: F32-FUZZ-LEGACY-OMOD-ZERO 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The translator turns a -0 v_mul_legacy_f32 result into +0 under an output
modifier (the measured IEEE-off rule, docs/design.md), but the translator side
of check() still expected the ISA-text model's -0, so
f32_fuzz --programs 1500 --seed 53 reported a false mismatch (program 246).
The hardware side is unchanged: it already files this as dev_omod_neg_zero.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:52:08 +00:00
Author
Owner

@⁠ytsodacan on GitHub · 2026-11-25 03:42 UTC · original

[MERGE] (best of the #1459 / #1498 / #1502 duplicates; CI caveat below)

Compared all three diffs and ran tests/test_f32_fuzz.py on each in a fresh clone (python3, main: 29 OK; #1459: 30 OK; #1498: 29 OK; #1502: 31 OK).

Why this one:

  • It is the only fix that matches the actual defect. On main, ff.check("v_mul_legacy_f32", ...) with seed 53 program 246 inputs returns mismatch for mul:2, mul:4 and div:2 (model 0x80000000, translator 0). v_ceil_f32 with mul:2 already returns match on main, so the problem is specific to v_mul_legacy_f32, which the translator already models as +0 (docs/design.md).
  • The new test test_legacy_mul_omod_turns_an_underflowed_minus_zero_into_plus_zero (tests/test_f32_fuzz.py) is a real regression test: the three check calls fail on main and pass with the fix. It also pins that the hardware-side model still returns 0x80000000 and that v_mul_f32 keeps -0.
  • The change stays strict: the translator is judged against +0 for that op only, so a translator that returned -0 would now be flagged. #1502 accepts either word for every op.
  • Smallest diff (+8 tools/f32_fuzz.py, +12 tests).

Before merge (small, can be a follow-up):

  1. CI is still QUEUED (change-scope, no-game-data, windows, linux-gpu-tools, macos), so only my local run backs this. Please wait for green.
  2. tools/f32_fuzz.py, check(): the inline want[0] == 0x80000000 and any(m in OMOD ...) duplicates dev_omod_neg_zero (about line 941). Consider calling dev_omod_neg_zero(Case(...), want) for ops in TRANSLATOR_OMOD_POS_ZERO so omod_active stays the single source of truth. Not blocking.

Ideas ported from the duplicates: none needed. #1498's per-deviation counts in translate_cases could be a separate PR if wanted.

Triage assisted by Claude.

**@⁠ytsodacan** on GitHub · 2026-11-25 03:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1459#issuecomment-7152169265) **[MERGE]** (best of the #1459 / #1498 / #1502 duplicates; CI caveat below) Compared all three diffs and ran `tests/test_f32_fuzz.py` on each in a fresh clone (python3, main: 29 OK; #1459: 30 OK; #1498: 29 OK; #1502: 31 OK). Why this one: - It is the only fix that matches the actual defect. On main, `ff.check("v_mul_legacy_f32", ...)` with seed 53 program 246 inputs returns `mismatch` for `mul:2`, `mul:4` and `div:2` (model `0x80000000`, translator `0`). `v_ceil_f32` with `mul:2` already returns `match` on main, so the problem is specific to `v_mul_legacy_f32`, which the translator already models as +0 (docs/design.md). - The new test `test_legacy_mul_omod_turns_an_underflowed_minus_zero_into_plus_zero` (tests/test_f32_fuzz.py) is a real regression test: the three `check` calls fail on main and pass with the fix. It also pins that the hardware-side model still returns `0x80000000` and that `v_mul_f32` keeps -0. - The change stays strict: the translator is judged against +0 for that op only, so a translator that returned -0 would now be flagged. #1502 accepts either word for every op. - Smallest diff (+8 tools/f32_fuzz.py, +12 tests). Before merge (small, can be a follow-up): 1. CI is still QUEUED (change-scope, no-game-data, windows, linux-gpu-tools, macos), so only my local run backs this. Please wait for green. 2. tools/f32_fuzz.py, `check()`: the inline `want[0] == 0x80000000 and any(m in OMOD ...)` duplicates `dev_omod_neg_zero` (about line 941). Consider calling `dev_omod_neg_zero(Case(...), want)` for ops in `TRANSLATOR_OMOD_POS_ZERO` so `omod_active` stays the single source of truth. Not blocking. Ideas ported from the duplicates: none needed. #1498's per-deviation counts in `translate_cases` could be a separate PR if wanted. _Triage assisted by Claude._
github-bot force-pushed github-bot/gh-1459 from 58027bf9b0 to 93d0c205ba 2026-11-26 16:01:28 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1459/head:github-bot/gh-1459'
git switch 'github-bot/gh-1459'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1459'
git switch 'github-bot/gh-1459'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1459'
git switch 'github-bot/gh-1459'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1459'
git switch 'main'
git merge --squash 'github-bot/gh-1459'
git switch 'main'
git merge --ff-only 'github-bot/gh-1459'
git switch 'main'
git merge 'github-bot/gh-1459'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.