D3D12-WARM-AMD-SINGLE-PROCESS: default leonida warm to one process on AMD #2830

Closed
bobcatchris wants to merge 1 commit from upstream-pr/2830 into main
bobcatchris commented 2026-12-01 04:14:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T04:14:02Z.


Claim: D3D12-WARM-AMD-SINGLE-PROCESS (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7300449615).

What and why

leonida warm defaulted to two thirds of the logical cores. On an RX 7900 XTX that starts ten amdxc64.dll compiler processes; the driver silently refuses most PSOs and ends some processes with 0xc0000005. The same machine warmed 1,845 of 1,845 used pipelines with --jobs 1 and zero crashes, leaving warm-bad.txt empty.

This changes the default to one process when the DXGI adapter reports vendor 0x1002. --jobs still wins when passed explicitly, so the old behaviour remains available for A/B. Every other vendor keeps two thirds of the logical cores.

The vendor is queried through DXGI without creating a device, and LEONIDA_ADAPTER is honoured the same way the host device honours it. Two unit tests pin the pure default helper for AMD, another vendor and an unknown adapter.

No rendering or visual setting changes: this only chooses how many compiler processes warm uses before a run.

Verification (offline, no game files)

cargo test --locked -p leonida --bin leonida warm::tests
  test warm::tests::amd_compiles_one_pipeline_at_a_time ... ok
  test warm::tests::other_vendors_keep_two_thirds_of_the_cores ... ok
  test result: ok. 2 passed; 0 failed

cargo clippy --locked -p leonida --bin leonida   # no new warnings from this diff
python -I scripts/check_no_game_data.py <the four changed files>  # clean
git diff --check                                 # clean

The two leonida clippy warnings (player.rs:570 and the pre-existing count % 1000 in warm.rs) are on main before this change.

Hardware

Measured on AMD Ryzen 7 7800X3D, Radeon RX 7900 XTX (24 GB, driver 32.0.32029.2010), Windows 11. The compiler fault and the single-process warm are from the reporter's 48-minute log; this pull request changes only the default and was verified with the tests above, not by launching the game.

No game data, archives, shaders, textures or logs are in this change.

AI-assisted: yes.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5578865322 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2830). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T04:14:02Z. --- Claim: `D3D12-WARM-AMD-SINGLE-PROCESS` (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7300449615). ## What and why `leonida warm` defaulted to two thirds of the logical cores. On an RX 7900 XTX that starts ten `amdxc64.dll` compiler processes; the driver silently refuses most PSOs and ends some processes with `0xc0000005`. The same machine warmed 1,845 of 1,845 used pipelines with `--jobs 1` and zero crashes, leaving `warm-bad.txt` empty. This changes the default to one process when the DXGI adapter reports vendor `0x1002`. `--jobs` still wins when passed explicitly, so the old behaviour remains available for A/B. Every other vendor keeps two thirds of the logical cores. The vendor is queried through DXGI without creating a device, and `LEONIDA_ADAPTER` is honoured the same way the host device honours it. Two unit tests pin the pure default helper for AMD, another vendor and an unknown adapter. No rendering or visual setting changes: this only chooses how many compiler processes warm uses before a run. ## Verification (offline, no game files) ``` cargo test --locked -p leonida --bin leonida warm::tests test warm::tests::amd_compiles_one_pipeline_at_a_time ... ok test warm::tests::other_vendors_keep_two_thirds_of_the_cores ... ok test result: ok. 2 passed; 0 failed cargo clippy --locked -p leonida --bin leonida # no new warnings from this diff python -I scripts/check_no_game_data.py <the four changed files> # clean git diff --check # clean ``` The two `leonida` clippy warnings (`player.rs:570` and the pre-existing `count % 1000` in `warm.rs`) are on `main` before this change. ## Hardware Measured on AMD Ryzen 7 7800X3D, Radeon RX 7900 XTX (24 GB, driver 32.0.32029.2010), Windows 11. The compiler fault and the single-process warm are from the reporter's 48-minute log; this pull request changes only the default and was verified with the tests above, not by launching the game. No game data, archives, shaders, textures or logs are in this change. AI-assisted: yes.
ecox982745 commented 2026-12-01 04:22:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-12-01T04:22:17Z.


Independent Windows CLI verification. Head c6fc64b05 merged cleanly into 86c30fcea (tree 556ef0ca1). I built it on Windows 11 with Rust 1.98.1/MSVC. For this CPU-only probe I stubbed adapter detection and the driver fingerprint in a scratch build and made any attempt to create the D3D12 host fail the fixture. The warm argument parser and job-selection path were unchanged.

Each invocation used warm --limit 0 with its own empty synthetic pipeline store. The two existing warm::tests also passed in this build.

Invocation Selected jobs in CLI output Vendor lookups
Default, AMD stub 1 1
Default, NVIDIA stub 10 1
Default, no adapter stub 10 1
Explicit --jobs 7 7 0
Explicit --jobs 0 1 0

The NVIDIA and no-adapter defaults used 16 logical cores. Both explicit cases were configured to fail if the new vendor lookup was called. All five invocations exited successfully with zero pipelines to compile. Actual DXGI selection and AMD compiler stability remain hardware checks.

AI-assisted with OpenAI Codex (GPT-6.2 Sol).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7300665956 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2830#issuecomment-7300665956). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-12-01T04:22:17Z. --- Independent Windows CLI verification. Head `c6fc64b05` merged cleanly into `86c30fcea` (tree `556ef0ca1`). I built it on Windows 11 with Rust 1.98.1/MSVC. For this CPU-only probe I stubbed adapter detection and the driver fingerprint in a scratch build and made any attempt to create the D3D12 host fail the fixture. The `warm` argument parser and job-selection path were unchanged. Each invocation used `warm --limit 0` with its own empty synthetic pipeline store. The two existing `warm::tests` also passed in this build. | Invocation | Selected jobs in CLI output | Vendor lookups | | --- | ---: | ---: | | Default, AMD stub | 1 | 1 | | Default, NVIDIA stub | 10 | 1 | | Default, no adapter stub | 10 | 1 | | Explicit `--jobs 7` | 7 | 0 | | Explicit `--jobs 0` | 1 | 0 | The NVIDIA and no-adapter defaults used 16 logical cores. Both explicit cases were configured to fail if the new vendor lookup was called. All five invocations exited successfully with zero pipelines to compile. Actual DXGI selection and AMD compiler stability remain hardware checks. AI-assisted with OpenAI Codex (GPT-6.2 Sol).
KelboLive commented 2026-12-01 06:03:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T06:03:23Z.

Review: COMMENTED


On this NVIDIA box the new path is inert, which is the first thing to want: adapter_vendor_id() returns 0x10de and default_jobs(Some(0x10de), 32) is 21 (two thirds of 32) — the same as before — while --jobs still wins and never queries DXGI when passed. warm::tests is 2/2, flipping the vendor comparison fails both, and d3d12_switches.py --check, check_no_game_data and git diff --check are clean. Shaders' "every logical core" and LEONIDA_PIPELINE_WORKERS are untouched, so the shader-translation process count does not change — only how many warm processes run.

The risk I would write down, because I could not observe AMD here: the helper takes the first non-software EnumAdapters1 adapter (host.rs:1431), while create passes NULL to D3D12CreateDevice and lets Windows choose. On an Intel-iGPU + AMD-dGPU hybrid those can disagree — an OS per-app preference, or the iGPU enumerated first — and then warm picks two thirds of the cores while the runtime device is AMD, which is exactly the compiler-concurrency problem this default exists to avoid. LEONIDA_ADAPTER is the only way to align them today; the DXGI selection has no test (only default_jobs does). A sentence in the doc/comment about LEONIDA_ADAPTER would be cheap; a helper that takes the adapter list by injection would let the selection be tested.

Nit: with LEONIDA_ADAPTER set, the warm query calls chosen_adapter, which logs "host device on the card …" before any device exists, and then the device logs the same line again.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6125964338 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2830#pullrequestreview-6125964338). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T06:03:23Z. **Review:** COMMENTED --- On this NVIDIA box the new path is inert, which is the first thing to want: `adapter_vendor_id()` returns `0x10de` and `default_jobs(Some(0x10de), 32)` is 21 (two thirds of 32) — the same as before — while `--jobs` still wins and never queries DXGI when passed. `warm::tests` is 2/2, flipping the vendor comparison fails both, and `d3d12_switches.py --check`, `check_no_game_data` and `git diff --check` are clean. `Shaders`' "every logical core" and `LEONIDA_PIPELINE_WORKERS` are untouched, so the shader-translation process count does not change — only how many `warm` processes run. The risk I would write down, because I could not observe AMD here: the helper takes the **first non-software `EnumAdapters1` adapter** (`host.rs:1431`), while `create` passes `NULL` to `D3D12CreateDevice` and lets Windows choose. On an Intel-iGPU + AMD-dGPU hybrid those can disagree — an OS per-app preference, or the iGPU enumerated first — and then `warm` picks two thirds of the cores while the runtime device is AMD, which is exactly the compiler-concurrency problem this default exists to avoid. `LEONIDA_ADAPTER` is the only way to align them today; the DXGI selection has no test (only `default_jobs` does). A sentence in the doc/comment about `LEONIDA_ADAPTER` would be cheap; a helper that takes the adapter list by injection would let the selection be tested. Nit: with `LEONIDA_ADAPTER` set, the warm query calls `chosen_adapter`, which logs "host device on the card …" before any device exists, and then the device logs the same line again.
imShangLi commented 2026-12-02 00:35:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-02T00:35:28Z.


VERIFY-2830 — Linux, Fedora 45, Rust 1.98.1 (the pinned toolchain), Wine 11.21, no GPU device, no game files

Verdict: PASS. The repository's own red/green idea holds under Wine: the new test fails on the merge base and passes with the pull request, and nothing that worked before is broken.

Head c6fc64b0, base the current main 85ec1d33, merge base 86c30fce, 4 files, +61/−2: d3d12/apps/leonida/src/warm.rs, d3d12/apps/leonida/src/main.rs, d3d12/crates/leonida-gpu/src/host.rs, d3d12/crates/leonida-gpu/src/lib.rs.

1. What it changes

AMD's driver compiler refuses most pipelines when several processes ask it at once, and faults (0xc0000005) when enough are refused. The warm command (which makes the title's pipelines ahead of time) used to run two thirds of the logical cores' worth of processes. The change asks the adapter for its vendor id and uses one process on AMD:

fn default_jobs(vendor: Option<u32>, cores: usize) -> usize {
    if vendor == Some(AMD) { 1 } else { (cores * 2 / 3).max(1) }
}

and the vendor id comes from a plain DXGI enumeration that makes no device:

/// PCI vendor ID of the adapter a run would use, without making a device.
/// `None` when no hardware adapter answers; callers then keep their old
/// behaviour. `LEONIDA_ADAPTER` is honoured, as it is for the device in [`create`],
/// otherwise the first hardware adapter Windows would pick.
pub fn adapter_vendor_id() -> Option<u32> { ... }

The enumeration skips software adapters (DXGI_ADAPTER_FLAG_SOFTWARE), so a WARP-only machine gets None and keeps the old default ✓.

2. What I checked

  • The arithmetic. The old default was cores * 2 / 3 and the new one is (cores * 2 / 3).max(1) for a non-AMD vendor — the same value as before (the old code's .max(1) was applied after unwrap_or, the new one after unwrap_or_else, so a caller-passed --jobs is still taken as given) ✓. On 16 cores that is 10, on one core 1 ✓.
  • The None case keeps the old behaviour, as the comment says: no adapter → the old two-thirds default ✓, which the new test checks (default_jobs(None, 16) == 10).
  • AMD is detected by the vendor id, 0x1002, the same constant the driver fault is attributed to ✓; a non-AMD vendor (0x10de) keeps two thirds ✓.
  • The enumeration is a read-only query — EnumAdapters1 and GetDesc1, no device made — which matters because the caller is the leonida app, before any device exists ✓.

3. Red and green, run under Wine

apps/leonida and leonida-gpu do not build on Linux (upstream: "The crates are Windows-only today … Linux follows #2577"), so I cross-compiled them for x86_64-pc-windows-gnu and ran the tests under Wine 11.21:

the merge base with only this pull request's tests 643 tests
the pull request's head 643 tests
red → green 1 test — the new one fails on the base and passes with the pull request
regressions 0
failing on both sides 3 — the watch tests that need Microsoft's VirtualAlloc/VirtualQuery behaviour, which Wine does not have

4. What I did not check

  • AMD's driver. That concurrent compiler processes refuse most pipelines and fault with 0xc0000005 is a claim about an AMD card and its driver; I have no AMD card here, and the fix's effect (one process instead of ten) cannot be measured.
  • Whether one process is enough on AMD — i.e. whether the warm-up now takes much longer. The pull request says one is what AMD's compiler accepts; I did not measure the time.
  • LEONIDA_ADAPTER being honoured by adapter_vendor_id(): I read that it uses the same chosen_adapter() the device path uses, and did not run it with that variable set.
  • Windows and MSVC. Everything above is Linux with Wine 11.21 (staging) and no GPU device.

AI-assisted: MiniMax M3.1 Flash.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7330736525 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2830#issuecomment-7330736525). Originally posted by [imShangLi](https://github.com/imShangLi) on 2026-12-02T00:35:28Z. --- ## VERIFY-2830 — Linux, Fedora 45, Rust 1.98.1 (the pinned toolchain), Wine 11.21, no GPU device, no game files **Verdict: PASS.** The repository's own red/green idea holds under Wine: the new test fails on the merge base and passes with the pull request, and nothing that worked before is broken. Head `c6fc64b0`, base the current `main` `85ec1d33`, merge base `86c30fce`, 4 files, +61/−2: `d3d12/apps/leonida/src/warm.rs`, `d3d12/apps/leonida/src/main.rs`, `d3d12/crates/leonida-gpu/src/host.rs`, `d3d12/crates/leonida-gpu/src/lib.rs`. ### 1. What it changes AMD's driver compiler refuses most pipelines when several *processes* ask it at once, and faults (`0xc0000005`) when enough are refused. The `warm` command (which makes the title's pipelines ahead of time) used to run two thirds of the logical cores' worth of processes. The change asks the adapter for its vendor id and uses one process on AMD: ```rust fn default_jobs(vendor: Option<u32>, cores: usize) -> usize { if vendor == Some(AMD) { 1 } else { (cores * 2 / 3).max(1) } } ``` and the vendor id comes from a plain DXGI enumeration that makes **no device**: ```rust /// PCI vendor ID of the adapter a run would use, without making a device. /// `None` when no hardware adapter answers; callers then keep their old /// behaviour. `LEONIDA_ADAPTER` is honoured, as it is for the device in [`create`], /// otherwise the first hardware adapter Windows would pick. pub fn adapter_vendor_id() -> Option<u32> { ... } ``` The enumeration skips software adapters (`DXGI_ADAPTER_FLAG_SOFTWARE`), so a WARP-only machine gets `None` and keeps the old default ✓. ### 2. What I checked - **The arithmetic.** The old default was `cores * 2 / 3` and the new one is `(cores * 2 / 3).max(1)` for a non-AMD vendor — the same value as before (the old code's `.max(1)` was applied after `unwrap_or`, the new one after `unwrap_or_else`, so a caller-passed `--jobs` is still taken as given) ✓. On 16 cores that is 10, on one core 1 ✓. - **The `None` case keeps the old behaviour**, as the comment says: no adapter → the old two-thirds default ✓, which the new test checks (`default_jobs(None, 16) == 10`). - **AMD is detected by the vendor id**, `0x1002`, the same constant the driver fault is attributed to ✓; a non-AMD vendor (`0x10de`) keeps two thirds ✓. - **The enumeration is a read-only query** — `EnumAdapters1` and `GetDesc1`, no device made — which matters because the caller is the `leonida` app, before any device exists ✓. ### 3. Red and green, run under Wine `apps/leonida` and `leonida-gpu` do not build on Linux (upstream: "The crates are Windows-only today … Linux follows #2577"), so I cross-compiled them for `x86_64-pc-windows-gnu` and ran the tests under Wine 11.21: | | | |---|---| | the merge base with only this pull request's tests | 643 tests | | the pull request's head | 643 tests | | **red → green** | 1 test — the new one fails on the base and passes with the pull request | | regressions | **0** | | failing on both sides | 3 — the `watch` tests that need Microsoft's `VirtualAlloc`/`VirtualQuery` behaviour, which Wine does not have | ### 4. What I did not check - **AMD's driver.** That concurrent compiler processes refuse most pipelines and fault with `0xc0000005` is a claim about an AMD card and its driver; I have no AMD card here, and the fix's effect (one process instead of ten) cannot be measured. - **Whether one process is enough on AMD** — i.e. whether the warm-up now takes much longer. The pull request says one is what AMD's compiler accepts; I did not measure the time. - **`LEONIDA_ADAPTER` being honoured** by `adapter_vendor_id()`: I read that it uses the same `chosen_adapter()` the device path uses, and did not run it with that variable set. - **Windows and MSVC.** Everything above is Linux with Wine 11.21 (staging) and no GPU device. AI-assisted: MiniMax M3.1 Flash.
MoonEyes commented 2026-12-02 11:52:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T11:52:29Z.


Closing: this pull request no longer applies to current main (merge conflict in d3d12/apps/leonida/src/warm.rs), and open pull requests that have fallen out of step with main are being closed so the list stays workable. If you still want this change, rebase it on current main and reopen it (or open a new pull request); it will be looked at again.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7344525782 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2830#issuecomment-7344525782). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T11:52:29Z. --- Closing: this pull request no longer applies to current `main` (merge conflict in `d3d12/apps/leonida/src/warm.rs`), and open pull requests that have fallen out of step with `main` are being closed so the list stays workable. If you still want this change, rebase it on current `main` and reopen it (or open a new pull request); it will be looked at again. AI-assisted (Claude Code).

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