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

Merged
PierreEbele merged 1 commit from upstream-pr/1459 into main 2026-11-28 14:52:46 +00:00
PierreEbele commented 2026-11-25 00:39:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T00:39:05Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5482848093 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1459). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T00:39:05Z. --- `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)
ytsodacan commented 2026-11-25 03:42:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ytsodacan on 2026-11-25T03:42:34Z.


[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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7152169265 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1459#issuecomment-7152169265). Originally posted by [ytsodacan](https://github.com/ytsodacan) on 2026-11-25T03:42:34Z. --- **[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._
MoonEyes commented 2026-11-28 14:49:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:49:25Z.


Red/green: test_f32_fuzz.py failed 3 subtests on main where v_mul_legacy_f32 with omod was judged against -0, and they pass once the judge expects the +0 the translator models.
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main 4f9199d09 in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7240958728 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1459#issuecomment-7240958728). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:49:25Z. --- Red/green: test_f32_fuzz.py failed 3 subtests on main where v_mul_legacy_f32 with omod was judged against -0, and they pass once the judge expects the +0 the translator models. Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main 4f9199d09 in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1459
No description provided.