Recommendation: Changes Requested
PR #597 addresses a real gap in tensor-parallel forward preparation for mixed-SKU same-architecture SM120 workstations (fixing cross-SKU paths[name, variant] sharing, per-(host, root) publication locking, same-SKU lending, and per-(variant, gpu_name) Inductor inventory checks), while keeping homogeneous-GPU paths clean. However, it introduces a confirmed non-monotonic memory-admission and overcommit bug in allocate_workers (ignition/preparation/compile_pool.py:96-118) where a 2-SKU host with 12–39 GiB available RAM admits two concurrent 32 GiB compilers while 40–41 GiB raises MemoryError, alongside an unnecessary on-disk filename suffix that breaks homogeneous/mixed cache reuse inside already-per-SKU cache roots, a multi-host _share_artifacts lock-bypass hazard, stale docs, and missing main failure reproduction / isolated preparation evidence.
Merge Risk
Level: Medium
allocate_workers(ignition/preparation/compile_pool.py:96-118) runs on every distributed forward compilation; while homogeneous hosts (len(active_groups) == 1) preserve existing behavior, mixed-SKU hosts can concurrently overcommit host RAM (64 GiB estimated peak on 12–42 GiB available) or hit a non-monotonicMemoryErrorat 40–41 GiB.ForwardCache._prepare_ranks(ignition/preparation/aot.py:939-944) changes on-disk artifact filenames whenever any peer in the TP group has a different GPU product name, preventing cache reuse between homogeneous and mixed runs on the same card; on multi-host mixed-SKU runs,_share_artifacts(aot.py:698-734, 1103, 1169) writes foreign-SKU artifacts into unlocked cache roots.- No Python CI workflow runs
tests/preparation, andtests/preparation/test_inductor_tuning_cuda.pywas not run against the change.
Walkthrough
ignition/preparation/inductor_tuning.py: Adds_cuda_device_identity(device)(:21-26) returning(product_name, compute_capability)(or("", None)for non-CUDA), and updatesInductorSelections.warm(:247-260) to key inventory agreement by(compilation_variant, gpu_name)and reject cross-architecture capabilities.ignition/preparation/aot.py: UpdatesForwardCache._publication_lock(:774-811) to gather(host, str(self.root.resolve()))and acquirepublication.lockper distinct pair in deterministic sorted order with per-key barriers; updatesForwardCache._prepare_ranks(:929-1010, 1112, 1131, 1154) to gather(gpu_name, capability), reject cross-architecture groups, suffixcompilation_variantwith a normalizedgpu_tagwhen multiple GPU names appear, passgroups=gpu_namestoallocate_workers, and restrict compilation lending to(host, gpu_name)peers.ignition/preparation/compile_pool.py: Addsgroups=Nonetoallocate_workers(:62-128), raisingValueErroriflimit < len(active_groups), seeding one worker per active(host, group)subgroup (with a per-subgroup 2 GiB fallback), raisingMemoryErrorif any active subgroup remains empty, and distributing surplus workers across active subgroups.tests/preparation/test_mixed_gpu_inductor_keying.py: Adds 13 CPU-only unit tests using forked Gloo processes and monkeypatchedForwardCache/InductorSelectionsstubs covering mixed-SKU keying, lending isolation, worker seeding, multi-root publication locking, homogeneous un-suffixed sharing, cross-architecture rejection, and Inductor inventory mismatches.
Pre-merge Checks
- [PASS] Security / malicious screen: No prompt injection, shell execution, credential exposure, or unsafe deserialization introduced across the 4 changed files.
- [PASS] Charter & value fit: Lives in shared
ignition/preparation, targets SM120 workstation TP preparation with no new flags, env vars, or per-model branches, and tightens architecture/SKU invariants; however, evidence does not yet meet the charter's root-cause/before-after bar. - [WARN] Related / duplicate / conflict check: Additive to
main(no merged PR covers this layer, andmain'sreconcile_selectionsalready handles the b12x tuning half from #150), but overlaps open PRs #122 (compile_pool.py,aot.py) and #592 (aot.py,compile_pool.py) and imports private helpers fromtests/preparation/test_forward_artifact_sharing.py. - [WARN] Tests & verification evidence: No Python CI exists; "96 passed" has no attached command/output; no
mainfailure reproduction or isolated preparation measurement is provided;tests/preparation/test_inductor_tuning_cuda.pywas not run; and the new tight-budget test only checks 40 GiB, missing the 12–39 GiB and 42 GiB overcommit bug.
Blockers
- Non-monotonic memory admission and concurrent RAM overcommit in
allocate_workers(ignition/preparation/compile_pool.py:96-118).- Verified behavior & impact: The 2 GiB minimum-allowance fallback (
worker_bytes - FORWARD_WORKER_BYTES + _WORKER_BYTES, which equals2 GiBfor discrete GPUs perignition/preparation/host_memory.py:13-15) now runs insidefor subgroup in active_groups:instead of once per host when zero workers were admitted. On a 2-SKU discrete host (worker_bytes = 32 GiB,headroom = 8 GiB):- At
available = 12..39 GiB(remaining = 4..31 GiB), subgroup 0 misses the 32 GiB primary path and takes the 2 GiB fallback, then subgroup 1 also takes the 2 GiB fallback — admitting 2 concurrent compiler workers (64 GiB conservative concurrency demand) on as little as 12 GiB available RAM, directly contradicting the inline comment"without multiplying that allowance"(compile_pool.py:105-106). - At
available = 40..41 GiB(remaining = 32..33 GiB), subgroup 0 takes the 32 GiB primary path (remaining = 0..1 GiB), leaving subgroup 1 under 2 GiB, so admission raisesMemoryErroreven though 12–39 GiB succeeded (non-monotonic!). - At
available = 42..71 GiB(remaining = 34..63 GiB), subgroup 0 takes 32 GiB and subgroup 1 takes the 2 GiB fallback — again admitting 2 concurrent workers on 42 GiB available RAM. tests/preparation/test_mixed_gpu_inductor_keying.py:155-158only tested40 GiB(right inside the 2 GiB failure hole), which masked the bug.
- At
- Concrete fix: Keep the 2 GiB minimum-allowance fallback strictly for a single worker on the host (
len(active_groups) == 1, preservingmain's invariant), and require fullresources[rank].worker_bytesfor every seeded worker whenlen(active_groups) > 1(or compile active SKU subgroups sequentially when host RAM fits only one worker). Add unit tests covering12 GiB,39 GiB,40 GiB,42 GiB,71 GiB, and72 GiBfor 2 active SKU groups.
- Verified behavior & impact: The 2 GiB minimum-allowance fallback (
Should Fix
- Unnecessary on-disk
gpu_tagfilename suffix breaks homogeneous/mixed cache reuse and forks GPU identity (ignition/preparation/aot.py:939-944, 967, 1024, 1065vsaot.py:750-763andignition/preparation/inductor_tuning.py:248).ForwardCache.__init__(aot.py:750-763) already hashesproperties.nameintoself.root, so distinct GPU product names never share a cache directory in production. The cross-SKU sharing bug onmainoccurred only because_variant_compilersandpaths[name, variant]keyed oncompilation_variantalone.- Suffixing
_variant(forward)with a normalizedgpu_tagwhenheterogeneous = len(set(gpu_names)) > 1also changesname=f"{name}.{variant}"passed to_restore/_path, causing the exact same GPU card to write different.binhashes in the sameself.rootdepending on its peers (e.g., homogeneous TP2 vs mixed TP4 on the same Workstation card, or a homogeneous host paired with a different-SKU peer host). It also splits GPU identity into normalizedgpu_tag(aot.py:940) vs rawgpu_name(aot.py:996, 1000-1004;inductor_tuning.py:248). - Concrete fix: Remove
heterogeneousandgpu_tag. Keyselections,compilers, andpathsin_prepare_ranksby(base_variant, gpu_name)(matchingInductorSelections.warmand working natively with_variant_compilersataot.py:657-670), while passingname=f"{name}.{base_variant}"toself._restoreandself._path. Intest_mixed_gpu_inductor_keying.py, give each SKU its owncache.root(mirroringForwardCache.__init__) and assert cache reuse between homogeneous and mixed runs on the same GPU.
- Multi-host mixed-SKU
_share_artifactswrites foreign-SKU artifacts into unlocked cache roots (ignition/preparation/aot.py:698-734, 1102-1104, 1168-1169vs:788-804)._publication_lockacquirespublication.lockonly for(host, self.root.resolve())pairs present on each host. Whencoordinator.spans_hostsis True,_share_artifactsstill marks every path compiled on any other rank asmissingand writes it viatarget.parent.mkdir+os.replace(aot.py:718-733). On a multi-host mixed-SKU launch where Host B has no rank of Host A's SKU, Host B transfers unused artifacts and writes into that foreign SKU's cache directory without holding itspublication.lock.- Concrete fix: Filter
missingin_share_artifactsso each rank only fetches artifacts under its ownself.root(or paths it selects frompaths[name, variant]).
- Update stale documentation for worker admission, lending, and cache sharing (
docs/model-preparation.md:231-245,docs/preparation-development.md:351-371).docs/model-preparation.md:231-245still states that ranks lend missing forwards to any other rank on the host, describes a host-wide 2 GiB minimum allowance, and does not mention the per-active-SKU seeding orValueErrorwhen the host worker limit is below the active group count.docs/preparation-development.md:351-371still states "Ranks on one host share its cache directory" and "Every rank loads the same artifacts."- Concrete fix: Update both passages to document per-
(host, GPU product name)cache roots, same-SKU lending, per-active-group worker admission, and per-(variant, GPU name)Inductor validation.
- Provide a
mainfailure reproduction and isolated preparation-stage verification.- Attach the concrete failure observed on current
mainfor the mixed-SKU SM120 export, an isolated preparation comparison (mainvs this branch: compile phase outcome, wall clock, and admitted workers), and the exactpytestcommand/output (and runtests/preparation/test_inductor_tuning_cuda.pyif hardware is available, or explicitly note it as unrun).
- Attach the concrete failure observed on current
Subtract / Simplify
- Delete the unreachable duplicate cross-architecture gate in
InductorSelections.warm(ignition/preparation/inductor_tuning.py:249-255andtests/preparation/test_mixed_gpu_inductor_keying.py:326-340).- Every coordinator-backed
InductorSelectionsis constructed solely insideForwardCache._prepare_ranks(ignition/preparation/aot.py:1122), ~185 lines afteraot.py:933-938already rejects cross-architecture ranks on the samecoordinatorandself.device. Every other call site (aot.py:835, 1256,scripts/inspect_forward_kernels.py:93(not opened)) passescoordinator=None, where_gatherreturns[value](inductor_tuning.py:129-131). Droppingcapabilityfromwarm's gather payload removes the dead check and its stub-only test while keeping cross-architecture coverage intest_cross_architecture_ranks_are_rejected_before_forward_sharing.
- Every coordinator-backed
- Simplify
allocate_workersby removing the redundantgroups is Nonebranch andadmittedcounter (ignition/preparation/compile_pool.py:75-85, 94, 103, 115, 120).- Normalizing
groups = hosts if groups is None else groupscollapsesif groups is None:cleanly into the singleactive_groupscomprehension (sincejobs > 0is already enforced at:73-74). - After the
MemoryErrorcheck at:116-118, every active subgroup has received exactly 1 worker, soadmittedalways equalslen(active_groups); deleteadmittedand userange(limit - len(active_groups))at:120.
- Normalizing
- Eliminate duplicated test harness and copy-pasted tag normalization (
tests/preparation/test_mixed_gpu_inductor_keying.py:23-122).- Once Should Fix 1 removes
gpu_tag, lines:65-70(which re-implementaot.py:940verbatim) disappear. Consider extending_lending_rankintests/preparation/test_forward_artifact_sharing.py:171-252(from which this file already imports four private fixtures at:17) instead of duplicating the fork/Gloo setup.
- Once Should Fix 1 removes
Nits
ignition/preparation/aot.py:925imports private_cuda_device_identityacross modules; expose it without a leading underscore (e.g.,cuda_device_identityindevice_binding.pyorinductor_tuning.py).ignition/preparation/compile_pool.py:112usesworkers[rank] = 1whereas:101usesworkers[rank] += 1; prefer+= 1for consistency if the fallback stays forlen(active_groups) == 1.ignition/preparation/compile_pool.py:89-92raisesValueErrorif a host's effective CPU worker limit (e.g., from a 1-CPUsched_getaffinity/cgroup mask orcompile_threads=1) is smaller thanlen(active_groups)on a mixed-SKU host; mention this constraint when updatingdocs/model-preparation.md.
Dropped on verification
- Upstream claim that the PR's premise of cross-SKU artifact sharing on
mainis false (C1): Verified false. AlthoughForwardCache.roothashesproperties.name(aot.py:750-763),_prepare_ranksonmainassigned one compiler per(name, compilation_variant)across all ranks and all-gathered the compiling rank's absolute path inpaths[name, variant](aot.py:947-952, 1100, 1131), causing different-SKU peers to load from the compiling rank's root. Dropped C1 and kept the verified cache-reuse defect (Should Fix 1). - Upstream claim that this PR still depends on open PR #150 for mixed-SKU tuning agreement (C3 / Discovery / Value Prop): Verified false.
mainalready reconciles b12x kernel tuning across mixed-SKU ranks viareconcile_selections(ignition/preparation/tuning.py:500-508,ignition/preparation/collectives.py:397-426), which is why PR #150's review was halted as already fixed another way. - Upstream claim that
--compile-workers 1on a mixed-SKU CLI run used to succeed and now raisesValueError(Discovery / Value Prop / S5): Verified false for CLI.ignition/cli/preparation.py:85-86already rejects--compile-workers < world_sizeas aUsageError; theValueErroris only reachable via tight CPU affinity/cgroup limits,compile_threads, or direct Python calls. - Upstream claim that per-group
MemoryErrorbreaks mixed-SKU hosts that previously compiled serially onmain(B2): Overstated — mixed-SKU hosts did not prepare cleanly onmain, and homogeneous hosts (len(active_groups) == 1) retain identical behavior. Replaced by the verified non-monotonic overcommit bug (Blocker 1). - Upstream claim that a CUDA-unavailable rank is misreported as incompatible CUDA architectures (A1 — Major): Dropped as unreachable/low-signal in production:
ForwardCache.__init__(aot.py:750) unconditionally callstorch.cuda.get_device_properties(device)before_prepare_ranksruns; the("", None)path exists for CPU-only tests (test_forward_artifact_sharing.py:229, 408), and the error prints[(12, 0), None]. - Upstream claim that
_balance_compilations's error message (aot.py:681-682) misreports per-SKU failure as host-wide (B4): Dropped as unreachable from_prepare_ranksbecauseallocate_workers(compile_pool.py:116-118) already enforces at least one worker per active subgroup beforehand. - Upstream claim that
docs/model-preparation.md:203-209is contradicted by this PR (C4 / S5): Verified false — lines 203-209 describe b12x kernel tuning sharding on identical GPUs (tuning.py:440-441), which is unchanged and remains accurate. - Upstream claim that tests erroneously assert 8 vs 4 artifacts for mixed vs homogeneous hosts (D2): Dropped — compiling 4 forwards per distinct SKU (8 total) is expected when 2 SKUs compile distinct forward inventories; the real issue is filename suffixing breaking homogeneous/mixed cache reuse (Should Fix 1).
- Upstream note about missing
Signed-off-by/Design-Signed-Off-Bytrailers: Dropped as unverified because full commit message trailers were not observable in available tool output.