Skip to content

UMA: cap the coherent window at RAM/8 below 24 GB of RAM - #3068

Merged
Prime1997 merged 1 commit into
xcl-dev:mainfrom
RodrigoTorreao:pr/coherent-auto-cap
Nov 28, 2026
Merged

Prime1997 merged 1 commit into
xcl-dev:mainfrom
RodrigoTorreao:pr/coherent-auto-cap

Conversation

@RodrigoTorreao

@RodrigoTorreao RodrigoTorreao commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What is in it
The coherent window is pinned in system RAM (Windows counts it as the process's shared GPU memory). On 16 GB machines its default 4 GiB leaves the title paging. coherent_hint_for now caps it at an eighth of physical RAM (at least 1 GiB) when the machine has less than 24 GB. With 24 GB or more nothing changes.

  • XCL_COHERENT_MB still wins over the cap.
  • XCL_COHERENT_AUTO_CAP=0 turns the cap off.
  • One unit test covers the cap math: 16 GiB gives 2 GiB, 6 GiB gives 1 GiB, and 32 GiB or unknown RAM gives no cap.

Tested
RX 6750 XT 12 GB, 16 GB RAM, Windows 11 26200, driver 32.0.21045.29003. The retail title ran on Series X (anaconda) with a warm cache and XCL_PREPARE=0, 8 minutes per side, with A pressed automatically. GPU memory comes from Windows' per-process counters.

main 623d02e this PR
coherent window 4095 MB 2027 MB
GPU shared memory, peak / average 7.84 / 5.06 GB 6.64 / 5.29 GB
available RAM, min / average 0.00 / 0.99 GB 0.54 / 2.92 GB
draws (skipped) 18,490 (0) 20,679 (0)
end no crash, 480 s no crash, 480 s

The average shared memory stays about the same because VRAM over-commit spills into shared memory. The gain is free RAM: the title stops pushing the machine to 0 MB available.

On amd-dev, the same cap skips about 2 % of two-pass ExecuteIndirect draws whose arguments fall outside the smaller window (bind.rs, reported in #2996). On main that path does not exist, and 0 draws were skipped.

Regression run
Same title, XCL_PREPARE=0, separate empty caches. main ran with its own scripts/smoke.ps1.

main 6089122:

xcl-smoke v1
commit: 6089122a1c96dff16e93b6fdf04c8ed20cfb6102
gpu: AMD Radeon RX 6750 XT
title: 2a4aef2e
seconds: 60
exit: 0x0
frames shown: 1560 (PresentX 1560)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14014 MB

This PR:

xcl-smoke v1
commit: abf7e177804f2ae7daac44d19e6b0fa081def6c0
gpu: AMD Radeon RX 6750 XT
title: 2a4aef2e
seconds: 60
exit: 0x0
frames shown: 1348 (PresentX 1348)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14370 MB

Frames are 86 % of main's, and peak commit is 103 %. Both runs hold 60 presents per 2 s at the end, so the frame gap comes from startup timing.

Full suite (cargo test --workspace --no-fail-fast -- --test-threads=4):

  • main: 1464 passed, 1 failed, 47 ignored.
  • PR: 1465 passed, 1 failed, 47 ignored. That is main plus the new test.

The one failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, and it fails on both sides. The first PR suite run also failed the 3 e2e tests because xcl_testtitle.exe had not been built in that target dir. After cargo build --workspace, e2e passes 4/4.

Not tested

  • NVIDIA and Intel GPUs.
  • Machines with 8 GB of RAM (the cap is 1 GiB there).
  • Titles other than this one.

AI use
Code, measurements and text were made with Claude Code (Claude Opus 5.5). I reviewed the change and ran every test on the hardware above.

🤖 Generated with Claude Code

The coherent window is pinned in system RAM. On a 16 GB machine its
4 GiB default leaves the title paging; an eighth of RAM (at least
1 GiB) keeps it usable. XCL_COHERENT_MB still overrides it, and
XCL_COHERENT_AUTO_CAP=0 turns the cap off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RodrigoTorreao
RodrigoTorreao marked this pull request as ready for review November 27, 2026 22:37
@RodrigoTorreao

Copy link
Copy Markdown
Contributor Author

Help wanted: test reports from machines with less than 24 GB of RAM, on any GPU.

The change only acts below 24 GB of RAM. With 24 GB or more it is a no-op, which is also worth confirming.

  1. Build main and this branch. Run the same title on each for the same time, with a warm cache and XCL_PREPARE=0.
  2. The log line console code so far: ... coherent X/Y MB should show Y ≈ RAM/8 on this branch (4095 on main).
  3. Post the available RAM (min / average), GPU shared memory, draws and skipped draws, and how each run ended. Running with XCL_COHERENT_AUTO_CAP=0 on this branch should match main.

AI-assisted (Claude Code with Claude Opus 5.5).

@SlopTart

Copy link
Copy Markdown

Wine A/B across the RAM line: the RAM/8 cap does not change either uma_driver red.

We run xcl's CPU-side suite under Wine on two machines that sit on opposite sides of your 24 GB threshold:

  • 96 GB RAM rig: AMD Ryzen 9 9900X, RX 7900 XT 20 GB (Navi 31), Arch, kernel 7.2.15, Mesa 26.2.5 RADV, wine-11.0 (Proton files), rustc 1.94.0. Above 24 GB, so the cap never engages.
  • 16 GB RAM box: Intel i5-10600K, GTX 1070 8 GB, driver 550.163.01, Debian 13, wine-10.0, xvfb. Below 24 GB, so per your math the coherent window is capped to 2 GiB here.

Tested

Baseline main at 2c717a04 and this PR head abf7e177 (exact sha checked against the API at run time), same worktree per machine, cargo test --release --locked -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=2 --skip gpu:::

lane tree suite failed list
96 GB rig main 2c717a04 618 passed / 4 failed uav-clear, sparse tile (load flake), grooming..., xma2 (FAudio)
96 GB rig PR abf7e177 617 passed / 4 failed same four
16 GB box main 2c717a04 617 passed / 5 failed uav-clear, write_buffer_immediate..., failed_restore..., grooming..., xma2
16 GB box PR abf7e177 616 passed / 5 failed same five

Solo runs of the two uma tests, 3 each, same trees:

  • grooming_leaves_a_window_under_1_gib_only_its_hole: FAILED 3/3 on both lanes on both trees, identical signature uma_driver.rs:349:9, left: Some(1), right: Some(0) (rig geometry line still hole 0x7fffde000000, stretch 0x8fff0000..0xbfff0000).
  • failed_restore_stops_before_importing_an_unbacked_window: FAILED 3/3 on both lanes on both trees. 16 GB box keeps its signature uma_driver.rs:304:9, left: Some(1), right: Some(130088963); the 96 GB rig keeps left: 0, right: 20381696.

What this adds

The cap is live on the 16 GB lane (2 GiB window by your own table) and neither red moves at all: same asserts, same values, same failure counts in-suite and in solos. So on Wine these two reds are not coherent-window-sizing reds - the cap helps real titles page less, but the test failures survive it. If you expected one of the Wine reports in #2977 to be fixed by this PR, it will not be, on either RAM side.

Separate observation while baselining (not caused by this PR): on the 96 GB rig, failed_restore... is green in-suite at 2c717a04 (it was red in-suite at 06f90c19) but still fails solo 3/3, now fast (1.5-1.7 s instead of 6-8 s). That flip landed somewhere in the evening merge wave (#3043 DXIL release is the suspect, not bisected). The 16 GB box is red both in-suite and solo throughout.

Not tested

Native Windows. Real title runs / paging behavior under the cap. XCL_COHERENT_MB / XCL_COHERENT_AUTO_CAP=0 overrides. RDNA4.

AI use

Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

@andrewDoing

Copy link
Copy Markdown
Contributor

I found a test-isolation issue on exact head abf7e177804f2ae7daac44d19e6b0fa081def6c0. The PR documents XCL_COHERENT_AUTO_CAP=0 as the opt-out, and the cap function correctly returns None with it set. However, the stock unit test assumes it is unset.

Using one freshly built exact-head test binary in separate processes, I ran gpu::uma::auto_cap_tests::low_ram_machines_get_an_eighth_of_their_ram:

  • Variable unset: 1 passed.
  • XCL_COHERENT_AUTO_CAP=0: 1 failed, actual None versus expected Some(2147483648).

Only the initial process environment differed. Passing the enabled/disabled choice into the calculation (with a separate opt-out assertion) would make the test deterministic without mutating shared process environment. This is a test failure under a supported setting; I did not observe a production memory failure or run a title.

AI use: OpenAI Codex with GPT-6.2 Astra ran the checks; Codex reviewed and prepared this report.

@Prime1997
Prime1997 merged commit 392db2c into xcl-dev:main Nov 28, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants