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

Closed
aznohonza wants to merge 0 commits from upstream-pr/2959 into main
aznohonza commented 2026-12-01 21:35:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T21:35:27Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5594980881 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2959). Originally posted by [aznohonza](https://github.com/aznohonza) on 2026-12-01T21:35:27Z. --- `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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-01T21:39:44Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7326597245 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2959#issuecomment-7326597245). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-01T21:39:44Z. --- 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 commented 2026-12-01 21:42:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T21:42:43Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6140677699 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2959#pullrequestreview-6140677699). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T21:42:43Z. **Review:** COMMENTED --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T21:46:00Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7326750318 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2959#issuecomment-7326750318). Originally posted by [aznohonza](https://github.com/aznohonza) on 2026-12-01T21:46:00Z. --- 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.

Pull request closed

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!2959
No description provided.