shader/opt: the visit-budget test uses 5 phi levels, where the budget decides (D3D12-SHADER-BOUNDED-BUDGET-TEST) #2959

Closed
leonida/mandy
aznohonza wants to merge 0 commits from shader/bounded-budget-test into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

aznohonza commented 2026-12-01 21:35:27 +00:00

bounded_budget_caps_wide_phi_dag is named for the 64-visit budget in Module::bounded(), but it built 10 levels of a 4-way phi DAG. At 10 levels the depth limit answers None after 12 visits, before the budget is reached: taking the budget away (let mut budget = u32::MAX) left the test passing, so it did not test what it says.

Five levels needs 2,729 visits without the budget, so there the budget is what answers None. The test now builds 5 levels, and its comment says why the depth limit no longer decides first.

Verification (Linux, no GPU, no game files):

  • cargo test -p leonida-shader --features host: 250 passed, 2 ignored, 0 failed.
  • Discrimination: with let mut budget = u32::MAX, the 5-level test fails (assertion left == right failed: left: Some(0.0), right: None), while the same test at 10 levels still passes — the gap this closes.
  • The visit figures (64 with the budget, 2,729 without at 5 levels, 12 at 10 levels on the depth limit) come from the finding on the merged #2861, measured the same way.

Test-only: no translator output, no switch, no game data.

Claimed in #2570 (D3D12-SHADER-BOUNDED-BUDGET-TEST). AI-assisted.

`bounded_budget_caps_wide_phi_dag` is named for the 64-visit budget in `Module::bounded()`, but it built 10 levels of a 4-way phi DAG. At 10 levels the depth limit answers `None` after 12 visits, before the budget is reached: taking the budget away (`let mut budget = u32::MAX`) left the test passing, so it did not test what it says. Five levels needs 2,729 visits without the budget, so there the budget is what answers `None`. The test now builds 5 levels, and its comment says why the depth limit no longer decides first. **Verification** (Linux, no GPU, no game files): - `cargo test -p leonida-shader --features host`: 250 passed, 2 ignored, 0 failed. - Discrimination: with `let mut budget = u32::MAX`, the 5-level test fails (`assertion left == right failed: left: Some(0.0), right: None`), while the same test at 10 levels still passes — the gap this closes. - The visit figures (64 with the budget, 2,729 without at 5 levels, 12 at 10 levels on the depth limit) come from the finding on the merged #2861, measured the same way. Test-only: no translator output, no switch, no game data. Claimed in #2570 (`D3D12-SHADER-BOUNDED-BUDGET-TEST`). AI-assisted.
andrew-ai commented 2026-12-01 21:39:44 +00:00

Reproduced on Windows at 535c14094 and its parent 1fff69129. I instrumented the existing wide-DAG test locally to count visits with depth fixed at 12.

Fixture Starting budget Visits used Result
Parent, 10 levels 64 or u32::MAX 12 None
PR, 5 levels 64 64 None
PR, 5 levels 2,728 2,728 None
PR, 5 levels 2,729 or higher 2,729 Some(0.0)

The new fixture isolates the visit cap. Removing the cap would break the assertion on the PR, while the parent would still pass. The focused host-feature test passed on both revisions with their production budget. Verified with Codex assistance for #2570.

Reproduced on Windows at 535c14094 and its parent 1fff69129. I instrumented the existing wide-DAG test locally to count visits with depth fixed at 12. | Fixture | Starting budget | Visits used | Result | | --- | ---: | ---: | --- | | Parent, 10 levels | 64 or u32::MAX | 12 | None | | PR, 5 levels | 64 | 64 | None | | PR, 5 levels | 2,728 | 2,728 | None | | PR, 5 levels | 2,729 or higher | 2,729 | Some(0.0) | The new fixture isolates the visit cap. Removing the cap would break the assertion on the PR, while the parent would still pass. The focused host-feature test passed on both revisions with their production budget. Verified with Codex assistance for #2570.
KelboLive reviewed 2026-12-01 21:42:43 +00:00
KelboLive left a comment
No description provided.
Verified the arithmetic: with the zero-identity `Sub` at `opt.rs:491-495`, each level costs `1 Phi + 4×(1 Sub + previous)` from `V0=1` — 9 → 41 → 169 → 681 → **2,729** visits — and at 5 levels the depth (11) never reaches the `depth = 12` limit, so the 64 budget is what answers `None`. The test is deterministic (fixed loop counts, `Vec` order, dedup by value). The mutations agree: removing the budget or raising it to 2,729 fails with `left: Some(0.0), right: None`, while 2,728 still passes — so the wide DAG is pinned at exactly 2,729 visits. Non-blocking: the wide assertion only reacts **upward**; any budget from 13 to 2,728 still passes, and below 13 the small-diamond sub-test at `opt.rs:3221` fails first, not the wide DAG. If you want the low side pinned too, a budget assertion on the small test would do it. Test-only, clean against the merged #2861, and merge-tree is clean. Good to merge.
aznohonza commented 2026-12-01 21:46:00 +00:00

Thanks — that is the boundary I did not measure: the test pins "over the cap", not the exact edge. 2,728 visits do not fit and 2,729 do, and your parent row (12 visits, None with either budget) is exactly the gap this closes.

AI-assisted.

Thanks — that is the boundary I did not measure: the test pins "over the cap", not the exact edge. 2,728 visits do not fit and 2,729 do, and your parent row (12 visits, `None` with either budget) is exactly the gap this closes. AI-assisted.
Sign in to join this conversation.
No description provided.