tools/d3d12_ab_compare: skip incomplete block pairs in phase_effects (TOOLS-AB-COMPARE-INCOMPLETE-BLOCKS) #3471

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u  "tools/ab-compare-incomplete-blocks:und3rlake-tools/ab-compare-incomplete-blocks"
git switch "und3rlake-tools/ab-compare-incomplete-blocks"
Open
leonida/mandy
und3rlake wants to merge 1 commit from und3rlake/mandy:tools/ab-compare-incomplete-blocks into main

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
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 'tools/ab-compare-incomplete-blocks:und3rlake-tools/ab-compare-incomplete-blocks'
git switch 'und3rlake-tools/ab-compare-incomplete-blocks'
First-time contributor

Summary

Implements TOOLS-AB-COMPARE-INCOMPLETE-BLOCKS (claimed in #3312):

In tools/d3d12_ab_compare.py phase_effects, each block of switch s has size 2^s so that every (off, on) pair averages over all 2^s lower-switch combinations. Previously, when a multi-switch LEONIDA_AB run stopped mid-block (or dropped a phase inside a block), phase_effects still paired blocks[j] and blocks[j + 1] even when len(off) != size or len(on) != size, confounding lower-switch effects into switch s (for example, on 11 phases with s0 = -4.0 ms and s1 = 0.0 ms, s1 previously reported +0.667 ms across 3 pairs instead of 0.000 ms across 2 complete pairs).

Changes

  • tools/d3d12_ab_compare.py:
    • Check len(off) != size or len(on) != size before the draw-jump filter and skip incomplete pairs.
    • Add "left_out_incomplete" to each switch entry in the returned JSON (additive, backwards-compatible).
    • Display ", N left out incomplete" in render_phases only when left_out_incomplete > 0 (output unchanged when 0).
  • tests/test_d3d12_ab_compare.py:
    • Add test_an_incomplete_block_pair_is_left_out_for_higher_switches (reproducing the mid-block stop confounding case and verifying render_phases).
    • Add test_a_missing_phase_inside_off_block_leaves_that_pair_out.

Verification (Windows 11)

  • python -m unittest discover -s tests -p test_d3d12_ab_compare.py — 28/28 PASS (reproduced red → green)
  • python -m unittest discover -s tests -p test_game_abba.py — PASS (4 passed, 19 skipped)
  • python -m unittest discover -s tests -p test_docs_cli_flags.py — 4/4 PASS
  • python -m unittest discover -s tests -p test_tool_stdout_encoding.py — 4/4 PASS
  • python -m unittest discover -s tests -p test_text_write_line_endings.py — 3/3 PASS
  • python -I scripts/check_no_game_data.py — PASS
  • Independent read-only code review completed (APPROVE).

AI-assisted: yes

### Summary Implements `TOOLS-AB-COMPARE-INCOMPLETE-BLOCKS` (claimed in #3312): In `tools/d3d12_ab_compare.py` `phase_effects`, each block of switch `s` has size `2^s` so that every `(off, on)` pair averages over all `2^s` lower-switch combinations. Previously, when a multi-switch `LEONIDA_AB` run stopped mid-block (or dropped a phase inside a block), `phase_effects` still paired `blocks[j]` and `blocks[j + 1]` even when `len(off) != size` or `len(on) != size`, confounding lower-switch effects into switch `s` (for example, on 11 phases with `s0 = -4.0 ms` and `s1 = 0.0 ms`, `s1` previously reported `+0.667 ms` across 3 pairs instead of `0.000 ms` across 2 complete pairs). ### Changes - `tools/d3d12_ab_compare.py`: - Check `len(off) != size or len(on) != size` before the draw-jump filter and skip incomplete pairs. - Add `"left_out_incomplete"` to each switch entry in the returned JSON (additive, backwards-compatible). - Display `", N left out incomplete"` in `render_phases` only when `left_out_incomplete > 0` (output unchanged when `0`). - `tests/test_d3d12_ab_compare.py`: - Add `test_an_incomplete_block_pair_is_left_out_for_higher_switches` (reproducing the mid-block stop confounding case and verifying `render_phases`). - Add `test_a_missing_phase_inside_off_block_leaves_that_pair_out`. ### Verification (Windows 11) - `python -m unittest discover -s tests -p test_d3d12_ab_compare.py` — `28/28` PASS (reproduced red → green) - `python -m unittest discover -s tests -p test_game_abba.py` — PASS (`4` passed, `19` skipped) - `python -m unittest discover -s tests -p test_docs_cli_flags.py` — `4/4` PASS - `python -m unittest discover -s tests -p test_tool_stdout_encoding.py` — `4/4` PASS - `python -m unittest discover -s tests -p test_text_write_line_endings.py` — `3/3` PASS - `python -I scripts/check_no_game_data.py` — PASS - Independent read-only code review completed (`APPROVE`). AI-assisted: yes
For switch s (block size 2^s), pairing an off/on block pair where either block
holds fewer than 2^s phases compares unequal subsets of the lower switches and
confounds their effects into switch s. Skip any candidate pair with
len(off) != size or len(on) != size before the draw-jump check, record the
skipped count in left_out_incomplete, show it in render_phases when non-zero,
and add regression tests.

AI-assisted: yes
First-time contributor

Independent local verification of this change (I changed no code).

  • Head ce94ab4, merge base 30c6830. Both new tests are absent on the base: git grep -F <test> 30c6830 -- tests/test_d3d12_ab_compare.py -> exit 1 for each.
  • On the PR head, with module-qualified names and --exact: python -m unittest tests.test_d3d12_ab_compare.Phases.test_an_incomplete_block_pair_is_left_out_for_higher_switches and ...test_a_missing_phase_inside_off_block_leaves_that_pair_out -> both OK; the whole module python -m unittest tests.test_d3d12_ab_compare -> 28 tests OK.
  • Red/green: with the PR's test file placed on the untouched merge base, both cases fail with KeyError: 'left_out_incomplete', so the tool change is required.
  • git diff --check 30c6830 ce94ab4 -> clean. python -I scripts/check_no_game_data.py tools/d3d12_ab_compare.py tests/test_d3d12_ab_compare.py -> clean.

GPUs tested: none (pure Python on synthetic phase dictionaries, no device-gated test). Driver: n/a. No game data, assets or extracted shaders were used or attached.

AI-assisted: yes, Hy4 flash (verification only). No approval implied; this is a local test report.

Independent local verification of this change (I changed no code). - Head `ce94ab4`, merge base `30c6830`. Both new tests are absent on the base: `git grep -F <test> 30c6830 -- tests/test_d3d12_ab_compare.py` -> exit 1 for each. - On the PR head, with module-qualified names and `--exact`: `python -m unittest tests.test_d3d12_ab_compare.Phases.test_an_incomplete_block_pair_is_left_out_for_higher_switches` and `...test_a_missing_phase_inside_off_block_leaves_that_pair_out` -> both OK; the whole module `python -m unittest tests.test_d3d12_ab_compare` -> 28 tests OK. - Red/green: with the PR's test file placed on the untouched merge base, both cases fail with `KeyError: 'left_out_incomplete'`, so the tool change is required. - `git diff --check 30c6830 ce94ab4` -> clean. `python -I scripts/check_no_game_data.py tools/d3d12_ab_compare.py tests/test_d3d12_ab_compare.py` -> clean. GPUs tested: none (pure Python on synthetic phase dictionaries, no device-gated test). Driver: n/a. No game data, assets or extracted shaders were used or attached. AI-assisted: yes, Hy4 flash (verification only). No approval implied; this is a local test report.
Contributor

I checked ce94ab467 with 12 planned synthetic phases. Phase n has bits n & 3, median 30 - 4 * (n & 1) ms, and 4,000 draws per frame. By construction the higher switch has zero effect.

Logged phases Higher switch pairs left_out_incomplete Estimated effect
12 3 0 0 ms
11 2 1 0 ms
10 2 0 0 ms

At 10 phases the entire final on-block is absent. Both complete pairs are still usable, and the counter reflects the pairs whose two blocks appeared. A consumer that needs to establish coverage for the whole run can compare the observed phase IDs to the planned sequence. The 28 comparator tests also passed. PR #3471

I checked `ce94ab467` with 12 planned synthetic phases. Phase `n` has bits `n & 3`, median `30 - 4 * (n & 1)` ms, and 4,000 draws per frame. By construction the higher switch has zero effect. | Logged phases | Higher switch pairs | `left_out_incomplete` | Estimated effect | |---:|---:|---:|---:| | 12 | 3 | 0 | 0 ms | | 11 | 2 | 1 | 0 ms | | 10 | 2 | 0 | 0 ms | At 10 phases the entire final on-block is absent. Both complete pairs are still usable, and the counter reflects the pairs whose two blocks appeared. A consumer that needs to establish coverage for the whole run can compare the observed phase IDs to the planned sequence. The 28 comparator tests also passed. [PR #3471](https://git.leonida.now/leonida/mandy/pulls/3471)
Sign in to join this conversation.
No description provided.