test_cvt_norm_mods_probe: compute the expected f16 sweep once per op in FakeOracle (TEST-CVT-NORM-SWEEP-CACHE) #2064

Merged
amine23012004 merged 1 commit from upstream-pr/2064 into main 2026-11-28 10:58:49 +00:00
amine23012004 commented 2026-11-25 19:21:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by amine23012004 on 2026-11-25T19:21:13Z.


Claimed in the coordination issue as: TEST-CVT-NORM-SWEEP-CACHE

What and why

FakeOracle.run in tests/test_cvt_norm_mods_probe.py called pr.expected_sweep_words(op) for every sweep kernel it ran. That function is the exact rational reference model over all 65,536 f16 inputs, about 1.2-1.6 s a call, and the fake runs cover many kernels (two ops, both waves, every VOP3 modifier, two halves, plus the MODE variants), several times per file. The file took 98 s on its own, and over 300 s when run next to other tests on a 4-core machine.

This change computes the sweep once per op in a module-level cache (_sweep_words). Each kernel still gets a sliced copy, so the bad_word and wave64_diff mutations never reach the cache. The tool and its reference model are unchanged.

The check job runs the roughly 500 standard-library test files one after another under a 15-minute timeout, so this file used a noticeable share of it.

Tested

  • python3 -I tests/test_cvt_norm_mods_probe.py: 14 tests OK, 98 s before, 22-24 s after on a busy machine, and 28 s before, 6 s after on an idle one (Linux, Python 3.14.8, Intel i7-8650U, CPU only). One sweep also measured at 1.23 s under Python 3.12.15, so this is not a 3.14 slowdown.
  • python3 -m compileall -q, python3 -I scripts/check_no_game_data.py tests/test_cvt_norm_mods_probe.py, python3 -I tests/test_text_write_line_endings.py: OK.
  • Based on main 9f9a7c5f; merges cleanly with #1638, which edits the same test file elsewhere.
  • Not run on Windows.

GPUs tested: n/a (test-only change, no GPU used)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5497663603 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2064). Originally posted by [amine23012004](https://github.com/amine23012004) on 2026-11-25T19:21:13Z. --- Claimed in the coordination issue as: TEST-CVT-NORM-SWEEP-CACHE ### What and why `FakeOracle.run` in `tests/test_cvt_norm_mods_probe.py` called `pr.expected_sweep_words(op)` for every sweep kernel it ran. That function is the exact rational reference model over all 65,536 f16 inputs, about 1.2-1.6 s a call, and the fake runs cover many kernels (two ops, both waves, every VOP3 modifier, two halves, plus the MODE variants), several times per file. The file took 98 s on its own, and over 300 s when run next to other tests on a 4-core machine. This change computes the sweep once per op in a module-level cache (`_sweep_words`). Each kernel still gets a sliced copy, so the `bad_word` and `wave64_diff` mutations never reach the cache. The tool and its reference model are unchanged. The `check` job runs the roughly 500 standard-library test files one after another under a 15-minute timeout, so this file used a noticeable share of it. ### Tested - `python3 -I tests/test_cvt_norm_mods_probe.py`: 14 tests OK, **98 s before, 22-24 s after** on a busy machine, and **28 s before, 6 s after** on an idle one (Linux, Python 3.14.8, Intel i7-8650U, CPU only). One sweep also measured at 1.23 s under Python 3.12.15, so this is not a 3.14 slowdown. - `python3 -m compileall -q`, `python3 -I scripts/check_no_game_data.py tests/test_cvt_norm_mods_probe.py`, `python3 -I tests/test_text_write_line_endings.py`: OK. - Based on `main` `9f9a7c5f`; merges cleanly with #1638, which edits the same test file elsewhere. - Not run on Windows. GPUs tested: n/a (test-only change, no GPU used) AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MSedgeMC commented 2026-11-25 19:45:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MSedgeMC on 2026-11-25T19:45:23Z.

Review: APPROVED


Verified on the PR branch: python3 -m unittest tests.test_cvt_norm_mods_probe -> 14 tests OK (2 skips). Measured effect: main runs the same suite in 19.4 s, the PR branch in 2.6 s — caching expected_sweep_words once per op removes the repeated exact-rational 65,536-input computation in FakeOracle. The cache returns a slice copy, so a bad-word mutation cannot poison later callers. Advisory: branch carries ~34 older commits not on main; rebase before merge.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6063938323 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2064#pullrequestreview-6063938323). Originally posted by [MSedgeMC](https://github.com/MSedgeMC) on 2026-11-25T19:45:23Z. **Review:** APPROVED --- Verified on the PR branch: python3 -m unittest tests.test_cvt_norm_mods_probe -> 14 tests OK (2 skips). Measured effect: main runs the same suite in 19.4 s, the PR branch in 2.6 s — caching expected_sweep_words once per op removes the repeated exact-rational 65,536-input computation in FakeOracle. The cache returns a slice copy, so a bad-word mutation cannot poison later callers. Advisory: branch carries ~34 older commits not on main; rebase before merge.
sodove commented 2026-11-28 10:12:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T10:12:05Z.


#2064 | head 1847fa73c1c80c89c099413f30dcbbfc50132fb0 | python3 -I tests/test_cvt_norm_mods_probe.py -v | red: 14 passed | green: 14 passed | Green on both trees, test runtime reduced in sample

This changes caching inside the test file itself. For a separate timing check I also ran the untouched main file with the same compiler tools. All 14 tests ran on each tree, including the assembly checks. Unittest reported 12.259 s on untouched main and 2.805 s after merge (one timing sample per tree).

Pinned main 33db04a7010e81c40a7a6a15624525aa0c4a3a58, merged into this PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237740055 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2064#issuecomment-7237740055). Originally posted by [sodove](https://github.com/sodove) on 2026-11-28T10:12:05Z. --- #2064 | head `1847fa73c1c80c89c099413f30dcbbfc50132fb0` | `python3 -I tests/test_cvt_norm_mods_probe.py -v` | red: 14 passed | green: 14 passed | **Green on both trees, test runtime reduced in sample** This changes caching inside the test file itself. For a separate timing check I also ran the untouched main file with the same compiler tools. All 14 tests ran on each tree, including the assembly checks. Unittest reported 12.259 s on untouched main and 2.805 s after merge (one timing sample per tree). Pinned main `33db04a7010e81c40a7a6a15624525aa0c4a3a58`, merged into this PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7237628300).
DadaCap commented 2026-11-28 10:58:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T10:58:51Z.


Merged, thank you @amine23012004! This PR (test_cvt_norm_mods_probe: compute the expected f16 sweep once per op in FakeOracle (TEST-CVT-NORM-SWEEP-CACHE)) was checked by zmasi or sodove and then by our own local run of its tests with main merged in, and it passed cleanly, so it went in with its reviewed batch.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238245966 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2064#issuecomment-7238245966). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T10:58:51Z. --- Merged, thank you @amine23012004! This PR (test_cvt_norm_mods_probe: compute the expected f16 sweep once per op in FakeOracle (TEST-CVT-NORM-SWEEP-CACHE)) was checked by zmasi or sodove and then by our own local run of its tests with main merged in, and it passed cleanly, so it went in with its reviewed batch. AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.
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!2064
No description provided.