Case file — PR #641 "Resample host memory after flushing CUDA cache in CompilePool"
Author nero- (CONTRIBUTOR). Open, ready for review, base main at 0a8c20f, head d82fcfc, +163/−10 in 3 files. Opened 2026-11-30 13:01 and last updated the same minute. Zero comments, zero reviews, no labels, no CI checks, no linked issue.
Key findings
- The root cause is real and reproducible from the diff. On base
main,compiler_resources()sampledhost_memory.available_bytes()(line 45 of main), calledtorch.cuda.empty_cache(), resampled onlyfree, then clampedavailable = min(stale_available, new_free)— so every byte the flush returned to host RAM was thrown away. At head the clamp happens before the flush andavailableis resampled afterwards on unified memory (ignition/preparation/compile_pool.py:51-60). - An open draft PR has already claimed the same function. #639 (original-el8, a charter priority contributor) opened 66 minutes earlier, edits the same
compiler_resourcesbody incompile_pool.py, and changes_DISCRETE_WORKER_DEVICE_BYTESfrom 1 GiB to 704 MiB — which concretely breaks #641's new discrete-capacity test expectations (tests/preparation/test_compile_pool.py:605-623). Neither PR mentions the other. - The description's "unlocking additional compiler workers" is not shown by its own evidence. With the reported after-numbers (~13.3 GiB available, 8192 MiB headroom) a worker still needs 34 GiB by the main loop; the admitted
[1, 1, 1]comes from the pre-existing 4 GiB minimum allowance fallback (compile_pool.py:87-94). The measured gain is restoring the one-worker-per-host floor, not extra workers. - The flush becomes near-unconditional, which the description does not say. The new trigger is
available - headroom < max_workers * worker_bytes(≥34 GiB per worker on unified memory) /free - headroom_bytes < max_workers * device_bytes(~8 GiB on discrete at defaults), versus the old "one 2 GiB worker does not fit". No cost measurement accompanies anempty_cache()that now runs on essentially every GB10 preparation and on discrete hosts that never flushed before. - The clamp that is moved only does something on Windows. On POSIX integrated GPUs
device_memory_info()already returnsmin(total, available_bytes())(host_memory.py:108-109), somin(available, free)is a no-op on the platform all the live evidence comes from; the only behaviour the clamp changes is the Windows path, whose sole coverage is a mock. - This is the tail of a long, well-documented bug family the PR never cites. #242, #270, #73, #630 report the identical
MemoryErroron GB10 unified memory back to 2026-10-24; #122 (closed 2026-11-29) attacked the same failure by making the headroom configurable; #462 (merged 2026-11-22) added the flush #641 widens, for the same error; #584 (closed draft) proposed flush-before-probe and was told to split. #641 references none of them. - Evidence is a three-branch combined stack (
#635+local-inference-lab/hyperflare-recipes#103), one model (DeepSeek V4.1 Flash), one layout (TP3, one rank/host), one hardware (SM121 GB10). Discrete and Windows paths are covered only by monkeypatched CPU tests, andAGENTS.md:194-199says mocks cannot establish runtime correctness.
The change (what it does, in plain terms)
Three files, all named in the description; nothing hidden in scope (no new flag, config key, env var, dependency, artifact format, or doc).
ignition/preparation/compile_pool.py:26— new_DEFAULT_MAX_WORKERS = 8, extracted from the literal at:63. No behaviour change (a second source of truth already exists:_OPTIONS['compile_threads'] = min(16, cpu_count)inignition/preparation/compilation.py:30capslimit, hencemax_workers).compile_pool.py:38-64—compiler_resources()reordered: new localsshared:46,device_bytes:47,worker_bytes:48,headroom = max(host_memory._HEADROOM_BYTES, headroom_bytes if shared else 0):49,max_workers:50; samples:51-52; clamp before flush:53-54; new trigger:55-56; flush:57;freeresample:58; sharedavailableresample:59-60; capacity:61-63.allocate_workers()is untouched (:67-98).ignition/preparation/aot.py:1070—torch.cuda.empty_cache()added inside the existingtry/exceptafterrelease_unused():1069and beforedist.barrier(group=group):1074,compiler_resources(...):1076,all_gather_object(demand, ...):1081. A flush failure is folded intoerrorand reported through the collective failure list:1083-1085, so barrier progress is preserved. Comment at:1073reworded.tests/preparation/test_compile_pool.py:538-681(+147/−0, purely additive): helper_patch_compiler_memory:538-566; unified-memory resample thresholds:569-592(3 cases, incl.(8, 44, 34, 2)where a second worker appears only at 44 GiB); Windowsos.name == "nt":595-602; discrete capacity recovery:605-623; no-flush skips:626-642;_prepare_ranksordering:645-682assertingevents[:4] == ["release_unused", "empty_cache", "barrier", "compiler_resources"], parametrized over flush failure.
What it does beyond the description: (a) the trigger widens from one worker to the whole worker budget, making the flush near-unconditional; (b) the moved clamp is effectively Windows-only; (c) on discrete GPUs available is deliberately not resampled while capacity grows — the two numbers allocate_workers multiplies together (:75-86) — leaving available stale there. What the description says that the change does not do: nothing material; the only overreach is "unlocking additional compiler workers" (see Key finding 3). No Fixes # line, so no issue closes.
The why
- Same error text, same hardware, same model, since October: #242 (open, javieratomic, 2026-11-09, P2,
triage:partial) reportsMemoryError: host '…' has 38 missing forwards but no capacity for a forward compiler (11575 MiB available host memory, 8192 MiB headroom)on 3× DGX Spark GB10, TP3, DeepSeek V4.1 Flash — the template #641's "Before" quotes verbatim. Its 2026-11-11 comment: "the default headroom admits or rejects a compiler by a few hundred MiB" — exactly #641's 8435 vs 8192 MiB (243 MiB short) regime. - #73 (open, CaptKitCarson) GB10 TP2 kernel-tuning
MemoryError; its 2026-10-28 comment has the throughput number that motivates admission: "Compile model forwards" 908 s at 8 GiB headroom vs 503 s at 6 GiB headroom (one extra worker). #270 (open) GB10 TP3, 7.1–7.9 GiB available vs the 8 GiB floor. #630 (open, pfn, opened 5 h before #641) argues GB10MemAvailableis page-cache-polluted and baseline should beMemFree. - Duration: ~5 weeks of recurring reports (#73 2026-10-24 → #242 2026-11-09 → #630/#641 2026-11-30). The specific "available is not resampled after empty_cache" cause appears in none of them; #641 is the first to name it.
- The headroom floor both #242 and #641 hit is
host_memory._HEADROOM_BYTES = 8 << 30(host_memory.py:16), surfaced viaheadroom = max(_HEADROOM_BYTES, headroom_bytes);ForwardCache.headroom_bytes = plan.headroom_bytes + plan.reserve_bytes(ignition/preparation/bootstrap.py:134, default4 << 30at:35).
Related work
- #639 (open, DRAFT, original-el8, opened 2026-11-30 11:55, +58/−18, labels area:memory/area:preparation/performance) — rewrites
compiler_resources(:49-55,:62), caps discrete reserve atmin(headroom_bytes, 1 GiB)and sets_DISCRETE_WORKER_DEVICE_BYTES = 704 << 20, and reworkscompile_threads/worker_start_method. Direct conflict: #641's(free_gib=2, reclaim=4, compile_workers=None, expected_capacity=6)assumes 1 GiB per worker (6 GiB ÷ 704 MiB ≈ 8, clamped to 8, not 6), and(9, 4, 12, 13)becomes 18. It already has an Autobot "Changes Requested" review (2026-11-30 12:48, 2 blockers) that also flags the mock-only Windows guard and notes #639 partially reversesc8d4c324's single-thread-per-worker policy. Whichever lands second must rebase and re-derive. - #597 (open, "Ready To Merge") edits
compile_pool.py/aot.pycoordination paths andallocate_workers' signature but notcompiler_resources— softer overlap, flagged by #639's reviewer. - #122 (closed 2026-11-29, javieratomic, +392/−65) — the alternative lever for the same
MemoryError: make the 8 GiB headroom a[preparation] compile_headroom/--compile-headroomsetting. Closed with "Changes Requested" (stale base, recipe code in the wrong repo). #641 is positioned as the conservative alternative ("without relaxing headroom invariants or worker memory budgets") and is the surviving open answer; it does not cite #122. #122's withdrawn 510 s / 905.7 s figures came from extra Inductor threads, a mechanismc8d4c324removed — so #73's worker-count number is the reproducible one. - #462 (merged 2026-11-22, voipmonitor, +3/−0 in
compile_pool.py) — added the very flush #641 widens, "whenever driver-free VRAM falls below one compiler worker allowance", resolving the same "no capacity for a forward compiler" error on 16× GB202. #641 extends recent deliberate work without saying so. - #584 (closed draft 2026-11-29, FujitsuPolycom, +4283/−264) proposed "releases unused CUDA allocator segments before memory probes" plus adaptive
CompilePoolsizing; rejected by voipmonitor as an unsplit mega-PR with instruction to split. #641 is the small successor that review asked for; it does not cite #584. - c8d4c324 ("Budget forward compiler workers across each host", Luke Alonso, 2026-11-09) is the ancestor both #641 (keeps per-host
allocate_workersunchanged) and #639 (partly reverses) negotiate around. - Not relevant after checking: #112 (b12x's own
CompilePoolin FlashInfer — publication bug, different code), #616 (prefix-cache prep), #589 (Selene unified-memory budgeting, Rust layer, merged), #323 (unified-memory cache-sizing headroom, different subsystem), #509/#474 (worker startup, just reset surrounding lines).
Recent activity
ignition/preparation/compile_pool.py has been edited by six people in eight weeks: b6d57dad "Centralize preparation memory policy…" (Luke Alonso, 2026-10-12), cf192126 GB10 shared-memory (jasonc, 2026-10-12), 468415d1 Inductor-thread bounding (jasonc, 2026-10-13), 84c1c0a1 lending to idle ranks (Martin Vit, 2026-10-17), c8d4c324 per-host budget (Luke Alonso, 2026-11-09), 346615d8 the flush (#462, Martin Vit, 2026-11-22), b0d35934 (#509, Luke Alonso, 2026-11-24). #641 and #639 would be the 7th and 8th. Zero main commits touch the three changed files between the branch point and head, so #641 is not built on newer work and does not reverse anything already merged; it builds directly on #462 and c8d4c324.
People
- Author
nero-(CONTRIBUTOR, Discordnero): 3 merged / 3 closed / 3 open in 180 days, including two merged PRs inignition/preparation— DeepSeek V4.1 Flash TP6 per-rank Engram preparation (#220) and Inkling 2 Mini (#433). Established in this exact area, not a maintainer, not in the charter's priority list (@voipmonitor,@original-el8,@lukealonso). - Area owners (default-branch commits, 180 days):
ignition/preparation— Luke Alonso 158, Martin Vit 52, Eugene Rakhmatulin 36;tests/preparation— Luke Alonso 206, Martin Vit 34, jasonc 23. Luke Alonso is the dominant owner of both and the natural reviewer; voipmonitor (Martin Vit) added the flush and rejected #584. None has engaged. - Reporters of the underlying pain — javieratomic (#242, #122, GB10 measurements in #73), CaptKitCarson (#73), pfn (#630) — are uninvolved in #641.
Community
No engagement whatsoever: 0 comments, 0 reviews, 0 labels, 0 reactions, no CI checks on d82fcfc, no linked issue, opened and last updated in the same minute. For contrast, #639 drew a 2-blocker Autobot review within an hour, #597 has five comments, and the author's own #635 has two review rounds. Expect #641 to be judged against the same bar once read.
Project fit
- Aligns:
docs/design-review.md:81-84("Release compiler resources before materializing preparation caches"),docs/preparation-development.md:305-313(account for "cached allocator segments"),:314-318(budget compiler workers "against available system RAM"), and the charter's "what gets merged" (reproducible bug / measured memory issue) plus the four-part description rule inAGENTS.md:72-112(why / what changed / claimed benefit / evidence + limitations + Discord handle — all present). - Tension: charter line 42 asks for the full supported matrix (models, layouts, hardware); #641's live evidence is one model, one layout, one hardware class, with discrete and Windows paths mock-only, and
AGENTS.md:194-199explicitly says mocks cannot establish runtime correctness. - Documentation gap: no docs file is touched, while the two comparable PRs in this area (#597, #122) both edited
docs/model-preparation.md/docs/preparation-development.md.docs/model-preparation.md:489-495("DGX Spark") is the natural home for "cached allocator segments are reclaimed before admission". Nothing currently documented becomes wrong. - No per-model branch, no new flag, no new abstraction — consistent with the charter's small-shared-code rule.
Claims and evidence
| Claim | Backing |
|---|---|
available never resampled after flush, so reclaimed bytes are discarded |
Verified from the diff (main compile_pool.py:45-56 vs head :51-60); arithmetic reproduces the 8435 vs 8192 MiB MemoryError exactly, and the old trigger did fire (243 MiB < 2048 MiB) |
| Trigger skipped the flush in headroom/worker-budget cases and on discrete below the worker cap | Verified: old trigger tested one 2 GiB worker (:49 on main) / 1 GiB discrete constant, regardless of max_workers |
release_unused() ran before the barrier with no empty_cache() |
Verified (aot.py:1068-1074) |
"Prevents spurious MemoryError" |
Backed for the shown case only — one export, 3× GB10, 243 MiB under the floor |
| "Unlocks additional compiler workers" | Not backed by its own evidence: [1, 1, 1] comes from the 4 GiB minimum allowance (compile_pool.py:87-94); a second worker still needs 34 GiB remaining |
| "160 passed, 0 failed" | Author-reported local run of a 5-file subset; the workflow runs all of tests/ (.github/workflows/python-cpu.yml:33 (not opened)) |
Live 3-node SM121 validation (51/51 forwards, 193/193 graphs, flare run 24/24 determinism, −1.4593 NLL, 3.965 s 32K needle, 61/61 concurrency, 4/4 image) |
Structurally the strongest evidence, but produced by a three-branch stack (#635 + hyperflare-recipes#103 + this), so AGENTS.md:96-112's "never attribute a combined result to one PR" applies. No isolated main-vs-PR run; no wall-clock A/B (before failed in 2.5 s, after spent 1204.2 s actually compiling) |
| Windows unified memory | Mocked only — and this is the one path where the moved clamp changes behaviour at all |
New tests monkeypatch torch.cuda.empty_cache, host_memory.available_bytes, torch.cuda.mem_get_info, get_device_properties and dist.* (test_compile_pool.py:538-566), so they pin the arithmetic of the trigger, not real reclamation. "Resampled exactly once" is asserted only on the discrete path (:622); the Windows test (:595-602) exercises the clamp, not the flush. Unmeasured costs: the near-unconditional flush (including on discrete GPUs where warmup/capture could reuse those segments) and the new per-rank flush before the barrier.
Reach
- Two call sites (
compile_pool.py:133inCompilePool.__init__;aot.py:1076inForwardCache._prepare_ranks), andForwardCacheis constructed in exactly one place (ignition/preparation/capture.py:118(not opened)) — so everyflare export/debug-serve/benchpreparation of compiled forwards goes through it, as does any directCompilePooluser (b12x-style compilation). - Both hardware classes change, not just unified memory: discrete SM103/SM120/SM121 exports begin flushing where they never did (the existing premise of 12 GiB free / 2 GiB headroom at
tests/preparation/test_compile_pool.py:39-41now flushes). - No config surface, constant, artifact-format, cache-key, dependency or deployment change; existing cores still load. Headroom invariants and worker budgets untouched, as claimed.
- Existing green tests are at slight risk: multi-process gloo tests call
_prepare_rankswithout patchingtorch.cuda.empty_cache(tests/preparation/test_capture_order.py:266-284,325;tests/preparation/test_forward_artifact_sharing.py:238,415-418). In CPU runsempty_cache()is a no-op when CUDA is uninitialized and the author lists both files as passing, but it is not called out in the description. - Paired work declared by the author: #635 (same author, open, "Ready To Merge", planning/
filter_world_sizes— cannot affect memory sampling) andlocal-inference-lab/hyperflare-recipes#103(different repository, unreviewable here).
Process
Ready for review (not draft), ~0 elapsed review time, no CI checks on head d82fcfc. .github/workflows/python-cpu.yml:3-33 (not opened) does run pytest tests/ with CUDA_VISIBLE_DEVICES="" on every pull_request, so tests/preparation/ is covered — older Autobot reviews of #597/#639 claiming no Python CI runs these tests are stale. However the suite was permanently red until #623 was fixed by #624 (merged 2026-11-30 12:39, ~20 minutes before #641 opened), and first-time-contributor workflow runs need maintainer approval (#624's review). Nothing hostile: no instructions directed at agents in the description, comments (none), or #635.
Open questions / what could not be found
- No isolated
main-vs-PR measurement, and no cost measurement for the extra flushes. - No discrete-GPU (SM103/SM120/SM121) or live-Windows run.
- Whether
availableshould also be resampled after a discrete flush, for consistency with thecapacitythat does grow. - Whether #641 or #639 is the intended landing order for
compiler_resources, and how the 1 GiB vs 704 MiB discrete constant is to be reconciled. - Whether a docs line belongs in
docs/model-preparation.md:489-495, as #597 and #122 both did. - Nothing found: no linked issue anywhere, no review, no reactions, no mention in any other open item (searched the local PR/issue copy), and no statement of intent from a maintainer about this area.
- Minor consistency note a reviewer would raise:
worker_byteson integrated GPUs includesdevice_bytes(2 GiB) on top ofFORWARD_WORKER_BYTES(32 GiB), so the trigger budgets ≥34 GiB per worker while the admission floor it is meant to enable grants a worker for 4 GiB — the trigger is far more conservative than the fallback it unblocks.