Retail title on NVIDIA: root-cause fixes log (each with its cause, evidence and code) #2952
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#2952
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@claudetools-gh on GitHub · 2026-11-27 03:56 UTC · original
A running log of fixes for the retail title where the root cause is shown, the fix is on by default (not behind an env switch), and the result was measured in the world on our machine. Each entry is its own comment below, with the cause, the evidence, the fix (code in the comment when it is ours and small) and what was ruled out. This issue gets updated as entries land.
The goal is that others can take a fix as it is, instead of collecting switches. Workarounds that only hide a symptom (refusing programs, budgets that drop work, barriers added "because it stops hanging") do not go here. If you have an entry of that kind, or a correction to one of ours, please add it in the same format.
Machine: RTX 5070 Ti 16 GB (driver 621.01), Ryzen 7 9700X, 62 GB RAM, Windows 11 26300, render 2560x1440. Tree:
nvidia-dev-based lab tree (MacieGx's lab plus our changes).title_textures.rsv_div_fmas_f32scales by VCCdxil/prelude.rs,dxil/lower_valu.rsshaders.rsindirect_clamp.hlsl/.rsMapof GPU-written memory waits only for the copy backs it overlapssparse.rsbind.rsAI-assisted.
@claudetools-gh on GitHub · 2026-11-27 03:56 UTC · original
1. Loading-art flicker: the first write to a cold block reaches the GPU unseen
Symptom. On the loading art, single frames of black or of the background without the character layer, in a cycle of about 216 frames (96 flashes in 50 s here). Reported also on an RTX 4080 (#2572) and an RTX 3090 (#2917).
Cause.
7c18bc41(onnvidia-dev, not onmain) makes each look for CPU writes before a submit take only the 2 MiB blocks written in the lasthot_for(1,500 ms), while a background walk finds writes to the other blocks later. A block that has gone cold and gets written just before a submit is uploaded late: the GPU reads the stale copy for that frame. Evidence:XCL_WATCH_HOT=0gives 0 flashes in 85 s, andXCL_WATCH_HOT_MS=10000also removes them, at a cost in fps.Fix (ours, default on): write guards on cold blocks. A block that leaves the hot set is set
PAGE_READONLYby a guard thread. The next look reads its write-watch bits one last time, then leaves it alone. The first write to it faults into a lock-free vectored handler, which makes the block writable again, puts it back in the hot set and lets the write retry. So the looks stay as cheap as with7c18bc41, and no first write is missed.XCL's own writers have to open the blocks first:
ReadFile(including OVERLAPPED), DirectStorage, physical-page copies and CLZERO emulation. TheVirtualProtect/Alloc/Free/Queryhooks andcpu_writesknow about the guards too, and the title's protect/commit/free calls pin the blocks across the call. About 1,500 lines over 13 files, so we describe it rather than paste it. Ask if you want a part of it.Measured: 0 flashes in 85 s and 0 leaks (no block left writable without being hot), with no fps cost against hot looks. The simpler alternative, if you don't need the hot-look speed, is MacieGx's
240037e7, which turns hot looks off by default.AI-assisted.
@claudetools-gh on GitHub · 2026-11-27 03:56 UTC · original · edited 2026-11-27 07:31 UTC
2. Direct DXIL division: an overflowed quotient became NaN
Cause. The direct translator's
v_div_scale_f32returns its source unscaled and clears VCC, so the f32 division sequence (rcp, Newton fmas,v_div_fmas,v_div_fixup) can overflow where the hardware's scaled sequence never does.q = n·rcp(d)becomes Inf, the nextfma(-d, q, n)gives -Inf, and the step after that gives NaN.div_fixupthen returned that NaN for finite operands. #1144 fixeddiv_fixupandv_div_fmas_f32in the HLSL path only; withXCL_DIRECT_DXIL=1the bug stayed. A NaN in HDR shows as black and spreads through bloom, so we checked it.Fix. #1144's rules, ported to
dxil/prelude.rs(div_fixup). Each select wins over the ones before it:In
dxil/lower_valu.rs, both forms ofv_div_fmas_f32(the plain one and the rounding-mode one) now read VCC (u.get(3),Src::Pair) and selectldexp_f(r, 32)for lanes where it is set, as the HLSL path does since #1144.Tested: #1144's
gpu_div_fixup_f32_special_cases_and_signandgpu_div_fmas_f32_scales_by_vccpass with and withoutXCL_DIRECT_DXIL=1(3/3 in each). The VCC test failed on the direct path before the change.Not a fix for our dark cell. The black window stayed the same. A follow-up for quotients that come out as 0 or Inf from an unscaled reciprocal will be its own entry once it is measured in the world.
AI-assisted.
@claudetools-gh on GitHub · 2026-11-27 03:56 UTC · original
4. Single-record clamp: no 1,024-thread scan for one 12-byte record
Cause. Each two-pass mesh draw of this title (~3,700 a frame, all single-record
ExecuteIndirect(DispatchMesh)with no count buffer) bounds its record withindirect_clamp.hlsl'smain: one group of 1,024 threads, a prefix scan and about 23 group syncs, all for one record.Fix. A second entry point in
indirect_clamp.hlsl, chosen inbound_withinwhenmax == 1 && count_buf == 0. Its output is exactly whatmaingives for that case: the inclusive sum of a single record is its own work.The pipeline is made on first use from the same root signature, and falls back to
mainif it fails.Tested: a GPU test runs both entry points over 8 cases and compares every output byte: a normal record, garbage (
0xFFFFFFFF), zero, over budget, exactly at budget, fold, and draws with fields outside the action.Measured: in the world, frames 3000–3600 take 134–135 ms against 137 ms. It is small, but it holds across runs.
AI-assisted.
@SergeAx on GitHub · 2026-11-27 06:24 UTC · original
Item 1 confirmed on an RTX 5080 16 GB (driver 621.14, Windows 10 22H2):
nvidia-devecc0bb57+ #2929 + #1435, release, warm caches.XCL_WATCH_HOT=0alone removes them. The run before it, withXCL_WATCH_HOT=0and two other changes, had none either.XCL_PAGE_MAPPINGS=0,XCL_DISPATCH_LOOP_BUDGET=0,XCL_DS_KNOWN_WRITES=0, and title texture uploads back on XCL's own queue (a local switch that makestitle_queue_forreturnNone, as before124ccfb1).nvidia-devagainstmainb49be18(good) found them already at41303e41(24 November 23:54), which contains7c18bc41.The black frames were judged by eye, watching the loading screen in each run.
AI use: Claude Code (Claude Opus 5.5) built the trees, ran the title, set up the bisect and wrote this; the user watched the screen.
@KDenKC on GitHub · 2026-11-27 06:30 UTC · original · edited 2026-11-27 06:50 UTC
On entry 2 (direct-DXIL division), after reading the lowering at
mainc2ee10e4andnvidia-deva5e2d851: the cause is on both pins.gpu/dxil/lower_valu.rs:1015-1022passesv_div_scale_f32's selected input through and clears the lane mask, and:630-636/:1117-1120emitv_div_fmas_f32with no VCC post-scale.Your
div_fixupchange fixes the special-value result bits, butDIV_SCALEstays unscaled, so the sequence still overflows before fixup sees it. Two inputs where the result still differs from hardware (static; no GPU probe yet):n = d = 2^-130, with f32 denormals preserved. The true quotient is1. Unscaled,rcp(2^-130) = 2^130overflows to+inf, thenfma(-d, inf, 1) = -infandfma(-inf, inf, inf) = NaN. The patched fixup maps that NaN to+inf. Hardware prescales because the denominator is subnormal and never produces that NaN.DIV_FMASwith VCC set: scaling the already-rounded FMA isn't the same as scaling inside the fused operation. For2^-126 * 2^-30 + 0, the f32 intermediate2^-156rounds to zero even with denormals kept, so scaling it afterwards stays0, while the fused, scaled result is2^-124(prelude.rs:156-173'sldexp_fkeeps the zero).So a complete fix needs
DIV_SCALE's prescale and its VCC output, and a post-scale inside the FMA. Related: #1144 (eac652c3) is HLSL-only. Its direct-DXIL follow-up was posted inline there (#1144) but isn't in the head. Raw-bit outputs from an AMD hardware probe for all three opcodes would make a fixture for either path; we can run the same fixture through direct DXIL on an RTX 5090, both f32 denorm modes.On entry 1: on main this is covered by #2934 (
c230aa1b, opt-in watch trap: fault recovery, I/O pins, final look). The cold-block gap itself comes from7c18bc41, which onlynvidia-devhas.AI use: Codex (GPT-6.2-Sol) reviewed the code and worked out the cases; Claude Code (Claude Opus 5.5) checked the arithmetic and wrote this comment.
Update: the
ldexp_f(r, 32)in the entry-2 patch (and in #1144) is likely the wrong factor for the hardware: tinygrad's AMD hardware tests expect2^64or2^-64byexponent(S2) > 127. Details on #1144: #1144@claudetools-gh on GitHub · 2026-11-27 08:53 UTC · original
6. Pipeline caches replaced a pipeline that lists were still using: GPU hang at world entry (and two-pass batching)
Symptom. At world entry, 0x887a0006 (DEVICE_HUNG) a few seconds after the first frames that used a compute pipeline from one of XCL's internal per-device caches. It depended on timing: some runs hung and others didn't, on the same build.
Cause. Several of XCL's helper pipelines are cached per device with a check-then-insert:
The failing sequence:
insertreplaces the first thread's pipeline. The cache held the only lasting reference, and D3D12 does not keep a pipeline alive for the command lists that use it.It only happens when the first uses come from several threads within the same millisecond, which is what a title's world entry does.
Evidence.
Fix. The first pipeline put in the cache wins, and every thread uses that one. A pipeline built at the same moment on another thread is dropped before any list records with it.
Upstream.
nvidia-dev(eae01502and later) has the same pattern inscale_indirect_pipeline(bind.rs, theinsert(key, (rs.clone(), pso.clone()))after building the scale PSO). It is used by two-pass ExecuteIndirects of more than one record, whose first uses at world entry also come from several threads. We have not measured whether it causes any of the world-entry hangs reported here, but it is a use-after-free of a pipeline whenever it races, and the fix is two lines.What it unlocked here: two-pass mesh draws recorded in batches, on by default. The title issues ~3,700 single-record
ExecuteIndirect(DispatchMesh)calls a frame. Each one becomes a clamp, a compute pass and a mesh pass, with full drains in between. We now defer up to 32 such calls per list and record them together:The batch is recorded before any other list call that could change what it draws (a per-slot hook). Calls whose console program writes memory other than its records are recorded as a batch of one. In this cell view, 5.2 M calls went into 290 k batches (~18 a batch).
Not yet 0: 0.06 % of the calls (~3,300 in 5 min) are still left without room in a batch's rounds, plus a few cut at the last round (one call at the clamp's 2^22-group cap). The fix in progress sizes the rounds by the list's buffer and caps the largest call first. Single-record calls split into 4 mesh groups still take the old per-call path.
AI-assisted.
@KDenKC on GitHub · 2026-11-27 09:14 UTC · original
On entry 6: we went through every pipeline and root-signature cache in
crates/xcl/srcatmain623d02e4andnvidia-dev3f39671d(13 caches).scale_indirect_pipelineis the only one with the race, and it's onnvidia-devonly.mainhas no copy of it.bind.rs~1835-1853 at3f39671dbuildsrsandpsooutsideCACHE's lock, then callsinsert(key, (rs.clone(), pso.clone())), so a second racing build replaces the first.prepare_scaled_args, keeps only raw pointers:Rewrite { rs: rs.as_raw() as usize, pso: pso.as_raw() as usize, .. }, under the comment "the pair is the device's for good:scale_indirect_pipelinekeeps it". Its ownrs/psohandles drop at return. So once the replacement drops the first pair, any list recorded with thatRewritepoints at a freed PSO and root signature. Yourentry(key).or_insert(made)makes the comment true.OnceLock: dispatch-chain whole forms, the clamp, the compositor, the shaderPipelinessignatures, the indirect guard, scatter, andABI_RS_SAMPLERS.ABI_RSkeeps the first one withcompare_exchange.DEPTH_BIAS_PSOSre-checks under the lock.Weak, while each shell keeps its ownArc.Not measured: how often the race fires at world entry, or whether it accounts for any of the reported world-entry hangs on
nvidia-dev.AI use: Gemini (Antigravity) went through the caches; Claude Code (Claude Opus 5.5) checked the vulnerable site and its caller and wrote this comment.
@claudetools-gh on GitHub · 2026-11-27 09:46 UTC · original
@KDenKC thank you, that is a careful review. On each point:
Entry 6: good to have the full sweep. One vulnerable site,
nvidia-devonly, with the caller keeping raw pointers, makes it a clear two-line fix there.Entry 2: agreed, the first patch only fixed
div_fixup's special values. Since then, on our tree:v_div_scale_f32returns NaN with flag 0 whennordis ±0, as in the ISA. A pair of non-zero subnormals is prescaled by2^64in both passes with the flag kept at 0, since the factor cancels in the quotient. That covers yourn = d = 2^-130case: both become normal and the quotient is 1.v_div_fmas_f32with VCC uses tinygrad's rule:2^64whenexponent(S2) > 127, else2^-64.div_fixup's last resort, whenqcomes out 0, NaN or Inf for finite non-zero operands, divides normalised magnitudes and puts the exponent and sign back.GPU tests run in both backends, with and without
XCL_DIRECT_DXIL=1. Your second case stays open: we still scale after the rounded FMA, not inside it, so2^-126 * 2^-30 + 0still gives 0. A hardware fixture for the three opcodes would settle the rest. If you have one, we'll run it through our direct-DXIL path on an RTX 5070 Ti and post the bits. Entry 2 gets updated once this has been measured in the game.Entry 1: noted. On
mainit is the opt-in watch trap of #2934. The gap itself isnvidia-dev's7c18bc41.AI-assisted.
@KDenKC on GitHub · 2026-11-27 10:08 UTC · original
@claudetools-gh thanks. On the fused case: our local direct-DXIL version applies the
±64scale before the single rounding ofv_div_fmas_f32, rather than scaling the rounded FMA. Its raw-bit GPU test withS0 = 2^-126, S1 = 2^-30, S2 = 0, VCC set, expects2^-124. It passes on an RTX 5090 (split wave64) and on an AMD RDNA2 iGPU (native wave64), and fails onmain. The other fixtures pass the same way:n = d = 2^-130,0/0, the full LLVMfdiv.f32sequence against the host's IEEE quotient. We don't have AMD hardware vectors beyond tinygrad's tests. It isn't public yet. Once it's posted, the fixture values are in its tests for your RTX 5070 Ti run.AI use: Claude Code (Claude Opus 5.5).