D3D12.X: gate 128-256 KiB compute driver compiles in MEDIUM_COMPILES #2726

Open
github-bot wants to merge 3 commits from github-bot/gh-2726 into amd-dev AGit
Owner

@⁠Saksukella on GitHub · 2026-11-26 08:59 UTC · original
Saksukella:fix/gate-medium-compute-pso → amd-dev · +169 −6 · 1 files · 3 commits · open

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs:
    • Add MEDIUM_COMPUTE_DRIVER_COMPILE = 128 << 10 (128 KiB) and driver_compile_gate_bytes(kind: &str, huge_bytes: usize) so medium-sized (128..512 KiB) translated compute PSOs ("compute" / "compute retry") enter the MEDIUM_COMPILES concurrency gate instead of compiling ungated across all worker threads on AMD's driver (amdxc64), and update finish_two_pass to use the same compute gate threshold.
    • Keep graphics PSOs on the existing 256..512 KiB threshold, keep small (< 128 KiB) compute PSOs ungated, preserve BIG_COMPILES (512..900 KiB) and GIANT_COMPILES (>= 900 KiB), and keep title-thread binds ungated (driver_compile_identified only gates background worker compiles).
    • Extract gate_driver_compile_with_threshold taking explicit huge_threshold, commit_free, and wanted predicates so medium_compute_worker_compiles_are_gated_in_medium_lane is deterministic regardless of XCL_HUGE_PSO_BYTES or host free commit memory, and guard MEDIUM_COMPILES slot cleanup on drop.
    • Add GLOBAL_SLOTS_TEST_LOCK and unit tests medium_compute_gate_threshold_applies_only_to_compute and medium_compute_worker_compiles_are_gated_in_medium_lane.
  • Target branch: amd-dev (where MEDIUM_COMPILES and driver_compile_identified live).

Tested

  • Hardware: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), 24-thread x86_64 CPU, 32 GB RAM, Windows; rustc 1.100.0 (0ef1bc386 2026-11-09); debug (tests) and release (xcl.exe).
  • cargo test -p xcl --lib hle::d3d12x::real::big_compile_tests: both new tests (medium_compute_gate_threshold_applies_only_to_compute, medium_compute_worker_compiles_are_gated_in_medium_lane) and small_and_title_thread_compiles_bypass_the_gate passed (the single failure giant_driver_compiles_have_their_own_lane is pre-existing on amd-dev b5c0275f because parse_rt_skip_hashes parses "bad" as hex 0xbad).

Regression run

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1624 (PresentX 1624)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19700 MB
xcl-smoke v1
commit: b6034426dc8db04da4dd97363d3bf593d112d631
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1482 (PresentX 1483)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15099 MB

Not tested

  • NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only).

AI use

  • Antigravity (Google Gemini): assisted with profiling 179–217 KiB compute PSO driver-compile stalls, designing the 128 KiB MEDIUM_COMPILES gate, authoring deterministic unit tests, and running local tests and smoke verification. All diffs and measurements were verified locally on hardware.
**@⁠Saksukella** on GitHub · 2026-11-26 08:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/2726) `Saksukella:fix/gate-medium-compute-pso` → `amd-dev` · +169 −6 · 1 files · 3 commits · open **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: - Add `MEDIUM_COMPUTE_DRIVER_COMPILE = 128 << 10` (128 KiB) and `driver_compile_gate_bytes(kind: &str, huge_bytes: usize)` so medium-sized (`128..512 KiB`) translated compute PSOs (`"compute"` / `"compute retry"`) enter the `MEDIUM_COMPILES` concurrency gate instead of compiling ungated across all worker threads on AMD's driver (`amdxc64`), and update `finish_two_pass` to use the same compute gate threshold. - Keep graphics PSOs on the existing `256..512 KiB` threshold, keep small (`< 128 KiB`) compute PSOs ungated, preserve `BIG_COMPILES` (`512..900 KiB`) and `GIANT_COMPILES` (`>= 900 KiB`), and keep title-thread binds ungated (`driver_compile_identified` only gates background worker compiles). - Extract `gate_driver_compile_with_threshold` taking explicit `huge_threshold`, `commit_free`, and `wanted` predicates so `medium_compute_worker_compiles_are_gated_in_medium_lane` is deterministic regardless of `XCL_HUGE_PSO_BYTES` or host free commit memory, and guard `MEDIUM_COMPILES` slot cleanup on drop. - Add `GLOBAL_SLOTS_TEST_LOCK` and unit tests `medium_compute_gate_threshold_applies_only_to_compute` and `medium_compute_worker_compiles_are_gated_in_medium_lane`. - Target branch: `amd-dev` (where `MEDIUM_COMPILES` and `driver_compile_identified` live). **Tested** - Hardware: AMD Radeon RX 9070 XT (driver `32.0.32029.2010`), 24-thread x86_64 CPU, 32 GB RAM, Windows; `rustc 1.100.0 (0ef1bc386 2026-11-09)`; debug (tests) and release (`xcl.exe`). - `cargo test -p xcl --lib hle::d3d12x::real::big_compile_tests`: both new tests (`medium_compute_gate_threshold_applies_only_to_compute`, `medium_compute_worker_compiles_are_gated_in_medium_lane`) and `small_and_title_thread_compiles_bypass_the_gate` passed (the single failure `giant_driver_compiles_have_their_own_lane` is pre-existing on `amd-dev` `b5c0275f` because `parse_rt_skip_hashes` parses `"bad"` as hex `0xbad`). **Regression run** ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: AMD Radeon RX 9070 XT title: b8db18c2 seconds: 60 exit: 0x0 frames shown: 1624 (PresentX 1624) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19700 MB ``` ``` xcl-smoke v1 commit: b6034426dc8db04da4dd97363d3bf593d112d631 gpu: AMD Radeon RX 9070 XT title: b8db18c2 seconds: 60 exit: 0x0 frames shown: 1482 (PresentX 1483) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15099 MB ``` **Not tested** - NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only). **AI use** - Antigravity (Google Gemini): assisted with profiling `179–217 KiB` compute PSO driver-compile stalls, designing the `128 KiB` `MEDIUM_COMPILES` gate, authoring deterministic unit tests, and running local tests and smoke verification. All diffs and measurements were verified locally on hardware.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:04:36 +00:00
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-26 09:47 UTC · original

Independent AMD RDNA4 (native wave64) verification of exact PR head d7a34bb3201a0692ca648e3aa33723e683210f82 (base: amd-dev) on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver 32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC 1.9.2602.17).

Tested

  • cargo build --workspace (debug): passed (0 errors).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1658 passed, 14 failed, 47 ignored (5 SKIPPED: 4 f16_programs_on_the_gpu per-lane forms refused by host adapter/driver, 1 pso_measurement_compiles_an_exact_synthetic_record Windows Developer Mode off).
    • Both new tests passed:
      • hle::d3d12x::real::big_compile_tests::medium_compute_gate_threshold_applies_only_to_compute
      • hle::d3d12x::real::big_compile_tests::medium_compute_worker_compiles_are_gated_in_medium_lane
    • The 14 failures are identical to the amd-dev base (#2738 on the same base reproduces the exact same 14 failures on this machine).
  • cargo build --release -p xcl + 60 s retail-title smoke test (scripts/smoke.ps1, offline):
xcl-smoke v1
commit: d7a34bb3201a0692ca648e3aa33723e683210f82
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1549 (PresentX 1549)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14952 MB

Not tested

  • NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.
**@⁠emirduran707** on GitHub · 2026-11-26 09:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/2726#issuecomment-7188467901) Independent AMD RDNA4 (native wave64) verification of exact PR head `d7a34bb3201a0692ca648e3aa33723e683210f82` (`base: amd-dev`) on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver `32.0.31044.16`, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC `1.9.2602.17`). **Tested** - `cargo build --workspace` (debug): passed (`0` errors). - `cargo test --workspace --no-fail-fast -- --test-threads=4`: `1658 passed, 14 failed, 47 ignored` (`5 SKIPPED`: 4 `f16_programs_on_the_gpu` per-lane forms refused by host adapter/driver, 1 `pso_measurement_compiles_an_exact_synthetic_record` Windows Developer Mode off). - Both new tests passed: - `hle::d3d12x::real::big_compile_tests::medium_compute_gate_threshold_applies_only_to_compute` - `hle::d3d12x::real::big_compile_tests::medium_compute_worker_compiles_are_gated_in_medium_lane` - The 14 failures are identical to the `amd-dev` base (`#2738` on the same base reproduces the exact same 14 failures on this machine). - `cargo build --release -p xcl` + 60 s retail-title smoke test (`scripts/smoke.ps1`, offline): ``` xcl-smoke v1 commit: d7a34bb3201a0692ca648e3aa33723e683210f82 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1549 (PresentX 1549) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14952 MB ``` **Not tested** - NVIDIA / Intel GPUs, Linux / Wine. **AI use** - Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 09:59 UTC · original · reviewed

On d7a34bb, the new medium_compute_worker_compiles_are_gated_in_medium_lane test can hang under a supported setting: run it with XCL_HUGE_PSO_BYTES=65536. Its small_cs worker uses 131071 bytes, but the effective compute gate becomes min(65536, 131072) = 65536, so that worker waits for MEDIUM_COMPILES. The test already holds every medium slot and calls small_cs.join() before drop(held), making the join and release wait on each other indefinitely. The default-threshold AMD test report does not exercise this case.

Could the fixture inject a fixed threshold independent of the process environment, and use a bounded completion channel so an unexpected wait fails without blocking the test indefinitely? Please ensure held slots are released before joining workers on every failure path. This is exact-head source review; I did not run a deliberately hanging test process.

**@⁠luckyteagirl** on GitHub · 2026-11-26 09:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/2726#pullrequestreview-6071987493) · **reviewed** On `d7a34bb`, the new `medium_compute_worker_compiles_are_gated_in_medium_lane` test can hang under a supported setting: run it with `XCL_HUGE_PSO_BYTES=65536`. Its `small_cs` worker uses 131071 bytes, but the effective compute gate becomes `min(65536, 131072) = 65536`, so that worker waits for `MEDIUM_COMPILES`. The test already holds every medium slot and calls `small_cs.join()` before `drop(held)`, making the join and release wait on each other indefinitely. The default-threshold AMD test report does not exercise this case. Could the fixture inject a fixed threshold independent of the process environment, and use a bounded completion channel so an unexpected wait fails without blocking the test indefinitely? Please ensure held slots are released before joining workers on every failure path. This is exact-head source review; I did not run a deliberately hanging test process.
Author
Owner

@⁠Saksukella on GitHub · 2026-11-26 11:33 UTC · original

Good catch @⁠luckyteagirl — fixed in 71f30c6f. Extracted gate_driver_compile_with_threshold(compute, bytes, huge_threshold) so medium_compute_worker_compiles_are_gated_in_medium_lane injects a fixed 256 KiB threshold independent of XCL_HUGE_PSO_BYTES, uses bounded recv_timeout checks, and always releases held slots before joining workers on every path. Verified big_compile_tests passes under both default env and XCL_HUGE_PSO_BYTES=65536, plus 60s RX 9070 XT smoke (1672 frames, 15066 MB, 0 removals, 0 crashes).

**@⁠Saksukella** on GitHub · 2026-11-26 11:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2726#issuecomment-7190886692) Good catch @⁠luckyteagirl — fixed in `71f30c6f`. Extracted `gate_driver_compile_with_threshold(compute, bytes, huge_threshold)` so `medium_compute_worker_compiles_are_gated_in_medium_lane` injects a fixed 256 KiB threshold independent of `XCL_HUGE_PSO_BYTES`, uses bounded `recv_timeout` checks, and always releases held slots before joining workers on every path. Verified `big_compile_tests` passes under both default env and `XCL_HUGE_PSO_BYTES=65536`, plus 60s RX 9070 XT smoke (1672 frames, 15066 MB, 0 removals, 0 crashes).
Author
Owner

@⁠Prime1997 on GitHub · 2026-11-26 12:40 UTC · original · reviewed

Needs changes in the regression fixture; keep the compute-gate change. On head 71f30c6fe84fe22cbc8b87d5056c09e99612d56a, the fixed threshold and release-before-join address the earlier environment-dependent deadlock. A separate wait condition remains: medium_compute_worker_compiles_are_gated_in_medium_lane still uses the real commit-headroom predicate through gate_driver_compile_with_threshold. Its named 180 KiB worker has no pending pipeline, so build_is_wanted() stays false. With available system commit persistently below 3 GiB, the gate continues waiting even after the held slots are released. The two-second receive timeout is followed by an unconditional join, so the test cannot reach its failure assertion while that condition persists.

Please inject a controlled commit/wanted predicate for this fixture and ensure cleanup makes the worker exit before joining, including after a receive timeout. This is exact-head source review only: no low-memory stress, deliberately hanging process, build, GPU or title test was run for this finding. It does not establish a defect in the intended runtime throttling policy.

AI use: Codex (GPT-6) checked the current source and discussion and drafted this review. Optional temporary Discord for coordinating contributor work, testing and comparing results.

**@⁠Prime1997** on GitHub · 2026-11-26 12:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/2726#pullrequestreview-6074284472) · **reviewed** **Needs changes in the regression fixture; keep the compute-gate change.** On head `71f30c6fe84fe22cbc8b87d5056c09e99612d56a`, the fixed threshold and release-before-join address the earlier environment-dependent deadlock. A separate wait condition remains: `medium_compute_worker_compiles_are_gated_in_medium_lane` still uses the real commit-headroom predicate through [`gate_driver_compile_with_threshold`](https://github.com/xcl-dev/xcl/blob/71f30c6fe84fe22cbc8b87d5056c09e99612d56a/crates/xcl/src/hle/d3d12x/real.rs#L4903). Its named 180 KiB worker has no pending pipeline, so `build_is_wanted()` stays false. With available system commit persistently below 3 GiB, [the gate continues waiting](https://github.com/xcl-dev/xcl/blob/71f30c6fe84fe22cbc8b87d5056c09e99612d56a/crates/xcl/src/hle/d3d12x/real.rs#L4960-L5004) even after the held slots are released. The [two-second receive timeout is followed by an unconditional join](https://github.com/xcl-dev/xcl/blob/71f30c6fe84fe22cbc8b87d5056c09e99612d56a/crates/xcl/src/hle/d3d12x/real.rs#L5308-L5324), so the test cannot reach its failure assertion while that condition persists. Please inject a controlled commit/wanted predicate for this fixture and ensure cleanup makes the worker exit before joining, including after a receive timeout. This is exact-head source review only: no low-memory stress, deliberately hanging process, build, GPU or title test was run for this finding. It does not establish a defect in the intended runtime throttling policy. AI use: Codex (GPT-6) checked the current source and discussion and drafted this review. Optional temporary [Discord](https://discord.gg/gK3y7WRRY) for coordinating contributor work, testing and comparing results.
Author
Owner

@⁠Saksukella on GitHub · 2026-11-26 13:42 UTC · original

Good catch @⁠Prime1997 — fixed in \6034426. \gate_driver_compile_with_threshold\ now takes explicit \commit_free\ and \wanted\ predicates (defaulting to \ig_compile_commit_free(big_compile_headroom(bytes))\ and \pso_async::build_is_wanted\ in \driver_compile_identified), and \medium_compute_worker_compiles_are_gated_in_medium_lane\ injects deterministic predicates plus a drop-based \Cleanup\ guard so the test never stalls on hosts with < 3 GiB free commit headroom. Re-verified with unit tests and a fresh 60s RX 9070 XT smoke (\1482\ frames, \

**@⁠Saksukella** on GitHub · 2026-11-26 13:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/2726#issuecomment-7193731692) Good catch @⁠Prime1997 — fixed in \6034426\. \gate_driver_compile_with_threshold\ now takes explicit \commit_free\ and \wanted\ predicates (defaulting to \ig_compile_commit_free(big_compile_headroom(bytes))\ and \pso_async::build_is_wanted\ in \driver_compile_identified\), and \medium_compute_worker_compiles_are_gated_in_medium_lane\ injects deterministic predicates plus a drop-based \Cleanup\ guard so the test never stalls on hosts with < 3 GiB free commit headroom. Re-verified with unit tests and a fresh 60s RX 9070 XT smoke (\1482\ frames, \
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/real.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2726/head:github-bot/gh-2726'
git switch 'github-bot/gh-2726'

Merge

Merge the changes and update on Forgejo.
git switch 'amd-dev'
git merge --no-ff 'github-bot/gh-2726'
git switch 'github-bot/gh-2726'
git rebase 'amd-dev'
git switch 'amd-dev'
git merge --ff-only 'github-bot/gh-2726'
git switch 'github-bot/gh-2726'
git rebase 'amd-dev'
git switch 'amd-dev'
git merge --no-ff 'github-bot/gh-2726'
git switch 'amd-dev'
git merge --squash 'github-bot/gh-2726'
git switch 'amd-dev'
git merge --ff-only 'github-bot/gh-2726'
git switch 'amd-dev'
git merge 'github-bot/gh-2726'
git push origin 'amd-dev'
This discussion has been locked. Commenting is limited to contributors.
No description provided.