tests: serve GPU draw cases from one offscreen_check device #2758
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2766"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T06:50:32Z.
Part of #448
What this unblocks: the GPU draw checks create the D3D12 device once per test instead of once per case, which is where #448 measured most of the time (about 0.25 s of start-up per launch against about 0.03 s per case on a real card with the debug layer on).
Source: Microsoft D3D12 documentation,
D3D12CreateDeviceandID3D12Devicelifetime; earlier code of this repo (tests/offscreen_check draw cases and their CTest entries in CMakeLists.txt).What changed
offscreen_check <warp|hardware> --serve(tests/offscreen_check.cpp): runs any other operation, case after case, on the one device it already created. One case per stdin line, the operation and its operands separated by tabs, exactly the arguments that follow the adapter name in a one-shot call. Each case goes through the same argument validation, capability gate, debug-layer check and exit-code mapping as a one-shot call (0, 1, 77, 2), and its stdout and stderr text is what the one-shot call prints. Both streams end the case with a marker line so the client can split the text per case; the debug messages are cleared between cases; a removed device ends the loop after answering.tests/gpu_case_runner.py:run(renderer, adapter, args)has the signature and result ofsubprocess.run([renderer, adapter, *args], capture_output=True, text=True), but starts one--serveprocess per renderer and adapter and sends the case to it. The adapter banner is repeated in front of every case, so a check that looks fordebug_layer=enabledanddebug_errors=0 debug_warnings=0sees it in each case, as in a one-shot call. Only a server that cannot start (an olderoffscreen_checkwithout--serve, no adapter,X2W_FLAT_SERVER=0) falls back to the one-shot call. Once a case has been sent, a renderer that dies, does not answer within one deadline or answers with the wrong case number gives a FAILED verdict for that case and is never run again, so a crash cannot turn into a pass; both reply indices are validated and the renderer is ended as a whole process group.startup_flat_param_check.draw(imported by 50 checks, among themstartup_gfx2hlsl_f16_alu_draw),startup_gfx2hlsl_f32_sdwa,startup_gfx2hlsl_f32_nanandstartup_image_sample_b. Their cases, references and controls are unchanged.startup_flat_param_check.compile_hlslnow routes DXC compiles through the opt-inX2W_DXC_CACHEcache thatpixel_aot_checkandcompute_store_checkalready use.tests/gpu_case_runner_check.py(new,gpu_case_runner): a fakeoffscreen_checkthat speaks the protocol checks per-case text and exit codes, the banner with every case, skip (77), a renderer without--serve, a crash after the handshake (failed verdict, case not run again), a silent renderer (one deadline), a wrong reply index, a launcher child that keeps the pipes open, a second-case debug warning, andX2W_FLAT_SERVER=0.Builds on the batching work in #2635, #2654, #2615 and #2690 and the compiler reuse in #2711 (credit to RavenCurseBurg), and on the DXC cache of #448. Those make one test launch fewer processes by batching its references; this adds the same saving for every check that still starts a process per case, without changing any test's cases.
Why it is safe
Every case of the four adopted checks was run twice on Windows Server 2025 WARP, once through the served device and once through the old one-shot call, and compared (exit code, stdout, stderr; the banner is part of each served case and was compared too):
Each control changes one bit of the expected words (or the first byte of the reference file) of every seventh case and runs it through both paths.
Time (Windows Server 2025 WARP, idle host, one run each, DXC cache off)
f16_alu_drawstill spends most of its time compiling one vertex shader per case with DXC and FXC one after the other; that is the next step (compiling in parallel), not part of this change. The saving on a real card is larger, because the debug layer makes each launch more expensive.What stays the same
Only
--startup-flat-param,--startup-pixel-wordsand--startup-image-2d-array-mipscases changed path; every other operation and every check that is not listed above is untouched.offscreen_check --self-teststill validates the operation table, and--serveitself is listed there like any other operation.Verification
python3 -B tests/gpu_case_runner_check.py: all tests OK (Linux).python3 -B tests/startup_flat_param_check.py: controls OK (Linux).offscreen_checkwith this change andctest -R 'gpu_case_runner|startup_gfx2hlsl_f16_alu_draw|startup_gfx2hlsl_f32_sdwa|startup_gfx2hlsl_f32_nan|startup_image_sample_b_(warp|hardware)|startup_flat_param': 15/15 passed.(times are the summed
offscreen_checkcalls only, not compiles.)ctestof the same 15 tests: 15/15 passed.cmake --build --preset <dev|release> --target offscreen_checkthenctest --preset <dev|release> --no-tests=error -R "gpu_case_runner|startup_gfx2hlsl_f16_alu_draw|startup_gfx2hlsl_f32_sdwa|startup_gfx2hlsl_f32_nan|startup_image_sample_b|startup_flat_param|draw_skip" -V(gpu_case_runner, startup_flat_param_{controls,warp,hardware}, startup_image_sample_b_{controls,warp,hardware}, startup_gfx2hlsl_f32_nan{,_warp,_hardware}, startup_gfx2hlsl_f32_sdwa{,_warp,hardware}, startup_gfx2hlsl_f16_alu_draw{controls,warp,hardware}, startup_gfx2hlsl_draw_skip).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T07:01:22Z.
I reproduced the Linux failure on this head. The f32_nan and f32_sdwa cases now call gpu_case_runner.run, so the existing subprocess.run mock misses them and Popen tries to execute the fake renderer. In startup_gfx2hlsl_draw_skip_check.py, set renderer_runner = getattr(module, "gpu_case_runner", module.subprocess) and patch renderer_runner.run. On Windows Python 3.12 this kept all 18 existing subcases green, including failure-before-skip = 1 and clean skip = 77.
The five runner tests also pass here, but emit ResourceWarning for unclosed pipes and a live child after fallback. Please close the stdio handles and wait for the process on every exit, including failed handshake and dead-server restart. The runner test should verify cleanup before calling the one-shot fallback.
Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-26T07:43:21Z.
I will check the updated served renderer on native Windows D3D12 on the Intel UHD 770 and RTX 4060, with WARP as a control. I will compare the one-shot and served routes on the same executable, including wrong expected values followed by valid draws, and report the exact head and timings here.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T07:50:04Z.
Thanks for the repro and the exact fix.
6c2e55d1b.startup_gfx2hlsl_draw_skip_check.pynow also patchesgpu_case_runner.run, next to the existingsubprocess.runpatch, so the 18 subcases (failure-before-skip = 1, clean skip = 77) stay green. I kept both patches instead ofgetattr(module, "gpu_case_runner", ...)because the same loop also covers modules that still callsubprocess.run.aa6c9bd71. Every exit of a served process (failed handshake, skip 77, dead server and its restart, close at exit) now waits for the process, joins the two reader threads and closes stdin, stdout and stderr. New runner testtest_every_exit_leaves_no_process_and_no_open_pipechecks that each of those servers has exited and has all three pipes closed, before the one-shot fallback result is used; I also fixed the test's own cleanup order, which emptied the server table before closing the servers.python3 -B -W error::ResourceWarning tests/gpu_case_runner_check.py: 6 tests OK; the four adopted checks also run clean with that flag.@RavenCurseBurg, thank you for checking native Windows D3D12 on the Intel UHD 770 and RTX 4060. The head to test is
aa6c9bd71.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T08:28:09Z.
Windows 11 build 26200, Python 3.12, exact
7e0a4e39:python -B -W error::ResourceWarning tests/gpu_case_runner_check.pyfailed 2/9. The crash reported a 300 s timeout immediately, and the 2 s hang case returned after 60.06 s. The separate draw-skip ordering test passed.I isolated two causes. The Windows fake runs through a .cmd parent. Killing that parent leaves its sleeping Python child holding stdout/stderr, so cleanup blocks until the child exits. Launching the fake Python renderer directly made the 2 s hang test pass, but the crash still raced EOF against Popen.poll(). With the direct child plus a bounded
self.proc.wait(timeout=max(0.0, deadline - time.monotonic()))when the reply is missing, all 9 tests passed with ResourceWarning promoted to an error. The exit-code check and the no-replay assertions stayed in place. Please make the Windows fake a direct child of the runner and preserve the one shared deadline when collecting the process status.Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-26T08:34:50Z.
Native Windows comparison at
7e0a4e39: all 2,694 one-shot/served pairs matched on exit code, full stdout and full stderr, including the repeated adapter banners. The comparison covers the four adopted checks on WARP, Intel UHD 770 and RTX 4060. The runner stayed attached to the live server throughout each suite.Each of the 62 additional wrong-value calls per adapter returned 1 through both routes and printed the same mismatch; the immediately following valid draw returned 0. For timing, one-shot/served summed renderer call times in seconds were WARP 147.86 / 14.99, UHD 770 524.30 / 36.81, RTX 4060 454.01 / 53.20. The three suites of adapter measurements ran concurrently on the same host, with alternating call order and shader compilation outside the timer. These are single-run measurements under load.
Windows 11 build 26100.9711, in-box D3D12, WARP 10.0.26100.9711, Intel 32.0.101.5973, NVIDIA 32.0.15.9579. The debug layer was unavailable. The local Zig 0.13/Clang build included the PR's actual service loop, argument and diagnostic paths, the three adopted operation handlers, desktop GPU setup and D3D12 draw implementations. The local executable selected those operations and explicitly flushed output at one-shot exit for MinGW. All four suites used both DXC and FXC. The comparison script also takes a standard full
offscreen_check.exe:The separate process-lifecycle unit suite reproduced the two Windows failures already reported above, including the 2-second case returning after 60.43 seconds. The device comparisons above all completed. AI-assisted with Codex.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T08:42:58Z.
Thank you both, this is exactly the data I needed.
@R0Y00: both causes fixed in
069f17228..cmdor shell parent holding the pipes after a kill.proc.wait(timeout=max(0, deadline - now))) before reading its exit status, so a crash reportsexited (code 3)and not a timeout. One deadline per case stays.-W error::ResourceWarning, and the four adopted checks plus the draw-skip check pass. I cannot run Windows Python 3.12 here, so please re-runpython -B -W error::ResourceWarning tests/gpu_case_runner_check.pyon069f17228.@RavenCurseBurg: thank you for the 2,694 matching pairs on WARP, UHD 770 and RTX 4060, wrong-value controls included. Your numbers are for
7e0a4e39; the runner changed only in the process handling since, not in the protocol, the banners or the verdict mapping.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T09:28:06Z.
Rechecked
069f1722on native Windows 11 build 26200 with Python 3.12.python -B -W error::ResourceWarning tests/gpu_case_runner_check.pynow passes 9/9, including the 2 s deadline and crash exit-code tests.startup_gfx2hlsl_draw_skip_check.pyalso passes. This resolves my two Windows runner findings. Raven's 2,694 paired GPU results above were on the preceding head; this run covers the revised process-handling tests.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T09:50:16Z.
@R0Y00: thank you for the native Windows re-check of
069f1722(9/9 and the draw-skip check).Gate status from our independent reviewer: code gate PASS on
069f17228. Win2025 dev and release 17/17 each (gpu_case_runner passes there in 13 s), served-versus-one-shot compared on every case of the four adopted checks with the banner included, wrong-value controls included: 0 mismatches. A RunPod run showed one intermittent 1800 s timeout ofstartup_gfx2hlsl_f32_sdwa_warpon that head; it did not repeat on the next head, and the re-gate on that head is running.The head is now
43360b0e9: the client ends the served renderer with an explicit--endline before closing stdin (the service loop stops on it), because a Wine launcher may not pass the end of stdin on. An older renderer answers that line with exit 2 and still ends at the end of stdin. Nothing else changed in the protocol, banners or verdicts.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:52:39Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
f5747cc0bfℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:36:23Z.
Independent review of head
f5747cc0b(served GPU draw cases): PASS.Verification:
ctest --no-tests=error -R 'gpu_case_runner|startup_gfx2hlsl_f16_alu_draw|startup_gfx2hlsl_f32_sdwa|startup_gfx2hlsl_f32_nan|startup_image_sample_b|startup_flat_param|draw_skip': gpu_case_runner, startup_flat_param_{controls,warp,hardware}, startup_image_sample_b_{controls,warp,hardware}, startup_gfx2hlsl_f32_nan{,_warp,_hardware}, startup_gfx2hlsl_f32_sdwa{,_warp,hardware}, startup_gfx2hlsl_f16_alu_draw{controls,warp,hardware}, startup_gfx2hlsl_draw_skip.python3 -B tests/gpu_case_runner_check.pypasses; mutating the failed verdict to a pass, dropping the index check or dropping the per-case banner each fail the check.--endline is still missing; closing stdin also ends the server in the fake renderer, so the line itself is covered only by the real Wine run.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:36:44Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
f5747ccℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:52:39Z.
Code review location:
tests/gpu_case_runner.py; line 179When a renderer writes a diagnostic and then crashes or times out before its end markers, this returns only the generic
_Lostmessage. For crashes,case()has already consumed the unmarked stderr chunk before raising; for timeouts, this skips draining while the renderer is alive and never recovers output after killing it. The empty stdout also drops the cached adapter/driver/debug-layer banner on first-case failures. A fake renderer printing an error before exiting with code 3 reproduces the diagnostic loss. Preserve the collected chunks, post-termination output and banner in the failed result.AGENTS.md reference: AGENTS.md:L95-L96
Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:52:39Z.
Code review location:
tests/gpu_case_runner_check.py; line 93When
X2W_FLAT_SERVER=0is set to exercise the supported one-shot path,R.SERVER_OFFis alreadyTrueat import and this fixture never overrides it. The served-path tests consequently execute one-shot calls and fail—for example,test_served_cases_carry_their_own_text_and_exit_codereceives the unexpectedONESHOTprefix. Since the runner check is registered in CMake, running the suite with the opt-out produces spurious failures even though the fallback works correctly. Save and restoreR.SERVER_OFFin the fixture and set it toFalsefor the served-path tests.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:52:39Z.
Code review location:
tests/gpu_case_runner_check.py; line 197In a Linux container whose PID 1 does not reap orphaned children,
_close_all()successfully kills the grandchild but its PID remains as a zombie.os.kill(pid, 0)still succeeds for that dead process, so this loop reachesself.fail()and the runner check rejects correct cleanup. This reproduces in the current container, where the child has stateZ; all 10 tests pass under a reaping harness. Check whether the child is actually running or arrange for the fixture to reap it instead of requiring the PID to disappear.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:24Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:28Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:31Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:24Z.
Code review location:
tests/gpu_case_runner.py; line 179Fixed in
f01ff5b6c(head619ae700after merging main): a lost case now returns the adapter banner, what the renderer printed for the case before it was lost, and everything still queued after the process group is killed. New test test_a_crash_keeps_the_diagnostics_and_the_banner, and the silent-renderer test checks the same; both failed before the change. Ran tests/gpu_case_runner_check.py: 11/11 OK.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:28Z.
Code review location:
tests/gpu_case_runner_check.py; line 93Fixed in
f01ff5b6c: the fixture patches R.SERVER_OFF to False for every test and restores it; the opt-out test patches it to True. Ran tests/gpu_case_runner_check.py with X2W_FLAT_SERVER=0 in the environment: 11/11 OK (6 failures before the change).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:31Z.
Code review location:
tests/gpu_case_runner_check.py; line 197Fixed in
f01ff5b6c: the check treats a killed child that nobody reaped (state Z in /proc) as gone, so it no longer depends on PID 1 reaping orphans. Ran tests/gpu_case_runner_check.py: 11/11 OK.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:37:52Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
619ae7009534dcbfce40cfd60d309bfe2ac885fd:--preset dev):cmake --build --preset dev --target offscreen_check -- -j 2):54.60s(configure2.52s)ctest --preset dev -R '^gpu_case_runner$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (16.54s:gpu_case_runner16.38s)/O2(--preset release):cmake --build --preset release --target offscreen_check -- -j 2):53.76s(configure2.62s)ctest --preset release -R '^gpu_case_runner$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (15.27s:gpu_case_runner15.06s)tests/gpu_case_runner_check.pyok (14.9s),tests/startup_flat_param_check.pyok (0.2s),tests/startup_image_sample_b_check.pyok (0.3s),tests/startup_gfx2hlsl_f32_nan_check.pyok (5.5s)sccache: 247/280 hits; wall156.1stested:
619ae700via fetch (pull/2766/head, no patch)AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T18:18:54Z.
Review: APPROVED
Independently reviewed
619ae700integrated overmain429f11d5(treea8658aad, clean merge).What I traced. I read the
--serveloop intests/offscreen_check.cpp. Each case goes throughresolve_cliandrun_operation_specon the existing device, the same path as a one-shot call. Stored debug messages are cleared after each case, and a removed device answers its case and then ends the loop.On the client side (
tests/gpu_case_runner.py):What I ran. I built
offscreen_checkindevandrelease. I then ran every CTest entry whose script importsgpu_case_runnerorstartup_flat_param_check, which is 305 tests: 122_hardware, 122_warp, plus the controls and Python checks. The non-hardware ones ran with-j 8and the hardware ones with-j 1:ctest --test-dir out/build/<preset> --no-tests=error -j 1 --output-on-failure -R '^(<the 122 _hardware names>)$'/O2: 305/305 passed, no skips.startup_slot67_indirect_dispatch_{warp,hardware}. It launchesstartup_stream_consumer, which I had not built in that tree, through plainsubprocess.run, and it does not use the runner. It only matched my name filter by prefix.debug_layer=enabledappears in all 72 served cases ofstartup_image_sample_b_hardware, so the banner is repeated per case as described.Runner check.
python -B -W error::ResourceWarning tests/gpu_case_runner_check.pypassed 3 of 3 runs: 11 tests, 8.5 s each. The one skip is the POSIX-only launcher-child test.Mutant. I made a lost case return 0 in
_failed. That fails four runner tests: crash after the handshake, crash keeps diagnostics, wrong case number, and silent renderer. Onmain429f11d5,gpu_case_runneris not registered.git diff --checkis clean.Speed on a real card, Release, debug layer on, one run each:
X2W_FLAT_SERVER=0startup_image_sample_b_hardwarestartup_gfx2hlsl_f32_nan_hardwarestartup_gfx2hlsl_f32_sdwa_hardwareNon-blocking finding. The server reads a case with
fgetsinto a 64 KiB buffer, so a longer line is read as two cases. Both halves are answered with consecutive numbers, so the client's index check still matches, and every later verdict shifts by one case.On WARP, through
gpu_case_runner.runwithout/build/dev/offscreen_check.exe, I sent six calls in order:--compute-root--compute-root <70,000-char arg>--compute-root--compute-root--bogus-op--compute-rootThey returned
0, 2, 2, 0, 0, 2where one-shot semantics give0, 2, 0, 0, 2, 0. The invalid operation came back as a pass.No current caller can reach this. Every adopted case was a one-shot command line, which Windows caps at 32,767 characters; a one-shot call of the 70,000-char case fails with
WinError 206. But the served path now accepts lines that the one-shot path rejects, so a future caller could hit it silently. Either fix would close it: send lines of 64 KiB or more through the one-shot call, which fails loudly, or read whole lines on the server, for example withstd::getline. This is not a reason to hold the PR.Verdict: approve on
619ae700.Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; debug layer on.
CI:
Build and test on Windowspasses on619ae700. All review threads are resolved.This reply was AI-assisted.