Recommendation: Changes Requested
The propagation mechanism itself is sound, minimal, and fixes a real ContextVar loss across mp.get_context("spawn") boundaries for external recipe CLIs without introducing concurrency, memory, or hot-path regressions. However, the PR should not merge as-is because (1) the PR description cites an unmerged cache-root agreement check from PR #597 as the main failure mode, omits cross-references to #597 and priority-contributor PR #670 (which already contains the same rank_group.py fix), and overstates current tuning_replicas reachability (docs/design-review.md Principle 16), (2) the new peer spawn test asserts only ContextVar visibility rather than ForwardCache.root / source_identity() agreement, and (3) wrapping all 85 lines of _peer in rank_group.py creates avoidable re-indentation churn and merge conflicts against #670 and #664.
Merge Risk
Level: Low
- Scoped strictly to external-recipe local spawns: Plain in-tree
ignitioninvocations bind()and retain identicalForwardCachekeys and behavior; external-recipe launches gain consistent_EXTRA_ROOTSpropagation acrossrank_group._peerandtuning_replicas._replicawith picklabletuple[tuple[str, Path], ...]payloads and no new locks, threads, or runtime/ABI changes. - Unnecessary conflict surface in
rank_group.py: Wrapping the entire ~85-line_peerbody (ignition/preparation/rank_group.py:59-143) instead of just the preparation block (:60-74) collides directly with open PR #670 (which already wraps:60-74) and #664, and keeps preparation roots bound throughserve_rank/serve_peer. - No CI run recorded on head
e72ec0d:.github/workflows/python-cpu.yml(not opened) (:30-33) covers these tests underCUDA_VISIBLE_DEVICES="", but no check run exists one72ec0dyet.
Walkthrough
ignition/preparation/source_identity.py:17-19: Addscurrent_source_roots() -> tuple[tuple[str, Path], ...]returning_EXTRA_ROOTS.get().ignition/preparation/rank_group.py:44-45,53,59-143,295-312: Capturesextra_source_roots = current_source_roots()inprepare_group, passes it as the trailingextra_source_roots=()argument to spawned_peerprocesses, and wraps_peer's body inwith source_roots(extra_source_roots):.ignition/preparation/tuning_replicas.py:142,145,158-165,174-176,190-194: Capturesextra_source_roots = current_source_roots()inprepare_recipe, passes it as the trailingextra_source_roots=()argument to spawned_replicaworkers, and enterswith source_roots(extra_source_roots), CoreStorage(...) as storage:before callingprepare(...).tests/preparation/test_forward_cache_sources.py:71-189: Adds three CPU tests coveringcurrent_source_roots()nesting/reset, real-spawnpropagation throughrank_group.prepare_groupover loopback Gloo, and real-spawnpropagation throughtuning_replicas.prepare_recipe(with CUDA/CoreStorage stubbed in the child).
Pre-merge Checks
- [PASS] Security / malicious screen: No unsafe deserialization, prompt injection, shell execution, or credential handling across the 4 changed files; only a
tuple[tuple[str, Path], ...]is passed tomp.get_context("spawn"). - [WARN] Charter & value fit: Right layer, root-cause fix, and minimal runtime footprint without flags or
hyperflare_recipesimports; however, PR prose violatesdocs/design-review.mdPrinciple 16 by citing an unmerged #597 check as themainsymptom and omitting #597/#670 context. - [WARN] Related / duplicate / conflict check: Directly duplicates the
rank_group.pyfix already open in priority contributor@lukealonso's PR #670 (pr/670ignition/preparation/rank_group.py:44-74,295-311, whose review suggested splitting this fix out with a CPU test); also overlaps #664 (rank_group.py) and #668 (tests/preparation/test_forward_cache_sources.py). Coordinate ownership and merge order with #670. - [WARN] Tests & verification evidence: No CI checks have run on
e72ec0d; the peer spawn test checkscurrent_source_roots()rather thanForwardCache.root/source_identity()equality; SM120 2-GPU/4-GPU mixed-SKU runs are author-reported only and depend on unmerged #597.
Blockers
None.
Should Fix
-
Align the PR description with
mainand cross-reference #670 and #597 (docs/design-review.md:147-162Principle 16)- Verified behavior:
ForwardCache._prepare_ranksonmain(ignition/preparation/aot.py:1023-1295) has no cache-root agreement check (only forward-catalog key agreement at:1043-1046and Inductor kernel inventory checks). Onmain, root divergence causes spawned peers to resolve rank 0's cache-relativepathsunder their own rootlessself.root(aot.py:845-855,1214,1239), failing withFileNotFoundErroror silent cache misses. The same-SKU cache-root agreement check ("ranks with GPU ... resolved incompatible forward cache roots") comes from unmerged PR #597 (pr/597ignition/preparation/aot.py:1054,1068), which also matches the reported 4-GPU mixed-SKU (Max-Q + Workstation) validation rig. In addition,tuning_replicas._replicainvokesprepare(..., compile_forwards=False, ...)(ignition/preparation/tuning_replicas.py:160) and exits onTuningComplete, so no in-tree code path in_replicacurrently instantiatesForwardCache(ignition/preparation/capture.py:117-118,ignition/preparation/bootstrap.py:127-128(not opened)) or callssource_identity()(ignition/preparation/tuning.pyhas no references). - Fix: Update the PR description to (a) describe the real
mainfailure mode (FileNotFoundError/cache miss on divergentself.root), (b) cross-reference #597 (disclosing that the cache-root agreement check and 4-GPU mixed-SKU validation included #597) and #670 (stating the intended merge/ownership plan for therank_group.pyhunk), and (c) describe thetuning_replicas.pypropagation accurately as defensive spawn-boundary parity rather than claiming replicas computeForwardCacheroots today.
- Verified behavior:
-
Assert actual
ForwardCache.rootand/orsource_identity()agreement in the spawned-peer test- Location:
tests/preparation/test_forward_cache_sources.py:83-110. - Verified behavior:
test_prepare_group_propagates_source_roots_to_spawned_peerwrites(external / "recipe.py (not opened)").write_text("recipe = 1\n")at:98(never read or hashed) and only asserts thatcurrent_source_roots()returns the same tuple on ranks 0 and 1. Meanwhile,ForwardCache.__init__(ignition/preparation/aot.py:845-847) reads_EXTRA_ROOTS.get()directly rather thancurrent_source_roots(), so the claimed invariant (rank 0 and spawned peers compute identicalForwardCacheroots andsource_identitydigests) is only verified indirectly. - Fix: Inside
_record_peer_source_roots(:83-90), also computeaot.ForwardCache(namespace={"model": "example"}, device="cuda:0").root.name(using a localpytest.MonkeyPatch.context()onaot.torch.cuda.get_device_propertiesas at:44-45) andsource_identity(), and assert that rank 0 and rank 1 produce identical digests that differ from the unbound baseline.
- Location:
Subtract / Simplify
-
Narrow
with source_roots(extra_source_roots):in_peerto theprepare(...)block- Location:
ignition/preparation/rank_group.py:59-143. - Why: Wrapping the entire
_peerfunction body re-indents ~85 lines (turning a ~6-line semantic change into+91/-85), creates a large merge conflict with open PRs #670 and #664, and keeps preparation roots bound throughserve_rank(:122) andserve_peer(:126,130). Nothing in_peerafterprepare(...)(:60-74) reads_EXTRA_ROOTSor callssource_identity(). - Fix: Wrap only lines
:60-74(around theif exporting: ... else: model = prepare(...)block, matchingpr/670ignition/preparation/rank_group.py:60-74andignition/preparation/tuning_replicas.py:158).
- Location:
-
Consider removing the
=()default on private spawn targets_peerand_replica- Location:
ignition/preparation/rank_group.py:44-45,ignition/preparation/tuning_replicas.py:142. - Why: Both functions are module-private
multiprocessingtargets whose other 10 / 7 positional parameters are all required, and each has exactly one production caller (both now passingextra_source_roots). Dropping=()makes omission aTypeErrorrather than silently reintroducing empty roots, requiring only a 1-line update totests/preparation/test_native_processes.py:228-229.
- Location:
Nits
ignition/preparation/aot.py:845-847: Switchfrom .source_identity import _EXTRA_ROOTS/_EXTRA_ROOTS.get()to the newly introducedcurrent_source_roots()so_EXTRA_ROOTSstays private tosource_identity.py.ignition/preparation/source_identity.py:24: Updatesource_roots' docstring ("for the duration of a CLI invocation") to reflect that spawned rank/replica contexts also use it.tests/preparation/test_forward_cache_sources.py:162: Remove the unused(external / "recipe.py (not opened)").write_text("recipe = 1\n")intest_prepare_recipe_propagates_source_roots_to_spawned_tuning_replicaunless the replica callback hashesexternalviasource_identity().- Ensure
.github/workflows/python-cpu.yml(not opened) runs and passes on the updated head commit.
Dropped on verification
- Upstream claim (Correctness F3 / Dossier #3 / Value Prop #5): "Multi-host
ignition joinis still broken/unbounded and short-circuited byrank_group.py:288-290." Dropped as false.join(ignition/cli/__init__.py:153,ignition/cli/serve.py:528-553) runs insideignition.cli.main(..., source_roots=...)(ignition/cli/__init__.py:364-372), and bothHostRendezvous.prepare(ignition/preparation/host_ranks.py:300-385) andserve_peer(host_ranks.py:629-657) run in-process withoutmp.spawn. An external recipe CLI invokingjointherefore already has_EXTRA_ROOTSbound forsource_identity()(serve.py:546) andprepare(...)(host_ranks.py:654-657), and rank 0 must not forward its own local filesystem paths across hosts (host_ranks.py:270-271). - Upstream claim (Correctness F4 / Dossier #4 / Value Prop #3): "Bind
source_rootsbefore_resolve_recipeintuning_replicas._replica(:155vs:158) and propagatecurrent_recipes()." Dropped as false.source_roots(...)(ignition/preparation/source_identity.py:22-30) only sets_EXTRA_ROOTSfor hashing and does not altersys.pathor recipe imports;_resolve_recipe(ignition/preparation/tuning_replicas.py:128-139) resolves external recipes viaimportlib.import_module(prepare.__module__)and neither_resolve_recipenorPlan.__post_init__(ignition/planning.py:171-215) reads_EXTRA_ROOTS. Propagatingcurrent_recipes()acrossspawnis also deliberately avoided becauseRecipeinstances contain unpicklable lambdas (hencetuning_replicas.py:183stripsrecipebefore pickling). - Upstream claim (Correctness F7 / Dossier #4 / Value Prop #5): "Undeclared artifact change in peer-written
rebuild_manifest(rebuild_manifest.py:327)." Dropped as false.rebuild_manifest.from_plan(ignition/preparation/rebuild_manifest.py:286-335, callingsource_identity()at:327) is only called on rank 0 (ignition/cli/serve.py:237,338). Peerexport_model(ignition/preparation/runtime_core.py:350,432-434) only invokesrebuild_weights_metadataandweight_payload_request(rebuild_manifest.py:418-460), neither of which callssource_identity(). - Upstream claim (Correctness F2): Demand to delete the
tuning_replicas.pyhunk because it has no current in-tree consumer. Softened: verified that_replicapassescompile_forwards=Falseand reaches no in-treeForwardCache/source_identity()call today, but the ~8-line spawn-boundary parity is harmless and chains cleanly for TP>1 tuning replicas; only the overstated PR claim requires fixing (moved into Should Fix #1). - Upstream claim (Subtraction #1): Framing
extra_source_roots=()as a charter "magic default" violation. Dropped the charter-violation framing as overstated (source_roots(),source_identity(), andcli.main()all default to()); retained the simpler required-argument suggestion underSubtract / Simplify. - Upstream claim (Correctness F6): Flagging
world_size ×disk reads of external*.pyfiles inForwardCache.__init__. Dropped as low-signal:aot.py:837-844already readsignition/andflashinfer/*.pytrees on every rank, and reading a small external recipe tree from OS page cache adds negligible overhead.