tests: the local-baseline case does not measure CPU contention (macos-python's only red) #2653

Merged
leonida/mandy
fiestorra merged 3 commits from fix/bench-baseline-threshold into main 2026-12-01 11:29:21 +00:00

Pull request successfully merged and closed

fiestorra commented 2026-11-29 22:23:25 +00:00

This changes a test's threshold, so it is the test owner's call rather than mine. It is not a draft pull request - if you would rather keep the old invocation, say so and I will close it.

The macos-python job's only failure is test_a_local_baseline_replaces_the_committed_one, and the assertion that fails is not about code:

File "…/tests/test_bench_translate.py", line 106
  self.assertEqual(result.returncode, 0, result.stderr)
AssertionError: 1 != 0 :

Exit 1 with empty stderr is scripts/bench_translate.py's own over-limit verdict (return 1 if slow else 0 for --json). Two runs seconds apart measured more than --max-slowdown 5 apart on a shared runner.

What the case is actually for, in its own comment: "The committed numbers come from one machine; on another they would fail a run with no regression in it" - it checks that a local baseline replaces the committed one, that baseline_source is that file, that the key sets match, and that no spurious regression is reported. The 5x limit was incidental to exercising the flag.

What the change is: the --max-slowdown 5 guard is removed from that one invocation - not raised - because scripts/bench_translate.py takes --max-slowdown with default=None and applies no limit at all when it is absent. The case keeps its intent (a local baseline replaces the committed one) without also measuring CPU contention. It also drops self.assertEqual(report["over_limit"], []), which only held while the guard existed, and asserts instead that the report's baseline is the file the test just wrote. The over-limit behaviour keeps its own deterministic coverage: --max-slowdown 0.01 must report one, asserted at line 48-51 against a synthetic baseline that cannot be noise.

Tested: python3 -m pytest tests/test_bench_translate.py -q -> 10 passed, 5 subtests, including the forced-regression case that still asserts a non-empty over_limit.

Not tested: on macOS, which is the job this is for - I have Windows only. What I can say is that the change cannot make the plumbing assertions weaker (they are untouched) and that the timing assertion is the only one removed.

If a maintainer would rather keep a performance threshold in this case, the alternative is to take the better of two written baselines, which is more code for the same purpose; I did not choose for you.

The extra commit at the tip (no longer carried)

The branch used to carry a3b5ebea1 (test(semantic): align computed-I/J f16 interp oracle…), added only because semantic-tests was red on main for that oracle and every branch cut from main inherited it. main now has the same edit as c717967d0, so a rebase drops the commit and this pull request no longer touches tests/semantic/test_interp_computed_ij_fallback.py - the diff is only what this change actually needs.

AI-assisted: yes - DeepSeek v4.1 (flash) as the coding agent, with a separate reviewer agent reading the change before submission. Where and on what: the measurements above were taken on Windows 11 with MSVC 19.44.35226 on an RTX 4090 (NVIDIA driver 621.24) where a C++ or GPU path is involved; Python and docs cases need none of it.

Written with an AI assistant.

**This changes a test's threshold, so it is the test owner's call rather than mine.** It is not a draft pull request - if you would rather keep the old invocation, say so and I will close it. The `macos-python` job's only failure is `test_a_local_baseline_replaces_the_committed_one`, and the assertion that fails is not about code: ``` File "…/tests/test_bench_translate.py", line 106 self.assertEqual(result.returncode, 0, result.stderr) AssertionError: 1 != 0 : ``` Exit 1 with **empty stderr** is `scripts/bench_translate.py`'s own over-limit verdict (`return 1 if slow else 0` for `--json`). Two runs seconds apart measured more than `--max-slowdown 5` apart on a shared runner. **What the case is actually for**, in its own comment: *"The committed numbers come from one machine; on another they would fail a run with no regression in it"* - it checks that a local baseline **replaces** the committed one, that `baseline_source` is that file, that the key sets match, and that no spurious regression is reported. The 5x limit was incidental to exercising the flag. **What the change is:** the `--max-slowdown 5` guard is **removed** from that one invocation - not raised - because `scripts/bench_translate.py` takes `--max-slowdown` with `default=None` and applies no limit at all when it is absent. The case keeps its intent (a local baseline replaces the committed one) without also measuring CPU contention. **It also drops `self.assertEqual(report["over_limit"], [])`**, which only held while the guard existed, and asserts instead that the report's `baseline` is the file the test just wrote. The over-limit behaviour keeps its own deterministic coverage: `--max-slowdown 0.01` must report one, asserted at line 48-51 against a synthetic baseline that cannot be noise. **Tested:** `python3 -m pytest tests/test_bench_translate.py -q` -> **10 passed, 5 subtests**, including the forced-regression case that still asserts a non-empty `over_limit`. **Not tested:** on macOS, which is the job this is for - I have Windows only. What I can say is that the change cannot make the plumbing assertions weaker (they are untouched) and that the timing assertion is the only one removed. If a maintainer would rather keep a performance threshold in this case, the alternative is to take the better of two written baselines, which is more code for the same purpose; I did not choose for you. ### The extra commit at the tip (no longer carried) **The branch used to carry `a3b5ebea1`** (`test(semantic): align computed-I/J f16 interp oracle…`), added only because `semantic-tests` was red on `main` for that oracle and every branch cut from `main` inherited it. **`main` now has the same edit as `c717967d0`**, so a rebase **drops the commit** and **this pull request no longer touches `tests/semantic/test_interp_computed_ij_fallback.py`** - the diff is only what this change actually needs. **AI-assisted:** yes - DeepSeek v4.1 (flash) as the coding agent, with a separate reviewer agent reading the change before submission. **Where and on what:** the measurements above were taken on Windows 11 with MSVC 19.44.35226 on an RTX 4090 (NVIDIA driver 621.24) where a C++ or GPU path is involved; Python and docs cases need none of it. Written with an AI assistant.
merzleckeier commented 2026-11-29 22:29:31 +00:00

I checked 2ec0571e (GitHub merge fe8b6003) against 452d1d1b on CachyOS with Python 3.14.10. The CLI for this case can omit --max-slowdown and check the saved numbers directly. I tested that change alongside the draft.

MEASURED. The full python3 -I tests/test_bench_translate.py -v run passed 10/10 in each tree. In a diagnostic replay I supplied the same recorded baseline to each tree and scaled only the second invocation's measured values. These are injected ratios.

Replay Base (5×) Draft (1000×) No limit in this case, compare saved values
8× 0/3 3/3 3/3
1024× 0/3 0/3 3/3

I also substituted the committed baseline values while leaving baseline_source set to the local file. The base and draft both passed that probe. The variant failed at dictionary equality, as intended.

The test-only change is to read json.load(handle)["measured"] from the file just written, run the second command with --baseline and --json without a limit, then check self.assertEqual(report["baseline"], written_measurements) alongside the existing path and key checks. The separate --max-slowdown tests still pass in both output formats and in --compare.

AI-assisted with OpenAI Codex.

I checked `2ec0571e` (GitHub merge `fe8b6003`) against `452d1d1b` on CachyOS with Python 3.14.10. The CLI for this case can omit `--max-slowdown` and check the saved numbers directly. I tested that change alongside the draft. **MEASURED.** The full `python3 -I tests/test_bench_translate.py -v` run passed 10/10 in each tree. In a diagnostic replay I supplied the same recorded baseline to each tree and scaled only the second invocation's measured values. These are injected ratios. | Replay | Base (5×) | Draft (1000×) | No limit in this case, compare saved values | | --- | ---: | ---: | ---: | | 8× | 0/3 | 3/3 | 3/3 | | 1024× | 0/3 | 0/3 | 3/3 | I also substituted the committed baseline values while leaving `baseline_source` set to the local file. The base and draft both passed that probe. The variant failed at dictionary equality, as intended. The test-only change is to read `json.load(handle)["measured"]` from the file just written, run the second command with `--baseline` and `--json` without a limit, then check `self.assertEqual(report["baseline"], written_measurements)` alongside the existing path and key checks. The separate `--max-slowdown` tests still pass in both output formats and in `--compare`. AI-assisted with OpenAI Codex.
fiestorra commented 2026-11-29 22:44:51 +00:00

Your replay data settled it, and I took your variant rather than mine.

What your table showed: a 1000x limit is still a timing threshold - at a 1024x slowdown it failed 0/3, while comparing the run's baseline back against the file it was handed passed 3/3 in every replay. A limit measures the runner; the numbers do not.

What the branch now does (8fc90097c):

with open(path, encoding="utf-8") as handle:
    written = json.load(handle)["measured"]
result = run("--runs", "1", "--size", "20", "--baseline", path, "--json")
self.assertEqual(result.returncode, 0, result.stderr)
report = json.loads(result.stdout)
self.assertEqual(report["baseline_source"], os.path.abspath(path))
self.assertEqual(sorted(report["baseline"]), sorted(report["measured"]))
# The baseline is that file's own numbers, not the committed ones: substituting the latter fails here.
self.assertEqual(report["baseline"], written)

No --max-slowdown on that invocation at all, so the case asserts the thing its name says - a local baseline replaces the committed one - and nothing about CPU contention.

Checked here, in the direction you checked it: python3 -m pytest tests/test_bench_translate.py -q -> 10 passed, 5 subtests; and your negative control reproduced - substituting a different baseline makes the case fail (1 failed), so the new assertion is load-bearing rather than decorative. The --max-slowdown 0.01 case still reports an over-limit as before.

Thank you for measuring the 1024x point instead of accepting the 1000x; that is the difference between a patch that hides the flake and one that removes it.

Written with an AI assistant.

Your replay data settled it, and I took your variant rather than mine. **What your table showed:** a 1000x limit is still a timing threshold - at a 1024x slowdown it failed 0/3, while comparing the run's baseline back against the file it was handed passed 3/3 in every replay. A limit measures the runner; the numbers do not. **What the branch now does (`8fc90097c`):** ```python with open(path, encoding="utf-8") as handle: written = json.load(handle)["measured"] result = run("--runs", "1", "--size", "20", "--baseline", path, "--json") self.assertEqual(result.returncode, 0, result.stderr) report = json.loads(result.stdout) self.assertEqual(report["baseline_source"], os.path.abspath(path)) self.assertEqual(sorted(report["baseline"]), sorted(report["measured"])) # The baseline is that file's own numbers, not the committed ones: substituting the latter fails here. self.assertEqual(report["baseline"], written) ``` No `--max-slowdown` on that invocation at all, so the case asserts the thing its name says - a local baseline **replaces** the committed one - and nothing about CPU contention. **Checked here, in the direction you checked it:** `python3 -m pytest tests/test_bench_translate.py -q` -> 10 passed, 5 subtests; and your negative control reproduced - substituting a different baseline makes the case **fail** (1 failed), so the new assertion is load-bearing rather than decorative. The `--max-slowdown 0.01` case still reports an over-limit as before. Thank you for measuring the 1024x point instead of accepting the 1000x; that is the difference between a patch that hides the flake and one that removes it. Written with an AI assistant.
fiestorra commented 2026-11-29 22:45:37 +00:00

Ready for review now, for two reasons that are not mine:

  • merzleckeier measured the approach against a 1024x slowdown (where a 1000x threshold still failed 0/3) and their variant passed 3/3, so the case no longer depends on the runner at all - what it asserts is that the second run used the file's own numbers;
  • rebased onto 452d1d1b6 with the interp commit (a3b5ebea1) that main is missing, so semantic-tests is not red for a reason this branch does not own. If #2633 merges first that commit becomes a duplicate and can be dropped.

python3 -m pytest tests/test_bench_translate.py tests/semantic/test_interp_computed_ij_fallback.py -q -> 19 passed, 18 subtests, and substituting a different baseline still fails the case (the assertion is load-bearing).

This is the last red standing between #2641 and a green board: macos-python is the only failing job on it.

Written with an AI assistant.

Ready for review now, for two reasons that are not mine: - merzleckeier measured the approach against a 1024x slowdown (where a 1000x threshold still failed 0/3) and their variant passed 3/3, so the case no longer depends on the runner at all - what it asserts is that the second run used the file's own numbers; - rebased onto `452d1d1b6` with the interp commit (`a3b5ebea1`) that `main` is missing, so `semantic-tests` is not red for a reason this branch does not own. If **#2633** merges first that commit becomes a duplicate and can be dropped. `python3 -m pytest tests/test_bench_translate.py tests/semantic/test_interp_computed_ij_fallback.py -q` -> **19 passed, 18 subtests**, and substituting a different baseline still fails the case (the assertion is load-bearing). This is the last red standing between #2641 and a green board: `macos-python` is the only failing job on it. Written with an AI assistant.
OreoFR commented 2026-11-29 23:03:42 +00:00

Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12.16, main 452d1d1b6, PR head 5faa965ca (test-only PR, so "red" = main's version of the tests, "green" = this PR's version, both on main's code). MEASURED:

  • tests/semantic/test_interp_computed_ij_fallback.py (pytest): main's version 2 failed / 9 (test_p1lv_f16_computed_ij_uses_interpolated_attribute_not_vsrc2, test_perspective_fixture_branch_and_f16_halves); this PR's version 9/9 passed, 13 subtests.
  • tests/test_bench_translate.py (python3 -I, 3 runs each, idle machine): main's version 10/10 OK ×3, this PR's version 10/10 OK ×3. The CPU-contention failure did not reproduce here, so this run neither confirms nor refutes the flake; it only shows the new assertion passes.

Note: #2566 makes the same SHADER-468 RTZ change to test_interp_computed_ij_fallback.py, and this PR conflicts with #2566 on that file (git merge-tree of main+this PR against #2566). Splitting the test_bench_translate.py half out would let it land on its own.

AI-assisted: Claude Code

Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12.16, main 452d1d1b6, PR head 5faa965ca (test-only PR, so "red" = main's version of the tests, "green" = this PR's version, both on main's code). MEASURED: - `tests/semantic/test_interp_computed_ij_fallback.py` (pytest): main's version **2 failed / 9** (`test_p1lv_f16_computed_ij_uses_interpolated_attribute_not_vsrc2`, `test_perspective_fixture_branch_and_f16_halves`); this PR's version **9/9 passed**, 13 subtests. - `tests/test_bench_translate.py` (`python3 -I`, 3 runs each, idle machine): main's version 10/10 OK ×3, this PR's version 10/10 OK ×3. The CPU-contention failure did not reproduce here, so this run neither confirms nor refutes the flake; it only shows the new assertion passes. Note: #2566 makes the same SHADER-468 RTZ change to `test_interp_computed_ij_fallback.py`, and this PR conflicts with #2566 on that file (`git merge-tree` of main+this PR against #2566). Splitting the `test_bench_translate.py` half out would let it land on its own. AI-assisted: Claude Code
OreoFR commented 2026-11-30 10:10:34 +00:00

Update by OreoFR: the conflict with #2566 I reported here is gone. main (1b0f657f3) now carries the SHADER-468 change to tests/semantic/test_interp_computed_ij_fallback.py (71db4c405), and this PR merges cleanly both with main and on top of main + #2566 (git merge-tree, checked 2026-11-30 11:10 local). Note also that my earlier check merged this PR with main first and then compared against #2566's head, which can report a conflict through an older merge base; I now check main + #2566 first, then the PR.

AI-assisted: Claude Code

Update by OreoFR: **the conflict with #2566 I reported here is gone.** `main` (1b0f657f3) now carries the SHADER-468 change to `tests/semantic/test_interp_computed_ij_fallback.py` (`71db4c405`), and this PR merges cleanly both with `main` and on top of `main` + #2566 (`git merge-tree`, checked 2026-11-30 11:10 local). Note also that my earlier check merged this PR with `main` first and then compared against #2566's head, which can report a conflict through an older merge base; I now check `main` + #2566 first, then the PR. AI-assisted: Claude Code
fiestorra commented 2026-11-30 14:00:15 +00:00

Re-verified after the rebase onto main 20fe0c754, on this machine (Windows 11, MSVC 19.44.35226): the diff no longer carries the interp-oracle commit (main has it as c717967d0), and what is left still passes.

python3 -m pytest tests/test_bench_translate.py -q
10 passed, 5 subtests passed in 10.70s

What I did not test: the rest of the change, and anything the rebase did not touch. This confirms the rebase kept the change working, not that the change is correct - that is what the review and the CI are for.

Written with an AI assistant.

**Re-verified after the rebase onto `main` `20fe0c754`, on this machine (Windows 11, MSVC 19.44.35226):** the diff no longer carries the interp-oracle commit (`main` has it as `c717967d0`), and what is left still passes. ``` python3 -m pytest tests/test_bench_translate.py -q 10 passed, 5 subtests passed in 10.70s ``` **What I did not test:** the rest of the change, and anything the rebase did not touch. **This confirms the rebase kept the change working, not that the change is correct** - that is what the review and the CI are for. Written with an AI assistant.
aslan2142 approved these changes 2026-12-01 11:29:19 +00:00
aslan2142 left a comment

LGTM. Comparing report["baseline"] directly against the written baseline file's measured dict in tests/test_bench_translate.py removes the CPU-contention flakiness while testing local baseline override deterministically. Clean-room verified, 5/5 CI green, and independently verified. Merging.

(AI-assisted review.)

LGTM. Comparing `report["baseline"]` directly against the written baseline file's `measured` dict in `tests/test_bench_translate.py` removes the CPU-contention flakiness while testing local baseline override deterministically. Clean-room verified, 5/5 CI green, and independently verified. Merging. *(AI-assisted review.)*
Sign in to join this conversation.
No description provided.