Repository navigation
Conversation
…TE-WARMUP-FREE) A queue submission waited at the compile gate for every pipeline create in the driver, warm-ups included. On a cold boot (HasiKe, RTX 2070 SUPER, ubiquitarianism#2233) the title crawled at about one submission a second behind 290 s of serial warm-ups; with the gate off it ran at about 100 frames a second. A compile worker now marks its speculative jobs (warm-ups, prewarms, the checkpoint) with the thread-local compile_job_speculative, and DriverTurn passes that to SubmitMutex::CompileTurn. A submission waits only for the demanded creates in the driver. A warm-up still never enters while a submission is in the driver or waiting at the gate, and at most LEONIDA_COMPILE_GATE_WARMUP_MAX (default 1) warm-ups are in the driver at once, so the creates beside a submission stay bounded. LEONIDA_COMPILE_GATE_WARMUPS=1 restores the old behaviour; LEONIDA_COMPILE_GATE=0 still turns the gate off. Tests: submit_mutex_test gets warmups_do_not_hold_the_gate (a submission passes a warm-up, still waits for a demanded create, the warm-up cap, no warm-up during a submission, the old policy, the settings); d3d12_compile_pool_test checks which jobs run as speculative. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
One boot with this PR and the compile gate on: RTX 4070 SUPER (12 GB), NVIDIA 621.01, Windows 11, 64 GB. Counts only. Tree:
AI-assisted (Claude Code). |
|
Second run with this PR, the same recipe and the gate on, with
AI-assisted (Claude Code). |
|
@Tyrannys, here is the cold boot you asked for, with the gate on, on the RTX 2070 SUPER. AI-assisted (Claude Code). Tree: Setup: NVIDIA 616.56, Windows 11 Pro 26300, my own 1.0.2.1 package. One binary for both runs, A/B via
So, on this card:
Neither boot reached the world. My input script only enters it at 314 s. So this says nothing about the world-load hang. That hang is a separate problem, a VS-as-mesh-shader draw that never finishes on the GPU (#1608, follow-up), and it also happens with the gate off. The cold boot on this machine goes from unusable to normal speed, so this PR looks like a clear win to me. |
|
I checked The production switch has no test. Only one line passes "this create is speculative" to the gate in the runtime:
Docs that no longer match:
The risk is stated well. A submission can now be in the driver beside one warm-up create. That is the NVIDIA 630.20 case the gate was added for. It is capped at one at a time ( The code reading behind these points was done with a second agent and checked line by line before writing this. AI-assisted (Claude Code, with Antigravity / Gemini 4 Neon). |
…te-warmup-free Brings ubiquitarianism#2233's one-build-per-PSO fix and current main. Conflicts in docs/d3d12_vulkan.md and d3d12_compile_pool_test.cpp's header, both kept. Also, from qhukz13's review of ubiquitarianism#2275: - test_a_driver_turn_passes_the_speculative_flag_to_the_gate: a DriverTurn made on a speculative job's thread lets a submission pass, and holds it otherwise. It fails when DriverTurn drops the flag. - Docs say what is affected today: compute warm-up creates (graphics builds never pass the gate; the checkpoint makes no create). The LEONIDA_COMPILE_GATE row now describes both 0 and 1. - test_a_checkpoint_sees_a_demand_that_started_during_it waits for the pool to be idle before its last check (it raced the job's removal). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…test's last check The demanded job leaves the running list only after its function returns, so has_compile_waiter() could still see it right after the log said it had finished (1 failure in 10 runs). Found while merging this into ubiquitarianism#2275. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@qhukz13 thank you for checking this, and for finding the untested line. All three points are addressed; current
After the merge: @HasiKe thanks again for the A/B on the RTX 2070 SUPER (74,012 against 745 submissions in 300 s, no device loss). That is the measurement this needed. AI-assisted (Claude Code) |
…warmup-free # Conflicts: # docs/d3d12_vulkan.md
…-warmup-free Main now has ubiquitarianism#2233 (the compile pool) and the adaptive compile gate (ubiquitarianism#2412, ubiquitarianism#2462). The warm-up-free gate is ported onto it: a speculative create is an InDriver entry flagged speculative that submissions do not wait for, at most warmup_max in the driver at once, except one of a kind whose verdict is driver_holds, which is waited for as a demanded create is. submit_mutex_test checks that case too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged main (ec91d69, with #2233 and the adaptive gate #2412/#2462; warm-up rule ported onto it) in at d61c909; submit_mutex, d3d12_compile_pool, d3d12_compile_teardown, d3d12_compile_teardown_one_worker, d3d12_pipeline_workers, d3d12_pipeline_workers_eager and pipeline_workers pass. AI-assisted (Claude Code) |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed and tested at d61c90965 (merged cleanly onto main ec91d695c).
The warm-up-free compile gate mechanics and test coverage in submit_mutex_test / d3d12_compile_pool_test are clear and well structured, and both suites pass. I found two behavioural edge cases on current main (plus one minor API guard) noted inline:
classic/auto: classic/LEONIDA_COMPILE_GATE=1bypass: becauseverdict_[kind]stayspendingwhenadaptive_isfalse,if (c.speculative) return false;inis_blocking()still lets submissions enter beside compute warm-ups even whenautocalibration deliberately pickedclassicbecause the driver holds submissions (e.g. NVIDIA 630.20) or whenLEONIDA_COMPILE_GATE=1is requested.- Interaction with
#2260graphics/mesh prewarm onmain:PipelineState::prewarm_queuesubmits graphics/mesh prewarms with non-zero priority (compile_job_speculative = true), whileautocalibration only probes a compute pipeline. On drivers where compute does not hold submissions (auto-->adaptive) but mesh creates do (e.g. 621.40),verdict_[graphics]startspendingand submissions enter immediately beside a mesh prewarm. - Minor:
set_warmup_policy()does not clamppolicy.max >= 1(passing0deadlocks a speculative create).
Verified locally on Windows 11 (MSVC 19.44.35230.0, Ninja Release):
submit_mutex: passed (42.26 s, including the warm-up and holding-kind cases)d3d12_compile_pool: passed (2.10 s, includingcompile_job_speculativeandDriverTurnchecks)scripts/check_no_game_data.pyandgit diff --check: clean
AI-assisted.
| bool is_blocking(const InDriver& c) const { | ||
| if (kind_off(c.info.kind)) return false; | ||
| if (verdict_[std::size_t(c.info.kind)] == GateVerdict::driver_holds) return c.seq > held_overdue_through_; | ||
| if (c.speculative) return false; // a warm-up, of a kind not known to hold submissions |
There was a problem hiding this comment.
In classic mode -- including LEONIDA_COMPILE_GATE=auto when startup calibration deliberately picks classic because the driver holds submissions behind compute creates (e.g. NVIDIA 630.20) -- and in LEONIDA_COMPILE_GATE=1 (GateMode::always), adaptive_ is false so probe() returns early and verdict_[kind] stays GateVerdict::pending permanently.
Because policy_.free defaults to true, if (c.speculative) return false; still lets vkQueueSubmit enter the driver beside compute warm-ups in auto: classic / classic (and beside graphics prewarms under =1), defeating the calibration fallback meant to avoid device loss on holding drivers. Gating the speculative bypass on adaptive_ (or disabling policy_.free when compile_gate_mode() is classic/always unless explicitly enabled) would preserve the non-adaptive modes' guarantee.
There was a problem hiding this comment.
Thanks, right: with adaptive_ false no verdict ever comes, so the bypass hit exactly the drivers auto falls back to classic for. Fixed in 3582924: whether a speculative create passes is now decided in enter_compile under gate_mutex_ (warmup_passes): only a compute create with the adaptive gate. With classic (forced or chosen by auto) and with LEONIDA_COMPILE_GATE=1 every speculative create holds submissions as a demanded one does, and CompileTurn::speculative() reports false. LEONIDA_COMPILE_GATE_WARMUPS=0 is the explicit opt-in to let compute warm-ups pass with those gates too (documented with its cost on a holding driver); =1 still makes every warm-up hold. submit_mutex_test checks each mode: adaptive, classic, =1, =0 under classic and =1, and =1 under adaptive, each on a gate of its own. AI-assisted (Claude Code)
| stats_.most_running = (std::max)(stats_.most_running, running_.size()); | ||
| const auto probe = probe_; | ||
| lock.unlock(); | ||
| compile_job_speculative = speculative; // its creates do not hold submissions (DriverTurn) |
There was a problem hiding this comment.
With #2260 (LEONIDA_PIPELINE_PREWARM_ORDER) now on main, PipelineState::prewarm_queue submits graphics and mesh prewarm jobs with non-zero priority (leonida::pipeline_prewarm::priority(entry.rank)), so speculative (and compile_job_speculative) is true for graphics/mesh prewarms too, not just compute warm-ups (also making the (only compute warm-ups exist) note in runtime/README.md stale).
More importantly, auto calibration only probes a compute pipeline. On drivers where compute does not hold submissions (auto --> adaptive) but mesh pipeline creates do hold submissions (e.g. NVIDIA 621.40), verdict_[graphics] starts pending, so marking graphics/mesh prewarms speculative lets submissions enter the driver immediately beside a long mesh prewarm before a graphics verdict exists. Consider restricting the speculative bypass to CreateKind::compute (or requiring verdict_[graphics] == driver_does_not_hold for graphics prewarms).
There was a problem hiding this comment.
Agreed, and thanks for catching the #2260 interaction. Graphics and mesh prewarms stay speculative jobs (the pool still schedules them as such: lower priority, never ahead of demanded builds), but at the gate they now hold submissions as a demanded create does: warmup_passes only lets a compute create through, since the calibration measures only compute and 621.40 held a submission 54 s beside a mesh create. So a mesh prewarm is waited for whatever the compute verdict is. The (only compute warm-ups exist) note is gone; README and docs/d3d12_vulkan.md now name the prewarms and say they hold the gate, and the compile_job_speculative comments say the gate decides. Tests: a speculative graphics create holds a submission with the adaptive gate and with =1 (submit_mutex_test), and the same through DriverTurn with kind = graphics (d3d12_compile_pool_test). AI-assisted (Claude Code)
| } | ||
| return policy; | ||
| } | ||
| void set_warmup_policy(WarmupPolicy policy) { |
There was a problem hiding this comment.
Minor: set_warmup_policy() stores policy.max without clamping it to at least 1 (unlike warmup_policy_from_environment()). Calling set_warmup_policy({true, 0}) would make speculative_ >= policy_.max permanently true and deadlock any speculative create. Also, applying speculative = speculative && policy_.free inside enter_compile() under gate_mutex_ (instead of taking gate_mutex_ separately in warmups_free()) would make direct enter_compile() callers honor policy_.free atomically.
There was a problem hiding this comment.
Done in 3582924: set_warmup_policy clamps max to 1-64 (the same range the environment accepts), and policy_.free is read in enter_compile under gate_mutex_ together with the mode and kind, so direct enter_compile callers follow it too; the separate warmups_free() is gone. submit_mutex_test runs the cap case with max 0 (taken as 1, no deadlock), 1 and 2. AI-assisted (Claude Code)
…adaptive gate lixonik's review of ubiquitarianism#2275: with the classic gate and LEONIDA_COMPILE_GATE=1 no verdict is ever reached, so a warm-up passed the gate there too, also where auto's calibration chose classic because the driver holds submissions (630.20). And since ubiquitarianism#2260, graphics and mesh prewarms are speculative jobs as well, while the calibration measures only a compute create (621.40 held a submission 54 s beside a mesh create). warmup_passes now decides, under gate_mutex_, in enter_compile: a speculative create passes without holding submissions only if it is a compute one and the gate is adaptive, or LEONIDA_COMPILE_GATE_WARMUPS=0 asks for it with every gate. Every other one holds the gate as a demanded create does. set_warmup_policy clamps max to 1-64 (0 deadlocked speculative creates). Tests for each mode, for a graphics prewarm (also through DriverTurn) and for max 0; docs updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @lixonik for the careful review and for testing it. All three points are addressed in 3582924, and main (55bd6f4) is merged in at e1bf0b8: speculative creates now pass the gate without holding submissions only as compute creates with the adaptive gate (or with |
lixonik
left a comment
There was a problem hiding this comment.
Re-reviewed 3582924b6 / e1bf0b8ae and re-tested:
- All three earlier points are cleanly addressed:
warmup_passes(CreateKind)lets speculative creates pass without holding submissions only forCreateKind::computeunder the adaptive gate (unlessLEONIDA_COMPILE_GATE_WARMUPS=0explicitly opts intoeverywhere), keeping classic /LEONIDA_COMPILE_GATE=1warm-ups and graphics/mesh prewarms holding the gate as demanded creates do.set_warmup_policyclampsmaxto1..64(kMaxWarmups), preventing amax == 0deadlock.- Docs (
docs/d3d12_vulkan.md,runtime/README.md) and tests cover every gate mode, graphics prewarm throughDriverTurn, andmax == 0.
- Tested on Windows 11 (MSVC 19.44):
submit_mutex: passed (43.70 s).d3d12_compile_pool: passed (2.28 s).
Looks good to merge.
AI-assisted (Antigravity, Gemini).
Claimed in the coordination issue as: RT-COMPILE-GATE-WARMUP-FREE (claim)
Depends on: nothing. #2233 has landed on
main, so this PR now depends on nothing else.mainis merged in (e1bf0b8), with #2233 and the adaptive compile gate (#2412, #2462). After lixonik's review, a speculative create (compute warm-up; graphics/mesh prewarm of #2260) passes the gate without holding submissions only if it is a compute create and the gate is adaptive (SubmitMutex::warmup_passes), and not where the adaptive verdict says the driver holds submissions. Withclassic(forced or chosen byauto), withLEONIDA_COMPILE_GATE=1, and for graphics/mesh prewarms, it holds the gate as a demanded create does;LEONIDA_COMPILE_GATE_WARMUPS=0opts compute warm-ups in with every gate,=1makes all hold.What and why
The compile gate (
SubmitMutex::CompileTurn,runtime/src/vulkan_device_fault.h) keeps a queue submission out of the driver while any pipeline create is in it. That covers warm-ups too, which nobody is waiting for. HasiKe's cold boots on an RTX 2070 SUPER (#2233) show the cost:LEONIDA_COMPILE_GATE=0it ran at about 100 frames a second.MoonEyes measured the same in #1608 (07:32): 142 s of submission waits behind warm-ups, and game state 3 reached with the gate off. The gate must stay for demanded creates (the device losses it was added for), so this narrows it to them:
compile_job_speculativefor the length of such a job, andDriverTurnpasses it toCompileTurn.enter_submitwaits only for the demanded creates in the driver. A warm-up's pipeline is simply not ready yet: a draw or dispatch that needs it builds it or waits for it, as before.LEONIDA_COMPILE_GATE_WARMUP_MAXwarm-ups (default 1) are in the driver at once.LEONIDA_COMPILE_GATE_WARMUPS=1makes warm-ups hold the gate again, the behaviour before.LEONIDA_COMPILE_GATE=0still turns the whole gate off, unchanged.Risk, and why it is opt-out rather than opt-in: a submission can now be in the driver while one warm-up create runs. That is the case the gate was first added for (NVIDIA 630.20, a submission behind a long warm-up create lost the device). HasiKe has since corrected their own report: their TDR with the gate off at 249.7 s matches fiestorra's world-load GPU hang, which happens with no pipeline build at all, and says nothing about parallel creates. So no current measurement shows a create beside a submission losing the device. This pull request keeps that overlap to one warm-up at a time. HasiKe offered to run it on their card; the result decides whether the default stays.
Tested
submit_mutex_test(CPU), new casewarmups_do_not_hold_the_gate:max1 and 2, four warm-ups never have more thanmaxin the driver at once, and a demanded create does not wait for them;LEONIDA_COMPILE_GATE_WARMUPS=1), a submission waits for a warm-up as before;The earlier gate cases (a submission waits for a create, a create waits behind a waiting submission, creates share the gate) still pass.
d3d12_compile_pool_test, new case: a warm-up's and the checkpoint's jobs run withcompile_job_speculativeset, a demanded job without, also on a worker that ran a warm-up before (one worker and three).Each gate rule was broken by hand in turn (4 mutants: warm-ups hold submissions, the policy ignored, no cap, a warm-up entering during a submission), and
submit_mutex_testfailed for every one.With the change, these pass (15 of 15):
submit_mutex,d3d12_compile_pool,d3d12_compile_teardown(pool and one worker),big_compile_gate,d3d12_big_compute(all 7 settings),d3d12_m4_compute,d3d12_pipeline_workersandd3d12_pipeline_workers_eager. A boot was running on this machine, so the full suite was not run.python -I tests/test_docs_env_vars.py,tests/test_docs_repo_paths.py,scripts/check_no_game_data.pyon the changed files: pass.Not tested here: a real boot. A cold boot on HasiKe's card, and ours, with the gate on is the measurement that matters (submissions a second while warm-ups run, and whether the device stays).
GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly.docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code