Explore scratchpad · NVIDIA/hyperflare-inference #641

Raw Markdown for agents: https://autobot.eidonix.com/p/be26590d-55ba-4464-aa98-aada0c2d3b98.md

#1 [high] Change: what #641 actually does, file by file

#641 (open, ready, head d82fcfc, base main, +163/-10, 3 files). Author nero- (CONTRIBUTOR), opened 2026-11-30 13:01, no reviews, no CI checks, 0 comments.

  1. ignition/preparation/compile_pool.py:26 — new module constant _DEFAULT_MAX_WORKERS = 8; replaces literal 8 at :63 in the capacity = min(8, capacity) clamp. Pure extraction, no behavior change.
  2. compile_pool.py:38-64 compiler_resources() is reordered/restructured:
    • Before: sampled available = host_memory.available_bytes() and free = device_memory_info(device)[0] FIRST (lines deleted at diff hunk @@ -42,21 +43,25), then if free - headroom_bytes < device_bytes: torch.cuda.empty_cache(); free = resample, then capacity, then capacity = min(8, capacity), then if shared: available = min(available, free) on the STALE available.
    • After: computes shared, device_bytes, worker_bytes (new local, was inline in the return), headroom (new local, was inline), max_workers = limit if compile_workers is not None else min(limit, _DEFAULT_MAX_WORKERS); samples available/free; clamps available = min(available, free) when shared BEFORE the flush test; flush trigger changed to available - headroom < max_workers * worker_bytes (shared) / free - headroom_bytes < max_workers * device_bytes (discrete) instead of free - headroom_bytes < device_bytes; after flush resamples free and, when shared, available = min(host_memory.available_bytes(), free) (:58-60).
    • Note the asymmetry the description names: after a flush on discrete GPUs available is NOT resampled (only free), so CompilerResources.available stays pre-flush on discrete hosts.
    • The discrete flush trigger uses headroom_bytes (raw caller value), not headroom = max(_HEADROOM_BYTES, ...), matching the pre-existing capacity formula max(0, (free - headroom_bytes) // device_bytes) at :61.
  3. ignition/preparation/aot.py:1070 — one added line torch.cuda.empty_cache() after release_unused() inside the existing try/except at :1068-1072, before dist.barrier(group=group) at :1074, before compiler_resources(...) at :1076, before all_gather_object(demand, ...) at :1081. Comment at :1073 reworded to mention "flushed CUDA caches". Because the flush is inside the try, a flush failure is recorded into error and reported through the all_gather_object failure list at :1083-1085, keeping the barrier collective intact (test asserts this).
  4. tests/preparation/test_compile_pool.py:538-681 (+147) — new helper _patch_compiler_memory and 5 test functions/parametrizations: unified-memory resampling thresholds (3 cases), Windows os.name == "nt" variant, discrete worker-capacity recovery (default and explicit compile_workers=12), no-flush skips when memory already covers max_workers (discrete 16 GiB free and integrated 300 GiB), and _prepare_ranks flush-before-barrier ordering on success and failure (events[:4] == ["release_unused", "empty_cache", "barrier", "compiler_resources"]).

#2 [high] Related work: #639 (open draft, same author area) rewrites the same compiler_resources lines — direct conflict

#639 "ignition: tune discrete CompilePool sizing and scale Inductor compile threads" — open, DRAFT, author original-el8 (COLLABORATOR, a priority contributor per charter), opened 2026-11-30 11:55 (about an hour BEFORE #641's 13:01), updated 12:48, head 3400e3a, +58/-18, 4 files, labels area:memory, area:preparation, performance, triage:review.

Same files: ignition/preparation/compile_pool.py (+15/-6), ignition/preparation/aot.py (+2/-2), tests/preparation/test_compile_pool.py (+25/-9), tests/preparation/test_forward_compile_options.py. #639 changes _DISCRETE_WORKER_DEVICE_BYTES 1 GiB -> 704 << 20, caps discrete compile reserve at min(headroom_bytes, 1024 << 20), and rewrites the compile_threads=1 / worker_start_method parts of CompilePool.__init__. It touches compiler_resources (:49-55, :62 per its own review), which is exactly the function #641 restructures — a textual/merge conflict is near-certain, and if #639 lands first, #641's headroom/max_workers triggers would need reconciling against a clamped discrete headroom_bytes.

#639 already has an Autobot review (comment 2026-11-30 12:48) recommending "Changes Requested": 2 blockers (unbudgeted nested Inductor subprocesses; persistent parent-rank AsyncCompile pool), 4 should-fix, 3 subtract/simplify. Its review also flags that open, "Ready To Merge" PR #597 "modifies the same compile_pool.py / aot.py coordination paths" and that it partially reverses commit c8d4c324's single-thread-per-worker policy.

Neither PR references the other in its description; #641 does not mention #639 at all. #639 does not mention #641 (it predates it by ~1h).

Note: the review of #639 complains about "the mock-only Windows guard" — a similar critique could apply to #641, whose Windows evidence is also mock-only (author discloses this in "Material limitations").

#4 [high] Why: the symptom is open issue #242/#270/#73 (GB10 unified memory, same MemoryError text), and #641 fixes only part of it

The exact symptom #641 fixes is a known, open, long-standing bug family. Open issue #242 "Multi-host export compiles for 22 minutes, then fails, when one rank has no memory for a forward compiler" (javieratomic, CONTRIBUTOR, opened 2026-11-09, labels area:memory, area:preparation, bug, model:deepseek-v4.1, priority:P2, triage:partial; updated 2026-11-13) reports on 3× DGX Spark GB10 (unified memory), TP3, one rank per host, DeepSeek V4.1 Flash:

How long wanted: issues from 2026-10-24 (#73) through 2026-11-09 (#242) to 2026-11-30 (#641), i.e. ~5 weeks of recurring reports that GB10 compiler admission is decided by a few hundred MiB around an 8 GiB floor. The specific "available not resampled after empty_cache" root cause appears in none of those issues; #641 is the first to name it.

#6 [high] Related work: #122 (closed 2026-11-29) solved the same MemoryError by lowering headroom; #641 reclaims memory instead

#122 "Make the compiler memory headroom a preparation setting" — javieratomic (CONTRIBUTOR), CLOSED 2026-11-29 21:44 (not merged), +392/-65, labels area:memory, area:preparation, model:deepseek-v4.1, performance, triage:design-review. Closed one day before #641 opened.

#7 [high] Claims: verified arithmetic — before-case reproduced from the diff; after-case is the 4 GiB minimum allowance, not extra workers

Verified arithmetic from the code, which both confirms the description's root cause and sharpens the claimed benefit.

Old code path on a GB10 (integrated, POSIX): device_memory_info() (ignition/preparation/host_memory.py:103-110) returns free = min(total, available_bytes()) for integrated GPUs on POSIX, so free ≈ available. With #641's "Before" numbers (available 8435 MiB, headroom_bytes = 8192 MiB, device_bytes = 2 GiB, _WORKER_DEVICE_BYTES): the OLD trigger free - headroom_bytes < device_bytes was 8435 - 8192 = 243 MiB < 2048 MiB → true, so the old code DID call torch.cuda.empty_cache() and DID resample free, but available had been sampled before the flush and the old code then did available = min(stale_available, new_free) = min(8435, post-flush free) → still 8435 MiB. Then allocate_workers (compile_pool.py:78-97) got remaining = 8435 - 8192 = 243 MiB, which fails the 34 GiB worker test and the 4 GiB minimum allowance, raising the exact reported MemoryError. So the description's root-cause claim ("the flush ran but the stale available discarded every reclaimed byte") is exactly reproducible from the diff. The old flush was not dead code in this scenario.

Magnitude of the trigger change (not stated in the description): the new integrated trigger is available - max(8 GiB, headroom_bytes) < max_workers * (32 GiB + 2 GiB) — with the default max_workers = min(limit, 8) that is available < headroom + up to 272 GiB. Even at max_workers = 1 it fires whenever available < 34 GiB + headroom. On a GB10 during preparation, MemAvailable is ~10–14 GiB (#73, #242, #122 measurements), so torch.cuda.empty_cache() now runs on essentially every unified-memory preparation, where before it ran only when device free minus headroom fell below 2 GiB. Same on discrete: fires whenever free - headroom_bytes < max_workers * 1 GiB, i.e. free < headroom + up to 8 GiB (existing test premises such as 12 GiB free / 2 GiB headroom at tests/preparation/test_compile_pool.py:39-41 now flush). The description frames the trigger change as fixing "skipped" flushes; it does not mention that the flush becomes near-unconditional, nor give any measurement of what an unconditional flush costs or what it does to a discrete GPU's cached allocator.

Claimed "3 compiler workers" decomposed: with #641's After numbers (~13.3 GiB available after reclaiming 4.9 GiB, headroom 8192 MiB), remaining = ~5.3 GiB. That still fails the 34 GiB per-worker test, so the admitted [1, 1, 1] can only come from the minimum-allowance fallback at compile_pool.py:87-94, whose test is worker_bytes - FORWARD_WORKER_BYTES + _WORKER_BYTES = 2 GiB + 2 GiB = 4 GiB <= remaining. So the honest reading of the live evidence is "reclaiming cached segments restores the one-worker-per-host floor", not "unlocks additional workers" — the 2nd+ worker still needs 34 GiB of remaining host memory each. The description's "unlocking additional compiler workers" overstates the measured case (a 2nd worker on GB10 would need ~46 GiB available).

Config dependency: ForwardCache gets headroom_bytes = plan.headroom_bytes + plan.reserve_bytes (ignition/preparation/bootstrap.py:134; BasePreparationConfig.headroom_bytes defaults to 4 << 30 at bootstrap.py:35), and compiler_resources on integrated GPUs uses headroom = max(host_memory._HEADROOM_BYTES = 8 GiB, headroom_bytes) (compile_pool.py:49). So the "8192 MiB headroom" in both #242 and #641 is the 8 GiB _HEADROOM_BYTES floor, i.e. #641's After case sits only 243 MiB under the floor — precisely the few-hundred-MiB regime #242 describes as decisive.

#8 [high] Related work: #639 and #641 conflict concretely — new tests assume _DISCRETE_WORKER_DEVICE_BYTES = 1 GiB, #639 makes it 704 MiB

#639 lowers _DISCRETE_WORKER_DEVICE_BYTES from 1 << 30 to 704 << 20 and caps discrete headroom_bytes at 1 GiB (per its description/review). #641's new tests hard-code today's 1 GiB constant and 0 headroom, so they will fail if #639 lands (as written, whichever merges second must be rebased and re-derived):

Both PRs are open against main, neither cites the other; #639 has an Autobot review (Changes Requested, 2 blockers), #641 has none yet. #639 was opened 2026-11-30 11:55, #641 at 13:01 — #641 is the later arrival into a function #639 had already claimed.

#9 [high] Recent activity: the empty_cache flush #641 widens was added 8 days earlier by #462 (voipmonitor) for the same error

#462 (merged 2026-11-22, voipmonitor — a PRIORITY contributor per the charter) is the commit that ADDED the existing torch.cuda.empty_cache() flush inside compiler_resources() (compile_pool.py:49-51 on main), and it did so for the same class of failure: its description says "flushes torch.cuda.empty_cache() in compiler_resources() whenever driver-free VRAM falls below one compiler worker allowance. Resolves MemoryError: no capacity for a forward compiler during kda-input exports on 16× GB202." #641 is therefore a continuation of #462's flock of fixes (it widens the trigger and adds the missing resample), but #641's description does not mention #462 or that the flush it is extending was deliberate and recent. Files: #462 touched ignition/preparation/compile_pool.py (+3/-0) plus Kimi3 recipe files; merged same day it opened, 0 comments.

History of the function (commits touching ignition/preparation/compile_pool.py, newest first): d82fcfca 2026-11-30 (#641 itself) → b0d35934 #509 Luke Alonso 2026-11-24 → 346615d8 #462 Martin Vit 2026-11-22 → c8d4c324 2026-11-09 Luke Alonso "Budget forward compiler workers across each host" (the per-host allocate_workers structure #641 keeps and #639 partly reverses) → 84c1c0a1 2026-10-17 Martin Vit "Lend missing forward compilations to idle ranks on one host" → b9a53f33 / aa7a19e8 "Size compiler workers by free device memory" (2026-10-11) / 468415d1 "Bound integrated forward compilers' Inductor threads by the RAM their workers leave" (jasonc 2026-10-13) / b6d57dad "Centralize preparation memory policy and size compiler pools from available RAM" (Luke Alonso 2026-10-12) / cf192126 "Keep unified-memory GPUs such as GB10 within their shared system memory" (jasonc 2026-10-12). So this ~40-line function has been edited by Luke Alonso (dominant owner), Martin Vit, jasonc and voipmonitor across 7 weeks; #641 (nero-) and #639 (original-el8) would be the 5th and 6th contributors into it in 8 weeks — a crowded, repeatedly-tuned hot spot, which is why the diff is small but the blast radius is broad.

#10 [high] Process: python-cpu.yml does run tests/preparation, but the suite was red until #624 merged 12:39; #641 has no CI checks or reviews

#12 [high] Related work: #584 (closed) proposed the same flush-before-probe; #630/#323 contest the MemAvailable basis it relies on

#13 [high] Claims and evidence: root cause verified from the diff; the live benefit is one-worker floor recovery, not extra workers

Claim-by-claim, with what backs each.

  1. "available was never resampled after torch.cuda.empty_cache(), so available = min(available, free) discarded every reclaimed byte." — VERIFIED from the diff. Main (compile_pool.py:45-56 at base main) samples available at :45, flushes at :50, resamples only free at :51, then clamps at :56. Reproduced arithmetically against the author's own before-numbers (see the entry on verified arithmetic). This is the strongest part of the PR.
  2. "The flush trigger skipped empty_cache() when unified-memory admission was bounded by the headroom/worker budget." — VERIFIED. Old trigger free - headroom_bytes < device_bytes (:49 on main) tests one 2 GiB worker, not the budget. With 8435 MiB available / 8192 MiB headroom the old trigger was 243 MiB < 2048 MiB → it did fire; the description's framing ("skipped") understates its own root cause here. The real under-triggering cases are the ones where the device could hold one worker but the budget could not (the new test at test_compile_pool.py:571-580, case 2).
  3. "Discrete GPU free memory fell below the admissible worker cap." — VERIFIED: old discrete trigger was 1 GiB (_DISCRETE_WORKER_DEVICE_BYTES) regardless of max_workers.
  4. "release_unused() ran before dist.barrier() without torch.cuda.empty_cache()." — VERIFIED (aot.py:1068-1074).
  5. "Prevents spurious MemoryError; unlocks additional compiler workers." — PARTLY BACKED. The live before/after is one export of one model on 3× GB10 (unified), at the 243 MiB-under-the-8-GiB-floor margin. As decomposed in the arithmetic entry, the shown gain is restoring the 4 GiB minimum allowance for one worker per host (compile_pool.py:87-94), not admitting additional workers: a second integrated worker needs 34 GiB of remaining host memory. No measurement shows a second worker being admitted on any host.
  6. "160 passed, 0 failed" — an author-reported local run of a 5-file subset (test_compile_pool.py, test_capture_order.py, test_forward_artifact_sharing.py, test_transient_retention.py, test_host_memory.py). Not verifiable here; the repo workflow runs the whole tests/ suite (.github/workflows/python-cpu.yml:33). New tests are all CPU/monkeypatched.
  7. Live 3-node SM121 validation — the strongest evidence, and it is combined-stack: the description says the export is "paired with NVIDIA/hyperflare-inference#635 and local-inference-lab/hyperflare-recipes#103". #635 is itself an open PR by the same author (planning/filter_world_sizes, reviewed "Ready To Merge" 2026-11-30 11:32). So the before/after comparison mixes three branches; the description does label the pairing, but AGENTS.md:96-112 warns against attributing a combined result to one PR, and there is no isolated main-vs-PR measurement and no wall-clock A/B (before failed in 2.5 s; after took 1204.2 s because it actually compiled — so no speed comparison exists or is claimed).
  8. "Material limitations: Windows unified-memory validated via CPU unit tests mocking host_memory.os.name == "nt" and torch.cuda.mem_get_info." — Disclosed honestly. Note AGENTS.md:194-199: "source-text checks and mocks that bypass the behavior cannot establish runtime correctness" — relevant precedent: #639's review flags "the mock-only Windows guard" as a should-fix. Also, the Windows clamp (available = min(available, free)) is the only behavior the clamp changes at all (on POSIX integrated, device_memory_info already returns min(total, available_bytes()), so min(available, free) is a no-op — see host_memory.py:108-109), which makes the untested Windows path the sole justification for moving the clamp.
  9. "Passed flare run qualification (24/24 determinism, 23/24 top-1 vs TP4, −1.4593 NLL, 3.965 s cold 32K needle, 61/61 concurrency, 4/4 image)" — whole-pipeline serving results on a core prepared by the combined stack. They establish that the produced core serves, not that #641 caused any of it.
  10. Unclaimed/unmeasured costs: the flush now runs on nearly every preparation (see arithmetic entry), including discrete GPUs where it drops allocator segments warmup/capture could reuse; and the new empty_cache() before the rank barrier runs on every rank of every multi-rank preparation. Neither cost is measured anywhere in the description. No main-vs-PR peak-RSS/MemAvailable telemetry is given beyond the 11.0–11.3 GiB during compilation.

#14 [high] Project fit: aligns with documented release/invariant rules; gaps are docs (none touched) and discrete/Windows coverage

What the description does not say (all verified from the diff/code):

  1. The clamp it moves is a no-op everywhere except Windows. On POSIX integrated GPUs, device_memory_info() already returns free = min(total, available_bytes()) (host_memory.py:108-109), so available = min(available, free) changes nothing on the platform the live evidence comes from. The moved clamp's only behavioral effect is the Windows path (os.name == "nt" skips that min), which is the one path the evidence cannot cover. The description presents the clamp as the general fix.
  2. The flush becomes near-unconditional, not merely better-triggered. The new unified trigger available - max(8 GiB, headroom) < max_workers * (32 GiB + device_bytes) fires for any available below ~34–272 GiB; the discrete trigger free - headroom_bytes < max_workers * 1 GiB fires below ~headroom + 8 GiB. Every GB10 preparation (MemAvailable 10–14 GiB per #73/#242/#122) now flushes, and discrete hosts that previously never flushed now do. No cost measurement accompanies this.
  3. available is deliberately not resampled on discrete GPUs after a flush — stated in the description, but the consequence is that CompilerResources.available (host RAM) on discrete hosts can now be stale relative to a capacity that grew after the flush; they are the two numbers allocate_workers combines (compile_pool.py:75-86).
  4. No existing test assertion is changed. The test diff is purely additive (+147/-0). Notable in contrast to open PR #639, which rewrites existing expectations (test_compile_pool.py:39-41, :16-27, etc.).
  5. _DEFAULT_MAX_WORKERS already had a duplicate source of truth: compilation.py:30 sets _OPTIONS['compile_threads'] = min(16, os.cpu_count() or 1), which caps limit and therefore max_workers by default; the new constant is the second cap. The description calls it a simple extraction, which it is.
  6. No linked issue / no Fixes # — so nothing closes automatically, even though #242's symptom overlaps.
  7. Nothing in the diff is undeclared in the sense of hidden scope: no new flag, config key, env var, dependency, artifact, or doc change (git-level: 3 files, all named in the description). The "does not do what it says" list is empty; the "does more than it says" list is items 1–3.

Charter / project-fit facts (not judgments):

#17 [high] Summary: what is proven, what is expected, main risks and unanswered reviewer questions

Collected loose ends so a downstream reviewer does not have to re-derive them:

  1. What is proven beyond doubt: main's compiler_resources samples available before the flush and clamps it with a post-flush free, so reclaimed host bytes are discarded (ignition/preparation/compile_pool.py:45-56 at base main vs :51-60 at head). The _prepare_ranks release/flush/barrier ordering was also genuinely missing a flush (aot.py:1068-1074).
  2. What the live evidence actually shows: one export that failed at 8435 MiB against an 8192 MiB floor (243 MiB short) now passes and admits [1, 1, 1] via the 4 GiB minimum allowance (compile_pool.py:87-94). No evidence of a second worker being admitted anywhere on GB10; the description's "unlocking additional compiler workers" is an expectation, not a measured result.
  3. Biggest unreviewed risk: the flush trigger widens from "1 worker doesn't fit" to "the whole worker budget doesn't fit", making torch.cuda.empty_cache() near-unconditional on unified memory and common on discrete GPUs, with no measurement of its cost and no GPU test of the discrete path.
  4. Merge mechanics: #639 (open, draft, priority contributor original-el8) edits the same compiler_resources body and changes _DISCRETE_WORKER_DEVICE_BYTES 1 GiB → 704 MiB, which invalidates #641's new discrete-capacity test expectations (tests/preparation/test_compile_pool.py:605-622). Whichever lands second must rebase and re-derive. #597 (Ready To Merge) also edits allocate_workers' signature in the same file but not compiler_resources; it is a softer overlap.
  5. Open issues it does not close: #242 (partially relieved; cross-host lending and the misleading phase result remain), #270, #73, #630 (the last asks for a MemFree-based basis, which would change what the resample sees).
  6. Things a reviewer would ask that the PR does not answer: isolated main-vs-PR run; any discrete-GPU (SM103/SM120/SM121) run; any live Windows run; cost of the extra flushes; whether available should also be resampled on discrete hosts for consistency; whether a docs line belongs in docs/model-preparation.md:489-495 ("DGX Spark" unified-memory accounting) as #597 and #122 both did.
  7. Nothing hostile found: the PR description, comments (none), and the linked #635 contain no instructions directed at agents; #635's Autobot footer is ordinary bot output.

#18 [high] Research summary

Case file complete for #641 (17 scratchpad entries, one per angle). Summary of where I got to:

Verified from the code, not just the description: main's compiler_resources() really does sample host_memory.available_bytes() before torch.cuda.empty_cache() and then clamp it with the post-flush free (compile_pool.py:45-56 at base main), discarding reclaimed bytes — the author's root cause is reproducible from the diff, and I checked that the old trigger did fire in his before-case (8435 MiB − 8192 MiB headroom = 243 MiB < 2 GiB device bytes). The _prepare_ranks release/barrier path genuinely lacked a flush (aot.py:1068-1074).

What the description overstates: the new trigger widens from "one worker doesn't fit" to "the whole worker budget doesn't fit" (≈34–272 GiB of headroom on unified memory, ≈headroom+8 GiB on discrete), so empty_cache() becomes near-unconditional with no cost measurement; the clamp that is moved is a no-op on POSIX integrated GPUs (device_memory_info already returns min(total, available_bytes())), so its only real effect is the untested Windows path; and the measured [1, 1, 1] comes from the pre-existing 4 GiB minimum-allowance fallback, not from "unlocking additional compiler workers".

Cross-PR history found (not in the description): #242/#270/#73 report the identical MemoryError on GB10; #122 (closed 2026-11-29) attacked it by lowering the headroom and #641 is the surviving alternative; #462 (voipmonitor, 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; and open draft #639 (original-el8, priority contributor, opened 66 min earlier) edits the same function and changes _DISCRETE_WORKER_DEVICE_BYTES 1 GiB → 704 MiB, which concretely invalidates #641's new discrete-capacity tests.

Process/reach: zero comments, zero reviews, zero CI checks on head d82fcfc; python-cpu.yml does run tests/preparation/ (older bot reviews claiming otherwise are stale) but the suite was red until #624 merged 20 minutes before this PR opened. No config, dependency, artifact-format, or docs change; the live evidence is a three-branch combined stack (#635 + hyperflare-recipes#103) on one model/one layout/one hardware, with discrete and Windows paths covered only by mocks.

#3 [medium] People: author nero- history; original-el8 and Luke Alonso own these files

Author: nero-, GitHub association CONTRIBUTOR, not in the charter's priority list (@voipmonitor, @original-el8, @lukealonso). Last 180 days: 3 merged, 3 closed, 3 open.

Area owners (default-branch commits, last 180 days): ignition/preparation — Luke Alonso 158, Martin Vit 52, Eugene Rakhmatulin 36. tests/preparation — Luke Alonso 206, Martin Vit 34, jasonc 23. So Luke Alonso dominates review/ownership here; original-el8 (#639) is a priority contributor who also works in this file.

Community engagement on #641 so far: none — 0 comments, 0 reviews, no labels, no CI checks on head d82fcfc, no linked issue. It has drawn no interest yet.

#5 [medium] Related work: #641 builds on c8d4c324's per-host admission, which #639 partly reverses

Also, the pre-existing compiler_resources flush (before #641) only triggered on free - headroom_bytes < device_bytes, i.e. only when the device could not hold a single worker — so on integrated GPUs where device_memory_info returns min(total, available_bytes()), the old trigger was effectively "host RAM nearly exhausted". That is why the flush almost never ran before and why the code that resampled available was effectively dead.

#11 [medium] Reach: only two call sites, but it changes discrete hosts too, adds no config and no docs

Who/what is affected (verified from the code):

#15 [medium] Community: no engagement at all on #641 (0 comments, 0 reviews, no CI); natural reviewers identified by commit history

Engagement: zero. #641 has 0 comments, 0 reviews, 0 labels, no linked issue, and no CI checks on head d82fcfc; it was opened and last updated in the same minute (2026-11-30 13:01). No human or bot has responded. (By contrast, #639 — opened 66 minutes earlier into the same function — had an Autobot review by 12:48, #635 by the same author had two Autobot review rounds, and #597 has five comments.)

Who usually works here (and would be the natural reviewers): Luke Alonso (158 commits in ignition/preparation, 206 in tests/preparation in 180 days; author of c8d4c324 "Budget forward compiler workers across each host", b6d57dad "Centralize preparation memory policy and size compiler pools from available RAM", 468415d1-era work, and the most recent merge into compile_pool.py, #509) and Martin Vit/voipmonitor (52 commits in ignition/preparation; #462 added the flush #641 extends; reviewed and rejected #584). Jason Cook/jasonc wrote the earlier integrated-memory sizing commits (cf192126 "Keep unified-memory GPUs such as GB10 within their shared system memory", 468415d1). None of them has engaged with #641.

Who reported the underlying failures: javieratomic (#242, #122, and the GB10 measurements in #73) and CaptKitCarson (#73), pfn (#630) — all end users/reporters of GB10 unified-memory admission and memory-accounting failures, none of whom is involved in #641. So the fix arrives from a different contributor than the ones who reported the pain, and does not cross-reference their reports.

Reaction/temperature: none measurable yet. The PR is new (same-day). Its neighbouring work carries heat: #639 drew a 2-blocker Changes Requested review within an hour; #584's draft was rejected as an unsplit mega-PR; #597 reached "Ready To Merge" after two rounds. Expect #641 to be judged against the same bar (isolated measurement, GPU coverage, split scope) once someone looks.

#16 [medium] Reach/process: three-branch combined stack (#635 + hyperflare-recipes#103) and existing gloo tests that now flush for real

Stacked / paired work (declared by the author): the live evidence says the export was "paired with NVIDIA/hyperflare-inference#635 and local-inference-lab/hyperflare-recipes#103".

Cross-reference to existing tests that will now call the new flush for real: _prepare_ranks is exercised by multi-process gloo tests that monkeypatch compile_pool.compiler_resources but NOT torch.cuda.empty_cache — tests/preparation/test_capture_order.py:266-284 (test_prepare_ranks_warms_compiled_forwards_in_agreed_largest_allocation_order, test_prepare_ranks_propagates_allocation_size_failure_without_hanging at :325) and tests/preparation/test_forward_artifact_sharing.py:238,415-418. Because the new flush is inside the try/except Exception at aot.py:1068-1072, any raise there would be turned into a collective failure at :1083-1085 and fail those tests; in practice torch.cuda.empty_cache() is a no-op when CUDA is uninitialized (CPU-only runs), and the author lists both files as passing. This is the one place where the new line could have broken existing green tests — worth naming because it was not called out in the description.

Ordering detail: release_unused() (default generation=2, host_memory.py:38-48) runs gc.collect + malloc_trim(0) and escalates to full GC when available_bytes() < _HEADROOM_BYTES; the new torch.cuda.empty_cache() therefore runs after host-side reclamation and before the barrier — the order that makes the resample see both kinds of reclaimed memory.

#19 [medium] File map: exact head line ranges, base commit, and the constants the fix leans on

For downstream reviewers who need to re-derive anything:

Base state. #641's base is main at the branch point 0a8c20f; orientation packet reports zero default-branch commits since the branch point that touch any of the three changed files, and the whole repo activity around this area is same-day. Head is d82fcfc. Branch fix/compile-pool-empty-cache → main, +163/−10, 3 files, labels: none, state: ready for review (not draft), opened = last updated = 2026-11-30 13:01.

File map at head (line cites at d82fcfc):

Values the code depends on (unchanged by #641): host_memory._HEADROOM_BYTES = 8 << 30 (host_memory.py:16), FORWARD_WORKER_BYTES = 32 << 30 (:15), _HEADROOM_BYTES-escalated release_unused (:38-48), integrated device_memory_info = min(total, available_bytes()) on POSIX (:103-110), CompilePool/compiler_resources constants 2 << 30 and 1 << 30 (compile_pool.py:23-25).

#20 [medium] Claims and evidence: what the new tests do and do not pin, and two consistency questions left open

Fidelity notes on the new tests and description that a reviewer should not have to rediscover:

  1. The tests replace the two inputs the code actually reads with stubs, but keep the real formula. _patch_compiler_memory (tests/preparation/test_compile_pool.py:538-563) sets compile_pool._OPTIONS['compile_threads'] = cpu_limit, makes compile_pool.cpu_workers a lambda returning the request, stubs torch.cuda.get_device_properties, torch.cuda.empty_cache, host_memory.available_bytes, and torch.cuda.mem_get_info. So they assert the arithmetic of the new trigger, not real allocator reclamation — consistent with AGENTS.md:194-199 ("mocks that bypass the behavior cannot establish runtime correctness"), and the one live run is the only proof the flush actually returns bytes.
  2. No test asserts host_samples == 1 for the shared path (only the discrete test asserts state["host_samples"] == 1, :620); the shared tests assert the resulting resources.available and worker count instead. Fine, but it means "resampled exactly once" is only pinned on the discrete path.
  3. The Windows test (:595-602) does not exercise the flush trigger at all (available 10 GiB, free 105 GiB, no reclaim), so what it pins is the min(available, free) clamp on os.name == "nt" — i.e. exactly the one behaviour whose only real-world effect the change has. It is the sole Windows coverage.
  4. No Fixes # line and no issue link anywhere in the description, so nothing auto-closes and #242/#270/#73/#630 stay open and cross-unreferenced (entry on #242 records what remains unfixed there).
  5. Description completeness against AGENTS.md:72-112: all four required parts present, material limitations stated (Windows mock-only), Discord line present (Discord: nero, AGENTS.md:142-153), and the combined-stack pairing disclosed by name — above the median for this repo, but it never names the PRs/issues it supersedes in spirit (#122, #462, #584) or the ones it relieves (#242).
  6. Two unaddressed consistency questions a reviewer would raise: (a) after a flush, discrete hosts resample free but not available, so capacity grows while CompilerResources.available stays stale — the two numbers allocate_workers multiplies together (compile_pool.py:75-86); (b) worker_bytes on integrated GPUs includes device_bytes (2 GiB) on top of FORWARD_WORKER_BYTES (32 GiB), so the new trigger's budget term is at least 34 GiB per worker even though the admission floor grants one worker for 4 GiB — the trigger is deliberately far more conservative than the fallback it is meant to enable.