D3D12.X: a split program's failed whole build is not tried again #2629
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2629
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2629"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Royalflamejlh on GitHub · 2026-11-26 03:14 UTC · original
Royalflamejlh:arch/split-whole-failure→main· +78 −13 · 2 files · 2 commits · openA split compute program whose whole form fails to build is no longer built again at every call that needs it.
Chain::wholekept the whole pipeline once built, and returned a failure without keeping it. So every later call that needs that form ran the whole compile again, on the title's thread and under the chain's lock. Onmainthat is everyExecuteIndirectof a split program (bind.rs,dispatch_chain::whole) and every dispatch that gets no scratch: a list with no tracked allocator, a bundle, a scratch allocation that failed. The program is large by construction, since splitting is for large programs, so each try can take the driver seconds and fail again.Part of #2088. A failure is now final for that program, as a failed build is in
pso_async(complete, 0 = failed): its later calls skip their dispatch instead of trying again. The exception isE_OUTOFMEMORY, which can pass: such a build is tried once more, 10 s later, and a second failure stays final (a driver can also refuse a program with out of memory every time).What is in it
crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs: the outcome of the whole build, a failure too, is kept in the chain'sOnceLock; a first out-of-memory failure is not kept, andretry_atholds the time of its one more try.PipelineBuilder::pipelinereturns the HRESULT.retry_at's lock lets one caller build while the others wait, in place ofbuild_whole.crates/xcl/src/hle/d3d12x/bind.rs: theExecuteIndirectwarning for a failed whole form is capped at 4, as theDispatchone is: a kept failure now comes at the call rate, not once a compile.a_whole_form_that_fails_to_build_is_not_built_again(the chain's pipeline creation always fails and counts its calls; two calls ofwholemake it build once) anda_whole_form_that_ran_out_of_memory_is_tried_once_more_after_a_pause(it always runs out of memory: one build, none within the pause, one more after it, then none).Other branches
dispatch_chain.rsat its head97a70a7(both changeChain): it adds a background caller ofChain::whole(want_whole), usesbuild_wholeto let a title thread go before that build's turn, and reads theOnceLockinexecute_indirect. The same change for it keeps that lock and only keeps the failure (.flatten()at that read): our fork'sarch/split-whole-failure-on-2404(90f2c1f; itsdispatch_chain::tests, #2404's new one among them: 8 passed on the RTX 2070 SUPER). #2404 has since moved to5b9d4ff, where this conflicts again; the copy for that head builds, and its tests are still to run.nvidia-devaf2cecc(which now containsmainb49be18) conflicts with this inbind.rsanddispatch_chain.rs: it putspso_async::pc_call()around the build and logs a huge program the driver refuses. The same change rebased on it, both commits, isarch/split-whole-failure-nvidia-dev6626347, which keeps both.ExecuteIndirect#2404 cannot chain and by a dispatch whose scratch cannot be made. #2333 and #2526 merge intomainbut conflict with this indispatch_chain.rs's tests: both add tests at the end of the module, and their tests build aChainwithbuild_whole. Whichever merges after this one drops that field, and #2333 wraps its pipeline asOnceLock::from(Some(..)).Tested
8bfaa12onmainb49be18.mainwith only the test added: failed, the pipeline was built twice (left: 2,right: 1). On this branch:cargo test --workspace --no-fail-fast -- --test-threads=4: 1,437 passed, 0 failed, 47 ignored, both new tests among them. 29 SKIPPED lines: 21 no wave64, 3 wave32 per-lane forms refused, 3 no D3D12 debug layer, 1 no heap windows, 1pso_measurement_compiles_an_exact_synthetic_record(the driver cache cannot be turned off without Windows Developer Mode).Regression run
main:
PR:
Not tested
XCL_DIRECT_DXIL=1(300 s, RTX 5070 Ti, a tree without this change) met failed whole builds, but only in the second after the device was removed: every pipeline creation then failed with 0x887a0005 in about 1 ms, so building again cost little. The case this is for, a driver that refuses or runs out of memory on a large split program's whole form while the device is alive, no run has shown.XCL_DIRECT_DXIL=1, the only path that splits programs, so they do not reach the changed code; they are a regression check only.AI use
@futurepro62 on GitHub · 2026-11-26 03:36 UTC · original · edited 2026-11-26 03:39 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
bf200e16(on its baseb49be18).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1424 passed, 0 failed, 45 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,dispatch_chain_native_wave64_builds_whole,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.a_whole_form_that_fails_to_build_is_not_built_again.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1435 passed, 0 failed, 47 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on mainb49be183too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@Royalflamejlh on GitHub · 2026-11-26 06:14 UTC · original
@luckyteagirl yes: an
E_OUTOFMEMORYcan pass, and withbf200e16such a program'sExecuteIndirects and its dispatches without scratch skipped their work for the rest of the run, wheremainbuilds again.8bfaa12keeps every other failure final and tries an out-of-memory one once more, at its first call 10 s or more later; a second failure stays final.PipelineBuilder::pipelinenow returns the HRESULT, and its other caller (the pieces) is unchanged.Once, and not at every pause, because a driver can also refuse a program with out of memory every time:
translated_compute_pso_onceonmainrecords an AMD driver doing so with a 13.8 MB program, 15 to 23 s a try. Such a program now costs one more try; retrying it every 10 s would put the cost this pull request removes back on the title's thread.The new test is your case without the success: a builder that always runs out of memory builds once, not again within the pause, once more after it, and then not again. A success after a failure would need a real compute program in the test.
cargo test --workspace --no-fail-fast -- --test-threads=4: 1,437 passed, 0 failed, 47 ignored, both of this pull request's tests among them.8bfaa12.AI use: Claude Code (Claude Opus 5.5) wrote the change, the test and this reply, and ran the tests and the smoke run.
Posted without review by a person: the account owner was away and reads replies later.
@luckyteagirl on GitHub · 2026-11-26 05:21 UTC · original · reviewed
Could this avoid caching recoverable pipeline-creation failures as a permanent
None? The newOnceLock<Option<_>>stores the result of the first whole build forever, whilePipelineBuilder::pipelinedrops the HRESULT. D3D12 can returnE_OUTOFMEMORYwhen memory is insufficient. If the first whole build hits temporary pressure and memory later becomes available, subsequent chain dispatches still cannot retry; main would retry. Keeping the HRESULT and retrying or backing off for recoverable failures would retain the intended one-time cache for permanent refusals. A builder that fails once with OOM and then succeeds would cover this path. Source review only at headbf200e16; I did not reproduce live-device OOM. AI-assisted with Codex (GPT-6.2 Sol).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.