Explore scratchpad · NVIDIA/hyperflare-inference #639

Raw Markdown for agents: https://autobot.eidonix.com/p/c6d0a9a1-8a69-4add-bc6f-e0dbdf368c0b.md

#1 [high] Change: what #639 does, verified in the diff (4 files, +58/−18)

PR #639 (open, draft), head 3400e3a, base main (branched at 0a8c20f), author original-el8, 4 files +58/−18.

  1. ignition/preparation/compile_pool.py:24-25 — _DISCRETE_WORKER_DEVICE_BYTES 1 GiB (1<<30) → 704 MiB (704<<20); comment now says "~672 MiB measured for CUDA context and Inductor constant folding". Integrated constant _WORKER_DEVICE_BYTES = 2 << 30 unchanged (compile_pool.py:23).
  2. compile_pool.py:49-51 — new compile_reserve = headroom_bytes if shared else min(headroom_bytes, 1024 << 20); used for the free - compile_reserve < device_bytes probe, for capacity = max(0, (free - compile_reserve) // device_bytes), but NOT for the returned CompilerResources.headroom (line 62 still max(host_memory._HEADROOM_BYTES, headroom_bytes if shared else 0)). So the host-RAM side of admission in allocate_workers (compile_pool.py:73-84, remaining = available - headroom) is unchanged.
  3. compile_pool.py:137-144 — replaces the unconditional compile_threads=1 with inner_threads = max(1, min(8, (os.cpu_count() or 1) // max(1, self.workers))), plus worker_options["worker_start_method"] = "subprocess" when os.name != "nt". os.cpu_count() read via hasattr guard. This is applied to self.options, which is passed as options into every _compile_forward(payload, device, self.options, ...) call (compile_pool.py:161-162) i.e. it becomes the per-worker Inductor option dict inside CompilePool subprocesses.
  4. ignition/preparation/aot.py:901-903 — ForwardCache.prepare_many's torch._inductor.config.patch(compile_threads=1) → compile_threads=min(24, os.cpu_count() or 1); comment changed from "Compiler workers own parallel compilation; artifact binding needs no second worker pool."
  5. Tests only otherwise: tests/preparation/test_compile_pool.py (+~30/−10) and tests/preparation/test_forward_compile_options.py, incl. new test_prepare_many_scales_inductor_compile_threads_with_cpu_count (monkeypatches aot.os.cpu_count→64, asserts observed 24).

Description matches the diff; nothing in the diff is undeclared at the file level. Undeclared side effects (see separate notes): interaction with _OPTIONS['compile_threads'] (= min(16, cpu_count), compilation.py:30) and with the unchanged CompilerResources.headroom.

#2 [high] Change: thread policy is inconsistent across the three Inductor compile_threads sites

compile_threads appears in four places at PR head:

Notable: the compile_pool per-worker value is now derived from the pool worker count rather than from the configured _OPTIONS['compile_threads'] (16-cap) — the config value survives only as the worker-count cap (compile_pool.py:44). The aot.py value ignores the same config entirely and uses a separate 24 cap. Neither cap is documented or configurable in BasePreparationConfig; grep of headroom_bytes/compile_threads in ignition/ shows no parameter plumbing for them (only bootstrap.py:35 headroom_bytes: int = 4 << 30). This is the same class of concern #509's Autobot review raised about unrecorded switches ("compile_options is still an unrecorded switch … Not in BasePreparationConfig, not in the plan/reproduction_arguments", #509 review) — #639 introduces two new hardcoded tuning constants (8, 24) and a new 1 GiB cap.

#3 [high] Related work: #122 (closed 2026-11-29) is the headroom-as-setting PR, and it withdrew the multi-thread-per-compiler mechanism #639 revives

#122 "Make the compiler memory headroom a preparation setting" by javieratomic, opened 2026-10-28, CLOSED (not merged) 2026-11-29 21:44, +392/−65 across 50 files. Related to issues #73, #242, #270 (GB10/DGX Spark unified-memory doors, kernel-tuning MemoryError / no compiler capacity).

Directly relevant to #639:

#4 [high] Change: hasattr(os, "cpu_count") guard exists to keep an unmodified Windows mock test passing; Windows partitioning untested

tests/preparation/test_compile_pool.py:467-476 test_windows_compiler_workers_fit_host_ram_with_larger_device_budget was not updated by #639 and still asserts (pool.workers, pool.options["compile_threads"]) == (1, 1). It monkeypatches compile_pool.os = SimpleNamespace(name="nt"), which removes cpu_count from the module's os. That is the only reason CompilePool.__init__ at compile_pool.py:139 reads os.cpu_count() if hasattr(os, "cpu_count") else None instead of plain os.cpu_count(): the hasattr guard makes the mocked os fall back to None → inner_threads = max(1, min(8, 1 // 1)) = 1, keeping the stale assertion green.

Consequence: (a) the hasattr guard is a test-shape artifact, not a portability need — os.cpu_count exists on every CPython 3.x platform including Windows and is always truthy-or-None, never absent; (b) that test no longer exercises the new partitioning path at all (it silently takes the cpu_count is None branch), so Windows thread partitioning is untested even though the PR description says "spawn" is "preserved on Windows".

Likewise tests still pinning compile_threads=1 semantics where the new path is bypassed: test_compile_pool.py:397-431 (test_compiler_reuses_its_budgeted_worker_pool) sets cpu_count → 8, so with workers=2 → 4 and workers=1 → 8, asserting the cap at 8; test_compile_pool.py:376-388 parametrizes cpu_count → 64.

#5 [high] Change: admission math before/after — only the device side relaxes; host-RAM headroom floor is untouched

Device sizing (discrete). #639 lowers the per-worker device estimate 1 GiB → 704 MiB with the justification "~672 MiB measured" (compile_pool.py:24-25). Evidence base in the repo for the old value: #242 (open) says "2 GiB for the worker's CUDA context (_WORKER_DEVICE_BYTES, compile_pool.py)" at d2b5c5f3, and the pre-#639 comment read "about 0.7 GiB for Kimi K3's 93-layer forwards". docs/model-preparation.md:238-245 documents only the 32 GiB host estimate and the 2 GiB minimum allowance, and docs/cli-design.md:1463 says "Compiler workers | Automatic memory-bounded sizing" — no documented per-worker device figure. So the number is a shared-code policy constant with no user-facing doc and no config: #122 (closed) is the PR that wanted exactly this class of value to be a setting.

Headroom cap (discrete). compile_pool.py:51 caps the device-side reserve at 1 GiB on discrete GPUs. Two things it does not cap:

Net effect on worker count: on a discrete GPU, capacity = (free − min(headroom,1 GiB)) // 704 MiB instead of (free − headroom) // 1 GiB. On main the equivalent test asserted 10 workers for 12 GiB free with 2 GiB headroom (tests/preparation/test_compile_pool.py:40-41 on main); #639 asserts 16 (line 43-45 at head). So the same hardware admits 60% more concurrent compiler processes, each with 8× more Inductor threads at low worker counts (see threads entry).

#6 [high] Why: no linked issue; the closest existing reports are #242, #122 and #584 and none is claimed as fixed

No linked issue or prior report is cited in #639. Closest in-repo reports, none of which #639 links or claims to fix:

#7 [high] Recent activity: #639 reverses a boot of the thread policy c8d4c324 deliberately set, on files #509 just rewrote

#8 [high] Related work: #597 (open, "Ready To Merge") edits the same compile_pool.py; #639 would land on top of or race it

#10 [high] Claims and evidence: CI is failing on the head commit but the description reports only green runs; the export timing has no baseline

Claims in #639's "Verification" section and what backs each:

  1. "146 passed, 0 failed" for test_forward_compile_options / test_compile_pool / test_forward_artifact_sharing / test_host_memory, CPU-only. Plausible and consistent with CI scope: .github/workflows/python-cpu.yml:30-33 runs .venv/bin/python -m pytest tests/ -q with CUDA_VISIBLE_DEVICES: "" on every pull_request, so the CPU suite does run in CI. No test file, log or CI run URL is cited in the description; no per-file counts are given.
  2. "56 passed, 14 skipped, 0 failed" for the five other preparation files — uncited, plausible.
  3. CI on the head commit is failing (orientation packet: "CI on the head commit: failed"). The description reports all-green unit runs; nothing in the description explains the failing CI job. This is the single largest gap between claim and evidence.
  4. "DeepSeek-V4.1 preparation compiled 101/101 model forwards in 359.8 s, and Inkling-2-Small preparation compiled 148-graph forwards" on "combined-stack GB300 (SM103)". No baseline: no main-vs-branch comparison, no per-configuration worker/thread counts, no memory samples, no mention of which compile_workers/headroom_bytes the exports used, and the phrase "combined-stack export validation alongside the isolated CPU unit suite" implies the exports also carried other unmerged changes. Charter: "Performance PRs need benchmarks showing an actual speedup over main on a served workload (#210)" — 359.8 s for 101 forwards is a wall-clock number with no comparison point, and the change's stated benefit is precisely speed (idle cores) and worker count.
  5. The "~672 MiB measured" figure behind 704 MiB is not traced to any measurement artifact, recipe or log; the PR's own hardware runs are on GB300/SM103 (a 288 GB HBM part), the hardware where freeing device memory matters least.
  6. The daemonic-multiprocessing claim ("TorchInductor requires worker_start_method="subprocess" on POSIX to spawn nested compile workers") is consistent with compile_pool.py:153-160, where POSIX uses SubprocPool(..., kind=SPAWN) — a non-daemonic spawn-kind pool — and with compilation.py:31-32 which only sets worker_start_method='spawn' on Windows. Not independently verified here: torch._inductor.config.compile_threads = 1 (the old value) is also the default that disables the nested pool entirely in Inductor, so the worker_start_method requirement only becomes live once threads > 1 — the two halves of the change are coupled, which the description does state.
  7. "Limitations: GPU-gated preparation unit tests (FLARE_RUN_CUDA_TESTS=1) were skipped" — accurate and consistent with the CPU-only claim.

#11 [high] Reach: default thread and worker counts rise for every export, and the thread count ignores CPU affinity, unlike the worker count

Who/what it affects.

#13 [high] Process: draft, opened hours ago, CI failing on head, zero reviews/comments/labels; plus the exact file:line map

#16 [high] Change vs description: the default 4 GiB→1 GiB reserve relaxation is not declared, nor the untouched compile_threads=1 sibling

Verified against the diff — the description is accurate about every file it names, and nothing in the four changed files is undeclared at file level. What the description does not say:

  1. The default headroom_bytes path changes too, not just "large runtime reserves". ignition/preparation/bootstrap.py:35 defaults headroom_bytes: int = 4 << 30, and bootstrap.py:134 passes plan.headroom_bytes + plan.reserve_bytes down. Under #639 a discrete GPU uses min(4 GiB, 1 GiB) = 1 GiB. So every discrete export's compile-time device reserve drops 4 GiB → 1 GiB even with no operator-supplied reserve, which is a 3 GiB relaxation the "Why" frames as only affecting large reserves.
  2. CompilerResources.headroom is deliberately left un-capped (compile_pool.py:62), so host-RAM admission still subtracts the full headroom/floored 8 GiB. Not stated; it means #242-style host-RAM failures are untouched.
  3. DeferredCompiledForward.materialize_for_capture keeps compile_threads=1 (aot.py:688). The description says the prepare_many patch changed but not that a sibling patch in the same file did not, leaving the file with two conflicting policies.
  4. The exact worker-count change is never quantified. On main, 12 GiB free + 2 GiB headroom admitted 10 workers (tests/preparation/test_compile_pool.py:40-41 on main); at head it admits 16 (lines 43-45). 3 GiB free goes 3 → 4 workers (line 377). The description says "under-allocates" and "admits against 704 MiB" but gives no before/after count.
  5. The hasattr(os, "cpu_count") guard (compile_pool.py:139) is unexplained; it exists so the unmodified Windows test (tests/preparation/test_compile_pool.py:467-476, which mocks os without cpu_count) still passes — see the separate note.
  6. No mention of the affinity/cpu_count mismatch, no mention of the aot.py 24-thread cap's interaction with the 16-thread _OPTIONS['compile_threads'], no doc or TODO update, and no note that no on-disk cache key changes.
  7. It also does not say the change is combining three unrelated concerns (device sizing, headroom capping, thread/start-method policy) — the shape #509 and #584 were both criticised for (Autobot: "Still one PR for five unrelated defects"; voipmonitor on #584: "bundling ~9 optimization tracks").

#17 [high] Research summary

Case file for #639 (open draft, head 3400e3a, +58/−18 in 4 files, author original-el8 == Jason Cook, a charter-named priority contributor). Sixteen scratchpad entries cover every angle; everything below is recorded there with citations.

What it does (verified against the diff): three coupled changes in shared preparation code — (1) _DISCRETE_WORKER_DEVICE_BYTES 1 GiB → 704 MiB (compile_pool.py:24-25); (2) a new discrete-only cap compile_reserve = min(headroom_bytes, 1024 << 20) in compiler_resources (compile_pool.py:49-55) that leaves CompilerResources.headroom — the host-RAM side of admission — un-capped (line 62); (3) CompilePool.__init__ replaces forced compile_threads=1 with max(1, min(8, cpu_count // workers)) and sets worker_start_method="subprocess" off Windows (compile_pool.py:137-144), plus ForwardCache.prepare_many's Inductor patch 1 → min(24, os.cpu_count()) (aot.py:901-903). Two test files updated, one new test.

What a reader cannot learn from the description: the default path also relaxes — bootstrap.py:35 (not opened) defaults headroom_bytes to 4 GiB, so every discrete export's compile reserve drops 4 GiB → 1 GiB, not just "large runtime reserves"; worker counts rise ~1.6× (the changed test goes 10 → 16 workers for 12 GiB free with 2 GiB headroom); DeferredCompiledForward.materialize_for_capture still pins compile_threads=1 (aot.py:688), so the same file now carries two conflicting thread policies; the hasattr(os, "cpu_count") guard exists only to keep an unmodified Windows mock test green (test_compile_pool.py:467-476), meaning Windows partitioning is untested; and the new thread count uses os.cpu_count() while the worker count uses sched_getaffinity via cpu_workers (host_memory.py:31), so a cgroup-limited rank can overshoot its CPU budget.

History and overlap: #639 reverses the thread policy main deliberately set in c8d4c324 (Luke Alonso, 2026-11-09), whose "one Inductor thread each" design #122's author records as having withdrawn per-compiler threading measurements on purpose. #122 (closed 2026-11-29) is the PR that wanted exactly this headroom constant to be a setting rather than a constant; #639 hardcodes a new cap instead. #597 (open, reviewed "Ready To Merge" 2026-11-30 12:22) edits the same compile_pool.py/aot.py and its review reasoned about the pre-#639 CompilePool.__init__; #584 (closed draft) was rejected partly for bypassing compile_threads and the worker cap. #509 rewrote these same four files seven days earlier. No issue is cited or fixed; #242 (open, P2) is about host RAM admission, which this change does not touch.

Evidence vs claims: CI is failing on the head commit while the description reports only green CPU runs; the headline hardware result (101/101 forwards in 359.8 s on GB300) has no main baseline and ran on a "combined stack", which the charter's #210 benchmark rule requires for a performance PR; the 672 MiB figure behind 704 MiB has no artifact; CI can only exercise the CPU path (python-cpu.yml runs everything with CUDA_VISIBLE_DEVICES=""), so every GPU-side number is either mocked or author-run. Engagement is zero: no comments, reviews, labels or Autobot review, and no prompt-injection attempts in any thread read.

#18 [high] Leads: what was followed, what was judged not relevant, and which searches found nothing

Triage of every lead in the orientation packet, so the report can say honestly what was followed:

In the changed files (all four): #509 (merged) — read, entry 7/8; #474 (closed, same author, replaced by #509) — same four files, the author's earlier attempt at this area (entry 8); #618, #592, #559, #425, #367, #543, #605 (merged/closed, aot.py only) — read via related_items metadata only; none of them changes compile_threads, _DISCRETE_WORKER_DEVICE_BYTES or prepare_many's patch, and none is undone by #639. items_touching(ignition/preparation/compile_pool.py) returns only four items in the last 180 days: #597 (open), #639, #509, #462.

Close topic matches: #122 — read in full, entry 3 (the headroom-as-setting PR; also records main's deliberate removal of per-compiler Inductor threads). #584 — read in full, entries 3 and 8 (closed draft whose review blocker #2 was compiling under the worker cap; the "bundled tracks" criticism). #597 — read in full, entry 8 (open, "Ready To Merge", same files). #242 — read in full, entry 6 (host-RAM admission failure; not addressed by #639). #425 (merged, same author, warmup ordering in the same _prepare_many region) — entry 7.

Named in the packet but judged not relevant, with reason:

Searches that found nothing (recorded so the absence is a finding, not an omission): "daemonic processes are not allowed to have children" → no items; "Inductor compile threads wrong nested daemonic SubprocPool" → none; "compile workers slow host CPU cores idle preparation" → none; "compile threads per worker host CPU affinity worker pool budget" (pr) → none. So no filed bug or request asks for extra Inductor threads per compiler worker, and the daemonic-multiprocessing failure #639 cites has no issue behind it.

#9 [medium] People: original-el8 is a charter priority contributor and prior owner-adjacent; no reviews or comments on #639 at all

#12 [medium] Project fit: matches the hardware target and shared-code placement, but conflicts with "no magic defaults" and the #210 benchmark bar

Where the charter lines up

Where it does not

#14 [medium] Claims and evidence: the repo's CI can only run the CPU path, so 704 MiB and the thread gains rest entirely on author-run GB300 exports

#15 [medium] Community: no comments, reviews, labels or Autobot review; the only reference is #597's overlap list

#19 [medium] Cross-connection: the bundling + unrecorded-switch objection raised on #509 and #584 applies in miniature to #639

A pattern spanning three PRs that matters when deciding #639, since two of the three reviewers raised it independently in the same month:

Countervailing fact for balance: at 58 lines this is genuinely small and the concerns are three adjacent constants/branches in two functions, so the "split it" objection from #509/#584 does not carry the same weight; and original-el8 is a charter priority contributor whose PRs "we never close out of hand as 'low value'". The reviewing question is therefore about the missing main-vs-branch measurement and the undefended 704 MiB / 1 GiB / 8 / 24 numbers, not about volume.