Recommendation: Changes Requested
PR #668 cleanly addresses three real multi-host preparation defects—request-name-first selection reconciliation (collectives.py), peer b12x_environment propagation and local kernel_cache remapping (host_ranks.py, serve.py), and ForwardCache B12X env keying plus atomic .bin persistence (aot.py)—with no hard blockers. However, ForwardCache._load's corrupt-cache handler (aot.py:64-76, 1371-1380) is overly broad (silently unlinking valid artifacts on transient OSError / non-OOM RuntimeError with no log and risking an uncaught OSError on read-only caches), the new serve_peer test (test_host_ranks.py:361-362, 426-438) leaks B12X_* variables into process-global os.environ across subsequent pytest tests, and Fixes #651 is not yet confirmed on live 2× GB10 hardware. Tightening _load's error handling, fixing the test env leak and coverage gaps, and trimming the redundant env channel / atomic-save duplication will make this ready to merge.
Merge Risk
Level: Medium
- Preparation-only blast radius (no Helios serving/wire-format impact): All changes stay in
ignition/preparation/andignition/cli/serve.py; no Rust runtime, Protobuf schema, or exported model-core format changes. - Cache invalidation & corrupt-recovery blast radius: Hashing
_b12x_forward_env()intoForwardCache.root(aot.py:897-899) will trigger a one-time recompile for recipes that declareb12x_environment(e.g., GLM-5.3, Kimi), and_load(..., required=False)now destructively unlinks cached.binfiles on caught exceptions (aot.py:1376-1380). - Active merge-overlap with open PRs: Same-author PR #667 also edits the peer export
export_options(...)block inignition/preparation/host_ranks.py:718-719, and #597 editsForwardCachekeying and_share_artifactsinignition/preparation/aot.py.
Walkthrough
- Request-name-first reconciliation (
ignition/preparation/collectives.py:196-224, 398-449):_selected_plan_catalognow records(request.name, variant, plan.component_id)alongsideportable_declaration(plan).reconcile_selectionsprefers sharedname_keymatches before falling back todecl_keymatches, using onetarget_forhelper for bothchangedandconfigsso all ranks enter or skip the reconcile pass in lockstep while preserving component-ID safety and DCP subgroup independence (request.collective is None). - Peer
b12x_environment& localkernel_cache(ignition/preparation/host_ranks.py:201-239, 313-381, 625-720;ignition/cli/serve.py:197, 420, 554):HostRendezvousaccepts and validatesmodel.recipe.b12x_environment(wired from_export_hostsanddebug_serve), transmits it to peers before assignment unpickling (and again insideassignment), andserve_peerapplies it, remapsconfig.kernel_cacheto the peer's localkernel_cachepassed byjoin, and forwardskernel_cacheinto peerexport_options. ForwardCachekeying, atomic writes, and corrupt-.binrecovery (ignition/preparation/aot.py:47-100, 870-877, 897-899, 1326, 1371-1380, 1454, 1463):ForwardCache.__init__hashes execution-relevantB12X_*env vars via_b12x_forward_env(), replaces all three directsave_compiled_function(str(path))sites with sibling-temp_save_compiled_function, adds temp cleanup in_share_artifacts, and treats_CORRUPT_ARTIFACT_ERRORSin_load(..., required=False)as a cache miss withunlink.- Tests (
tests/preparation/test_tuning_shards.py:264-325,test_host_ranks.py:334-438,test_forward_cache_sources.py:65-140,test_forward_artifact_sharing.py:130-154, 261-262): Adds a 2-rank Gloo reconcile test, rendezvous env validation andserve_peerenv/cache-remapping tests,ForwardCacheB12X keying / atomic save / corrupt-load tests, and updates_Artifact.save_compiled_functionto write real payload bytes.
Pre-merge Checks
- [PASS] Security / malicious screen: No credential handling, shell injection, or untrusted input escalation;
_validate_b12x_environmentrestricts peer env updates to non-cacheB12X_*string bindings. - [PASS] Charter & value fit: Stays cleanly in Ignition preparation/CLI with no per-model branches or runtime flags and targets a reproducible cross-node bug (#651), though
_CORRUPT_ARTIFACT_ERRORScurrently stretches the charter's rule against silently swallowing unexplained errors (#397). - [WARN] Related / duplicate / conflict check: Not superseded by
main(no commits since branch point touch these files), but coordinates with open same-author PR #667 onhost_ranks.py:718-719and open PR #597 onaot.py. - [WARN] Tests & verification evidence: CPU preparation (192) and CLI (136) suites passed locally against paired
flashinfer#199, but live 2× GB10 TP2 GLM-5.3export+join(the #651 repro) and GPU tests were not run, CI ond4d7b2dis pending, and the newserve_peertest leaks env vars across tests.
Blockers
None.
Should Fix
-
Narrow
_CORRUPT_ARTIFACT_ERRORS, log dropped artifacts, and guardunlink(ignition/preparation/aot.py:64-76, 1371-1380)._load(..., required=False)wraps bothpath.open('rb')andtorch.compiler.load_compiled_function(file)(which runs_load_inductorataot.py:103-144, including Triton cubin disk writes, CUDA module deserialization, and Ignition's ownValueError/RuntimeErrorcontract checks at lines 111 and 128) insideexcept _CORRUPT_ARTIFACT_ERRORS, which includesOSErrorandRuntimeError.- Any transient I/O error (
EIO,ENOSPC,EMFILE) or non-OOM CUDA driverRuntimeErrorsilently deletes a valid compiled.binarchive with no warning and forces a full recompile. On a read-only cache (EROFS/EACCES),Path(path).unlink(missing_ok=True)at line 1379 raises an uncaughtOSErrorfrom inside the handler, turning a recoverable miss into a hard crash. - In addition,
MemoryErrorinisinstance(error, (MemoryError, torch.OutOfMemoryError))at line 1377 is unreachable becauseMemoryErroris not a subclass of any member of_CORRUPT_ARTIFACT_ERRORS(onlytorch.OutOfMemoryError, aRuntimeErrorsubclass, can reach line 1377). - Fix: Keep
path.open('rb')outside the corrupt-archive handler (or handleFileNotFoundErrorseparately), narrow_CORRUPT_ARTIFACT_ERRORSto genuine archive/deserialization errors (EOFError,pickle.UnpicklingError,struct.error,zlib.error,zipfile.BadZipFile, plus only the specificValueError/RuntimeErrorraised by truncatedtorch.compiler.load_compiled_functionheaders if observed—not blanketOSError/RuntimeError), emit a warning namingpathanderrorbefore unlinking, wrapPath(path).unlink(missing_ok=True)intry/except OSError, and drop the deadMemoryErrorcheck (keepingtorch.OutOfMemoryErroronly ifRuntimeErrorremains in the tuple).
-
Fix the process-global
os.environleak and test gaps (tests/preparation/test_host_ranks.py:361-362, 426-438;tests/preparation/test_forward_cache_sources.py:136-140).- In
test_serve_peer_applies_b12x_environment_and_remaps_kernel_cache,monkeypatch.delenv("B12X_W4A16_A4_PREFILL", raising=False)andmonkeypatch.delenv("B12X_W4A16_SMALL_M_HOST_BARRIER_RESET", raising=False)are no-ops when those keys are initially absent, so pytest registers no teardown restoration.serve_peerthen callsos.environ.update(...)directly, leaking bothB12X_*variables intoos.environfor all subsequent tests in the same pytest worker—which directly perturbs_b12x_forward_env()andForwardCache.rootin later tests. - In
test_forward_cache_recovers_from_corrupt_cached_bin_on_restore(test_forward_cache_sources.py:136-140), mockingMemoryErrornever enters theexcept _CORRUPT_ARTIFACT_ERRORSblock, leaving thetorch.OutOfMemoryErrorcarve-out ataot.py:1377untested. - Neither
host_ranks.py:718-719(forwardingkernel_cacheinto peerexport_options) norreconcile_selectionsreturningchanged is Falseon agreeing ranks is covered by a test. - Fix: Restore
os.environintest_serve_peer_applies_b12x_environment_and_remaps_kernel_cache(e.g.,monkeypatch.setenv(k, "")followed bymonkeypatch.delenv(k), or restore infinally:), testtorch.OutOfMemoryErrorintest_forward_cache_sources.py, and add focused assertions for peerexport_options(..., kernel_cache=...)andreconcile_selectionswith agreeing ranks (changed is False).
- In
-
Do not auto-close #651 before live 2× GB10 verification.
- #647 previously auto-closed #631 without resolving the live 2× GB10 GLM-5.3 failure, which led to #651. As the PR description candidly notes, live 2-host GB10 TP2
export+joinof GLM-5.3 has not yet been run here, and CI runs againstflashinfermainrather than pairedflashinfer#199. - Fix: Either confirm convergence on live 2× GB10 GLM-5.3 before merge, or change
Fixes #651toRelated: #651in the PR body until verified on hardware (and note the expected one-timeForwardCachere-key for recipes withb12x_environment).
- #647 previously auto-closed #631 without resolving the live 2× GB10 GLM-5.3 failure, which led to #651. As the PR description candidly notes, live 2-host GB10 TP2
Subtract / Simplify
-
Collapse the duplicate
b12x_environmenttransmission and remove the unusedprepare(..., b12x_environment=None)parameter (ignition/preparation/host_ranks.py:313-314, 325-326, 377, 666-668;tests/preparation/test_host_ranks.py:400-412).HostRendezvous.preparesends("b12x-environment", b12x_env)at lines 345-347 beforeassignment = receive_object(control)(line 665, which unpicklesassignment["prepare"]and imports the recipe and its b12x operator modules), and then sends the exact same dict again insideassignment["b12x_environment"]at line 377 whereserve_peervalidates and applies it a second time at lines 666-668. Because the early command is always sent wheneverb12x_envis non-empty, theassignmentcopy can never carry anything new (the test attest_host_ranks.py:400-412only exercises both paths by fabricating different dicts thatHostRendezvous.preparecannot produce).- Separately,
b12x_environment=NoneonHostRendezvous.prepare(host_ranks.py:314, 325-326) has no caller (ignition/preparation/rank_group.py:286callsranks.prepare(...)without it). - Fix: Keep the early
("b12x-environment", b12x_env)command as the single channel, drop"b12x_environment"fromassignmentand lines 666-668, remove the unusedb12x_environment=Nonekwarg fromHostRendezvous.prepare(usingself.b12x_environmentdirectly), and update theserve_peertest to assert one realistic message.
-
Consolidate duplicated atomic-write blocks and fix the open-handle
unlinkin_share_artifacts(ignition/preparation/aot.py:90-100, 270-277, 870-877, 1185-1192;ignition/preparation/compile_pool.py:115-123)._save_compiled_function(aot.py:90-100) is byte-identical tocompile_pool.py:115-123(which already imports from.aotat line 104), andaot.pyretains three inlineNamedTemporaryFile+os.replace+unlinkblocks (:270-277,:870-877,:1185-1192), including the one this PR edited at:870-877.- Moreover, at
aot.py:870-877,try: ... finally: temporary.unlink(missing_ok=True)sits insidewith tempfile.NamedTemporaryFile(...) as file:, so iffile.writefails beforefile.close(), the handle is still open duringunlink(which raisesPermissionErroron Windows and masks the original write error). - Fix: Have
compile_pool.py:115-123call_save_compiled_function, and movetry/finallyoutside thewithblock ataot.py:870-877(or extract one shared atomic-write helper inaot.py).
Nits
- Wire protocol version hygiene (
ignition/preparation/host_ranks.py:41):PROTOCOLstays5while adding the new("b12x-environment", b12x_env)control message. In CLI usage,source_identity()(source_identity.py:95) hashes all ofignition/includinghost_ranks.pyand rejects mismatched checkouts in_admit(host_ranks.py:292-293), so stale peers cannot reachprepare(). Still, bumpingPROTOCOLto6keeps the wire-version constant accurate for any caller passing a customidentity. - Nested composite variant key (
ignition/preparation/collectives.py:212-215): Passing(variant, count)instead of overwritingvariantwithcountmakesname_keycollision-free even if composite plans are ever nested. - Deduping
decl_keyinreconcile_selections(ignition/preparation/collectives.py:409-412): Flatteninglocalsends duplicatedecl_keytuples across layers instead of deduplicating them as before; on a ~1.5k-request catalog this is only a few MiB once at the end of tuning, but interning uniquedecl_keys beforeall_gather_objectwould keep the wire payload small. - Docs (
docs/multi-host.md): Consider a short note that rank zero now propagatesrecipe.b12x_environmentand each peer uses its own localkernel_cache.
Dropped on verification
- Correctness F1 (Blocker: stale peer passes
_admitand crashes on("b12x-environment", ...)): Downgraded to a Nit. Verified inignition/preparation/host_ranks.py:292-293,ignition/cli/serve.py:193, 416, 548, andignition/preparation/source_identity.py:44-49, 95thatsource_identity()hashes the entireignition/tree (includinghost_ranks.py), so mismatched checkouts are already rejected during_admitbeforeprepare()runs. - Correctness F4 (Minor:
B12X_COMPILE_CACHE_DIRrejected inHostRendezvous.__init__causing peers to retryknockfor 600 s): Dropped. Failing fast on rank zero before binding the listener matches every other pre-rendezvous check in_export_hosts(serve.py:180-192), and no recipe setsB12X_COMPILE_CACHE_DIR. - Correctness F5 (Major:
tuning.py:504-518re-prepares all jobs unsharded and passesselected_configs={}): Dropped.ignition/preparation/tuning.pyis untouched by PR #668 (introduced in #647); Pass 2 hits warm selection caches for unchanged plans rather than repeating cold 2h15m autotuning; and F5's proposed fix ("iterate only over jobs whoseplans ∩ configsis non-empty") would deadlock rank 0 (whereconfigs == {}) against rank 1 (whereconfigsis non-empty) inside collectivecoordinator.prepare. - Correctness F6 (Major:
tuning.py:551-564double-countstuning_report): Dropped. Pre-existingtuning.pybehavior from #647, untouched by PR #668 (and summingelapsed_secondsacross both passes is accurate wall time). - Correctness F7 (Major/Minor: memory-critical all-gather blowup in
collectives.py:409-412): Downgraded to a Nit; ~1.3k small tuples is a few MiB once per preparation run, not a GB10 OOM hazard. - Correctness F8 (Minor: replace ambient
_b12x_forward_env()with recipe-onlyb12x_environment): Dropped. VerifiedForwardCacheis constructed inignition/preparation/capture.py:118without the recipe object, and hashing ambient execution-relevantB12X_*flags also protects manual CLI/benchmark overrides from silently colliding inForwardCache. - Correctness F9's claim that the early
("b12x-environment", ...)command cannot precede import-time reads: Corrected and narrowed. Verified inignition/cli/environment.py:74andignition/runtime_patches/workers.py:27thatenvironment.applyatserve.py:547importsb12x.preparation, not the recipe module or itsb12xoperator/kernel modules—those are imported duringassignment = receive_object(control)(host_ranks.py:665), so the early command genuinely runs before recipe/operator imports while theassignmentcopy is the redundant one. - Subtraction 3 (collapse
_validate_b12x_environmentbecauseRecipe.__post_init__already validates): Dropped.HostRendezvousandserve_peeraccept arbitrary dicts (including over the wire) rather thanRecipeinstances, so keeping a 9-line validation helper beforeos.environ.updateis sensible boundary hygiene. - Subtraction 4 (delete
_remap_peer_config'ssetattrfallback as unreachable): Dropped. Model recipes live in an external repository (local-inference-lab/hyperflare-recipes, perAGENTS.md:9-13), so a 2-line fallback for mutable non-dataclass configs cannot be proven unreachable from this repo alone.