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

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

@⁠amine23012004 on GitHub · 2026-11-25 19:21 UTC · original
amine23012004:test-cvt-norm-sweep-cache → main · +12 −1 · 1 files · 1 commits · open

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

**@⁠amine23012004** on GitHub · 2026-11-25 19:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2064) `amine23012004:test-cvt-norm-sweep-cache` → `main` · +12 −1 · 1 files · 1 commits · open 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)
FakeOracle recomputed expected_sweep_words (exact Fraction arithmetic over
65,536 f16 inputs, about 1.2-1.6 s a call) for every sweep kernel it ran.
Cache it per op and hand each kernel a sliced copy, so the bad_word and
wave64_diff mutations never reach the cache.

The file runs in 24 s instead of 98 s (Linux, Python 3.14, i7-8650U), and
all 14 tests still pass. No change to the tool or its reference model.

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

@⁠MSedgeMC on GitHub · 2026-11-25 19:45 UTC · original · approved these changes

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.

**@⁠MSedgeMC** on GitHub · 2026-11-25 19:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2064#pullrequestreview-6063938323) · **approved these changes** 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.
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/2064/head:github-bot/gh-2064'
git switch 'github-bot/gh-2064'

Merge

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