fix(gpu/run): keep descriptor heaps alive, harden device loss handling #239

Closed
github-bot wants to merge 1 commit from gh-pr/239/head into gh-pr/239/base
Owner

@⁠racknea on GitHub · 2026-11-23 21:45 UTC · original
racknea:patch-1 → main · +500 −474 · 1 files · 1 commits · closed without merging

No description provided.

**@⁠racknea** on GitHub · 2026-11-23 21:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/239) `racknea:patch-1` → `main` · +500 −474 · 1 files · 1 commits · closed without merging *No description provided.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:17:11 +00:00
github-bot closed this pull request 2026-11-26 04:17:11 +00:00
Author
Owner

@⁠denio4321 on GitHub · 2026-11-23 22:13 UTC · original

Tested cc124cf merged onto main 9ab7d76 on RTX 3060 12 GB (Ampere, 32-lane waves), NVIDIA 610.88, Windows 11 Pro 23H2 (22631), rustc 1.100.0 MSVC, DXC 1.9.2602.17.

.\scripts\test.ps1 (debug, --test-threads=4), no XCL_SAMPLE_* set. Baseline main 9ab7d76 alone on the same machine: 651 passed, 0 failed, 40 ignored.

  • This PR: 651 passed, 0 failed, 40 ignored, the same as main. Nothing regresses in the GPU tests that go through gpu/run.
  • The PR adds no test, and the suite never loses the device, so the device-loss path it changes isn't exercised by this run. A short description of what failed before (which heap was released early, and where) would make the 500 / 474 line rewrite easier to review.

AI-assisted (Claude Code).

**@⁠denio4321** on GitHub · 2026-11-23 22:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/239#issuecomment-7115486278) Tested `cc124cf` merged onto `main` `9ab7d76` on RTX 3060 12 GB (Ampere, 32-lane waves), NVIDIA 610.88, Windows 11 Pro 23H2 (22631), rustc 1.100.0 MSVC, DXC 1.9.2602.17. `.\scripts\test.ps1` (debug, `--test-threads=4`), no `XCL_SAMPLE_*` set. Baseline `main` `9ab7d76` alone on the same machine: 651 passed, 0 failed, 40 ignored. - This PR: **651 passed, 0 failed, 40 ignored**, the same as `main`. Nothing regresses in the GPU tests that go through `gpu/run`. - The PR adds no test, and the suite never loses the device, so the device-loss path it changes isn't exercised by this run. A short description of what failed before (which heap was released early, and where) would make the 500 / 474 line rewrite easier to review. AI-assisted (Claude Code).
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-23 22:30 UTC · original

Please keep the empty-draw heap fix and revise device removal before merging. Two controls on an RTX 5070 Ti showed where recovery breaks.

  1. A timeout removes the caller’s healthy device. I held an idle queue behind a CPU fence for 11.5 seconds. Both builds returned the ten-second timeout. On main, GetDeviceRemovedReason returned S_OK and the submission fence completed after release. On the merge it returned DXGI_ERROR_DEVICE_REMOVED (0x887A0005). No shader ran. Both draw_on_multi and dispatch_on pass a caller-owned device to this helper. Keep submitted resources alive until completion or confirmed removal and leave device-wide recovery to the owner. Error path · D3D12 removal semantics
  2. One failed recreation disables later retries. I retained a second device reference during explicit removal and the first retry. After releasing it, an independent init() succeeded on the merge, but the public runner still returned the cached removal error. Cache successful recreation and leave the slot empty on a transient failure. Cache path · D3D12 device identity

Tested

Windows 11 Pro 26200.9711, Ryzen 9 9950X, RTX 5070 Ti, NVIDIA 610.74, native D3D12, DXC 1.7.2308.16. Local merge 61583594e366877a62fb109066626dadedd0836a of head cc124cf80159f160da0505ac79e4d340b82afa60 onto main 7a033c8cd13194900cd49c01ed60a59c6c9559c7. The PR adds no tests.

Local synthetic control Main Merge
Empty-texture, empty-sampler draw Heap owner dropped before submission. Assertion stopped the draw. Owner survived the fence. Read back red and observed release on return.
Poisoned GPU mutex and explicit removal with no other owner Next lookup panicked or next allocation failed, respectively Both recovered
Short texture, seven-face cube, private zero-window arena Panicked, accepted, panicked All three returned errors
Two static samplers through run_code, stopping after PSO creation E_INVALIDARG PSO created
Valid UMA dispatch, with separate drop counters for the temporary window list and bound heaps Neither counter advanced Both advanced. Shader output matched main.

On the unmodified merge, cargo test -p xcl -j2 --lib --no-run followed by the binary with gpu::recomp:: --test-threads=1 reported 182 passed, 0 failed, 18 ignored, including two native-wave64 skips and one sample-dependent early return. Queued runs of the fence tests (5), compute integration tests (2), predication integration test (1), UMA test (1) and static-sampler test (1) passed on both builds. The 11 review controls above and in the findings ran individually in fresh processes. Nine failed on main and passed on the merge, one regressed, and one failed on both.

Merge order. Each head conflicts with #239 in runner.rs. Rebase #214 (bf2a27e) after #187 (c74b03a) and preserve #187’s populated window UAV heap in both arena and compute dispatch. #214 already conflicts with main in real.rs. Preserve #152’s cached draw queue and increasing fence value (4ba00d9) when applying the lifetime fix. Its conflicts in recomp/mod.rs and tests.rs already exist on main.

Not tested

The retail game, AMD, WARP, a real driver TDR, or timing changes from I/O packing, barrier batching and removing the second map. The static-sampler control checked PSO creation only. An initial invalid-DXIL arena probe terminated without an assertion result and is excluded from the counts.

🤖 GPT-6.2 Astra

**@⁠Kalmarv** on GitHub · 2026-11-23 22:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/239#issuecomment-7115838518) **Please keep the empty-draw heap fix and revise device removal before merging.** Two controls on an RTX 5070 Ti showed where recovery breaks. 1. **A timeout removes the caller’s healthy device.** I held an idle queue behind a CPU fence for 11.5 seconds. Both builds returned the ten-second timeout. On main, `GetDeviceRemovedReason` returned `S_OK` and the submission fence completed after release. On the merge it returned `DXGI_ERROR_DEVICE_REMOVED` (`0x887A0005`). No shader ran. Both `draw_on_multi` and `dispatch_on` pass a caller-owned device to this helper. Keep submitted resources alive until completion or confirmed removal and leave device-wide recovery to the owner. [Error path](https://github.com/ivall/xcl/blob/cc124cf80159f160da0505ac79e4d340b82afa60/crates/xcl/src/gpu/recomp/runner.rs#L83) · [D3D12 removal semantics](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device5-removedevice) 2. **One failed recreation disables later retries.** I retained a second device reference during explicit removal and the first retry. After releasing it, an independent `init()` succeeded on the merge, but the public runner still returned the cached removal error. Cache successful recreation and leave the slot empty on a transient failure. [Cache path](https://github.com/ivall/xcl/blob/cc124cf80159f160da0505ac79e4d340b82afa60/crates/xcl/src/gpu/recomp/runner.rs#L105) · [D3D12 device identity](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-d3d12createdevice#remarks) **Tested** Windows 11 Pro 26200.9711, Ryzen 9 9950X, RTX 5070 Ti, NVIDIA 610.74, native D3D12, DXC 1.7.2308.16. Local merge `61583594e366877a62fb109066626dadedd0836a` of head `cc124cf80159f160da0505ac79e4d340b82afa60` onto main `7a033c8cd13194900cd49c01ed60a59c6c9559c7`. The PR adds no tests. | Local synthetic control | Main | Merge | |---|---|---| | Empty-texture, empty-sampler draw | Heap owner dropped before submission. Assertion stopped the draw. | Owner survived the fence. Read back red and observed release on return. | | Poisoned GPU mutex and explicit removal with no other owner | Next lookup panicked or next allocation failed, respectively | Both recovered | | Short texture, seven-face cube, private zero-window arena | Panicked, accepted, panicked | All three returned errors | | Two static samplers through `run_code`, stopping after PSO creation | `E_INVALIDARG` | PSO created | | Valid UMA dispatch, with separate drop counters for the temporary window list and bound heaps | Neither counter advanced | Both advanced. Shader output matched main. | On the unmodified merge, `cargo test -p xcl -j2 --lib --no-run` followed by the binary with `gpu::recomp:: --test-threads=1` reported **182 passed, 0 failed, 18 ignored**, including two native-wave64 skips and one sample-dependent early return. Queued runs of the fence tests (5), compute integration tests (2), predication integration test (1), UMA test (1) and static-sampler test (1) passed on both builds. The 11 review controls above and in the findings ran individually in fresh processes. Nine failed on main and passed on the merge, one regressed, and one failed on both. **Merge order.** Each head conflicts with #239 in `runner.rs`. Rebase #214 (`bf2a27e`) after #187 (`c74b03a`) and preserve #187’s populated window UAV heap in both arena and compute dispatch. #214 already conflicts with main in `real.rs`. Preserve #152’s cached draw queue and increasing fence value (`4ba00d9`) when applying the lifetime fix. Its conflicts in `recomp/mod.rs` and `tests.rs` already exist on main. **Not tested** The retail game, AMD, WARP, a real driver TDR, or timing changes from I/O packing, barrier batching and removing the second map. The static-sampler control checked PSO creation only. An initial invalid-DXIL arena probe terminated without an assertion result and is excluded from the counts. 🤖 GPT-6.2 Astra
Author
Owner

@⁠raylitebull on GitHub · 2026-11-24 10:43 UTC · original

Closing as a stale, conflicting PR with an empty description and unresolved device-loss recovery review feedback. Feel free to submit a fresh, scoped PR for the descriptor-heap fix per CONTRIBUTING.md.

**@⁠raylitebull** on GitHub · 2026-11-24 10:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/239#issuecomment-7129162336) Closing as a stale, conflicting PR with an empty description and unresolved device-loss recovery review feedback. Feel free to submit a fresh, scoped PR for the descriptor-heap fix per `CONTRIBUTING.md`.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.