WIP: perf(vk): a network an earlier session left out is left out again without its translation (RX_VK_REMEMBER_LEFT_OUT) #2823

Draft
Simaude wants to merge 1 commit from Simaude/Longshot:pr/networks-left-out-remembered into main
First-time contributor

Summary

On a card that runs cooperative-matrix multiplies in software (networks_left_out: every vendor but NVIDIA, and NVIDIA before Turing), translate_into leaves the upscale networks out with a network left out on this card. A failure is kept nowhere, so every session translated each of them whole at its first dispatch, on the replay thread, only to leave it out again: 11 of them on a GTX 1070 (Pascal), 2-60 ms each, ~200 ms a session, most during the opening movie and one on the way into Hyrule Field.

Their keys now go to longshot_networks_left_out.txt beside the program cache, under the program cache's stamp (the translator, the device's translation settings and policy, and the RX_VK_NETWORK* / RX_VK_NO_F16 switches it takes) and the device's f16 support. program_pick leaves a listed compute program out at once, failed and ready, as its translation would end; nothing else changes (the dispatch takes the same upscale_stub route by the code's key). A list made under another stamp is not read, and is replaced at the next left-out network. The shader preparation fills the list at the build (71 networks on this card), so even a first session in play skips them.

  • gpu/vk/vk_shader.cpp: left_out_known / left_out_note, the check in program_pick before miss_note, the note in translate_into's catch (not for an answer seed_compute only tries).
  • gpu/vk/switches.def: RX_VK_REMEMBER_LEFT_OUT=0 turns it off (named off the RX_VK_NETWORK prefix, which the translator's stamp takes: setting it would drop the program cache).
  • Tests: tests/test_networks_left_out_remembered.py (new; fails on main), tests/test_not_translated_counts.py (its fixture now counts the notes: the 69 networks, not the trial nor the other failures).

Testing

Tested: Windows 11 23H2 (22631), NVIDIA GeForce GTX 1070, driver 582.78, i7-9700K, 32 GB, 1920x1080, Compile shaders: All, RX_VK_LOAD=start, RX_VK_SLOW_DISPATCH=1. One build of this branch; four interleaved pairs, RX_VK_REMEMBER_LEFT_OUT=0 against unset, each run a fresh profile from the repository's castle-gate save through the title and over the drawbridge into Hyrule Field (driven by scripts/longshot_ctl.py), 0 crashes.

  • longshot_networks_left_out.txt written by the preparation: 71 keys; every run with the list says 71 networks left out in an earlier session.
  • The full-size network's typed fallback (drawn by the typed fallback) and the movie's linear upscale are taken in every run, both ways.
  • Rebased onto main @ e4801d6a (head 8a24b9c8) and run again, one run each way: 0 against 11 networks translated, 71 networks left out in an earlier session, and the same stand-in lines both ways (movie upscaling uses the linear compute path, typed upscale helper generic RGB9E5 fallback, the same 11 rejected compute dispatches), 0 crashes.
  • Game-free: the two tests above pass; python -I -B tests/run_all.py --changed origin/main: everything this touches passes; test_switch_table (LONGSHOT_LAUNCHER_STARTUP, from #2683), test_dev_ab and test_input_movie fail the same on main on Windows.

Still to test:

  • An AMD card and an Intel card on Windows (most networks are left out there): the same two lines and the list's count (@Beanstalk).
  • A driver update between two sessions: the list is dropped with the program cache's stamp (by hand).

Measurements

Verdict: ~185 ms of replay-thread translation gone from every session on a card that leaves the networks out, most of it from the opening movie; frame times in play unchanged (the one network met in play cost 13 ms).

per run (4 pairs, GTX 1070) Before: main @ 22d0d200 (RX_VK_REMEMBER_LEFT_OUT=0) After: this PR @ 216eafcb (rebased as 8a24b9c8)
networks translated and left out 11 / 11 / 11 / 11 0 / 0 / 0 / 0
slow dispatches of a left-out program (RX_VK_SLOW_DISPATCH), in all 197 / 206 / 198 / 196 ms 46 / 13 / 10 / 13 ms

The numbers still hold on main @ e4801d6a: none of the 34 commits since touches the translation or the program cache, and one pair there gave the same 11 against 0 networks translated.

Risks

  • A key listed wrongly would leave a network out that could run: the list is only ever written from the translation's own network_left_out verdict, and it is dropped whenever the program cache's stamp changes (translator, policy, the network switches, f16 support).
  • The file is small (one line per network); written whole under a mutex when a new key is noted.
  • Turn off: RX_VK_REMEMBER_LEFT_OUT=0.

Checklist

Ready for review

  • One topic, on current main. The title is a Conventional Commit.
  • Tested on my own PC, in the game, as Testing says.
  • mise run test passes: the changed-file checks pass; three failures are pre-existing on main on Windows (named above).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths: built and run on Windows (llvm-mingw); Linux left to CI.
  • AI assistance recorded with an Assisted-by: trailer.

Assisted-by: Claude Opus 5.5

## Summary On a card that runs cooperative-matrix multiplies in software (`networks_left_out`: every vendor but NVIDIA, and NVIDIA before Turing), `translate_into` leaves the upscale networks out with `a network left out on this card`. A failure is kept nowhere, so every session translated each of them whole at its first dispatch, on the replay thread, only to leave it out again: 11 of them on a GTX 1070 (Pascal), 2-60 ms each, ~200 ms a session, most during the opening movie and one on the way into Hyrule Field. Their keys now go to `longshot_networks_left_out.txt` beside the program cache, under the program cache's stamp (the translator, the device's translation settings and policy, and the `RX_VK_NETWORK*` / `RX_VK_NO_F16` switches it takes) and the device's f16 support. `program_pick` leaves a listed compute program out at once, failed and ready, as its translation would end; nothing else changes (the dispatch takes the same `upscale_stub` route by the code's key). A list made under another stamp is not read, and is replaced at the next left-out network. The shader preparation fills the list at the build (71 networks on this card), so even a first session in play skips them. - `gpu/vk/vk_shader.cpp`: `left_out_known` / `left_out_note`, the check in `program_pick` before `miss_note`, the note in `translate_into`'s catch (not for an answer `seed_compute` only tries). - `gpu/vk/switches.def`: `RX_VK_REMEMBER_LEFT_OUT=0` turns it off (named off the `RX_VK_NETWORK` prefix, which the translator's stamp takes: setting it would drop the program cache). - Tests: `tests/test_networks_left_out_remembered.py` (new; fails on `main`), `tests/test_not_translated_counts.py` (its fixture now counts the notes: the 69 networks, not the trial nor the other failures). ## Testing **Tested:** Windows 11 23H2 (22631), NVIDIA GeForce GTX 1070, driver 582.78, i7-9700K, 32 GB, 1920x1080, Compile shaders: All, `RX_VK_LOAD=start`, `RX_VK_SLOW_DISPATCH=1`. One build of this branch; four interleaved pairs, `RX_VK_REMEMBER_LEFT_OUT=0` against unset, each run a fresh profile from the repository's `castle-gate` save through the title and over the drawbridge into Hyrule Field (driven by `scripts/longshot_ctl.py`), 0 crashes. - `longshot_networks_left_out.txt` written by the preparation: 71 keys; every run with the list says `71 networks left out in an earlier session`. - The full-size network's typed fallback (`drawn by the typed fallback`) and the movie's linear upscale are taken in every run, both ways. - Rebased onto `main @ e4801d6a` (head `8a24b9c8`) and run again, one run each way: 0 against 11 networks translated, `71 networks left out in an earlier session`, and the same stand-in lines both ways (`movie upscaling uses the linear compute path`, `typed upscale helper generic RGB9E5 fallback`, the same 11 `rejected compute` dispatches), 0 crashes. - Game-free: the two tests above pass; `python -I -B tests/run_all.py --changed origin/main`: everything this touches passes; `test_switch_table` (`LONGSHOT_LAUNCHER_STARTUP`, from #2683), `test_dev_ab` and `test_input_movie` fail the same on `main` on Windows. **Still to test:** - An AMD card and an Intel card on Windows (most networks are left out there): the same two lines and the list's count (@Beanstalk). - A driver update between two sessions: the list is dropped with the program cache's stamp (by hand). ## Measurements **Verdict:** ~185 ms of replay-thread translation gone from every session on a card that leaves the networks out, most of it from the opening movie; frame times in play unchanged (the one network met in play cost 13 ms). | per run (4 pairs, GTX 1070) | Before: main @ 22d0d200 (`RX_VK_REMEMBER_LEFT_OUT=0`) | After: this PR @ 216eafcb (rebased as 8a24b9c8) | |---|---:|---:| | networks translated and left out | 11 / 11 / 11 / 11 | **0 / 0 / 0 / 0** | | slow dispatches of a left-out program (`RX_VK_SLOW_DISPATCH`), in all | 197 / 206 / 198 / 196 ms | **46 / 13 / 10 / 13 ms** | The numbers still hold on `main @ e4801d6a`: none of the 34 commits since touches the translation or the program cache, and one pair there gave the same 11 against 0 networks translated. ## Risks - A key listed wrongly would leave a network out that could run: the list is only ever written from the translation's own `network_left_out` verdict, and it is dropped whenever the program cache's stamp changes (translator, policy, the network switches, f16 support). - The file is small (one line per network); written whole under a mutex when a new key is noted. - Turn off: `RX_VK_REMEMBER_LEFT_OUT=0`. ## Checklist ### Ready for review - [x] One topic, on current `main`. The title is a Conventional Commit. - [x] Tested on my own PC, in the game, as Testing says. - [ ] `mise run test` passes: the changed-file checks pass; three failures are pre-existing on `main` on Windows (named above). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths: built and run on Windows (llvm-mingw); Linux left to CI. - [x] AI assistance recorded with an `Assisted-by:` trailer. Assisted-by: Claude Opus 5.5
perf(vk): a network an earlier session left out is left out again without its translation (RX_VK_REMEMBER_LEFT_OUT)
Some checks are pending
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 7s
8a24b9c8cc
On a card that runs cooperative-matrix multiplies in software, translate_into leaves the upscale networks out, and a
failure is kept nowhere: every session translated each of them whole at its first dispatch, on the replay thread, only to
leave it out again (11 on a GTX 1070, 2-60 ms each, ~200 ms a session, most during the opening movie). Their keys now go
to longshot_networks_left_out.txt beside the program cache, under the program cache's stamp and the device's f16 support,
and program_pick leaves a listed compute program out at once, failed and ready, as its translation would end.
RX_VK_REMEMBER_LEFT_OUT=0 turns it off.

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
First-time contributor

Tested in game: Windows 11 23H2, NVIDIA GeForce GTX 1070 (Pascal), driver 582.78: castle-gate save through the title and into Hyrule Field, RX_VK_REMEMBER_LEFT_OUT=0 against unset (4 pairs on Friday's main, one pair again on main @ e4801d6a): 11 networks translated and left out against 0, ~185 ms less replay-thread translation a session, the same stand-in lines both ways, no crash.

Tested in game: Windows 11 23H2, NVIDIA GeForce GTX 1070 (Pascal), driver 582.78: castle-gate save through the title and into Hyrule Field, RX_VK_REMEMBER_LEFT_OUT=0 against unset (4 pairs on Friday's main, one pair again on main @ e4801d6a): 11 networks translated and left out against 0, ~185 ms less replay-thread translation a session, the same stand-in lines both ways, no crash.
Member

Possibly related, for context:

  • PR #2144 WIP: fix(vk): the program cache's stamp holds only the switches the translation reads, in name order — Open Vulkan cache-stamp change may overlap stamp inputs
Possibly related, for context: - PR #2144 WIP: fix(vk): the program cache's stamp holds only the switches the translation reads, in name order — Open Vulkan cache-stamp change may overlap stamp inputs
Some checks are pending
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 7s
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/networks-left-out-remembered:Simaude-pr/networks-left-out-remembered'
git switch 'Simaude-pr/networks-left-out-remembered'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2823
No description provided.