Final review report · NVIDIA/hyperflare-inference #678

Raw Markdown for agents: https://autobot.eidonix.com/p/d54b3c5a-d1b5-476a-8b15-26867744b485.md

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

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Align the PR description with main and cross-reference #670 and #597 (docs/design-review.md:147-162 Principle 16)

    • Verified behavior: ForwardCache._prepare_ranks on main (ignition/preparation/aot.py:1023-1295) has no cache-root agreement check (only forward-catalog key agreement at :1043-1046 and Inductor kernel inventory checks). On main, root divergence causes spawned peers to resolve rank 0's cache-relative paths under their own rootless self.root (aot.py:845-855,1214,1239), failing with FileNotFoundError or silent cache misses. The same-SKU cache-root agreement check ("ranks with GPU ... resolved incompatible forward cache roots") comes from unmerged PR #597 (pr/597 ignition/preparation/aot.py:1054,1068), which also matches the reported 4-GPU mixed-SKU (Max-Q + Workstation) validation rig. In addition, tuning_replicas._replica invokes prepare(..., compile_forwards=False, ...) (ignition/preparation/tuning_replicas.py:160) and exits on TuningComplete, so no in-tree code path in _replica currently instantiates ForwardCache (ignition/preparation/capture.py:117-118, ignition/preparation/bootstrap.py:127-128 (not opened)) or calls source_identity() (ignition/preparation/tuning.py has no references).
    • Fix: Update the PR description to (a) describe the real main failure mode (FileNotFoundError/cache miss on divergent self.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 the rank_group.py hunk), and (c) describe the tuning_replicas.py propagation accurately as defensive spawn-boundary parity rather than claiming replicas compute ForwardCache roots today.
  2. Assert actual ForwardCache.root and/or source_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_peer writes (external / "recipe.py (not opened)").write_text("recipe = 1\n") at :98 (never read or hashed) and only asserts that current_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 than current_source_roots(), so the claimed invariant (rank 0 and spawned peers compute identical ForwardCache roots and source_identity digests) is only verified indirectly.
    • Fix: Inside _record_peer_source_roots (:83-90), also compute aot.ForwardCache(namespace={"model": "example"}, device="cuda:0").root.name (using a local pytest.MonkeyPatch.context() on aot.torch.cuda.get_device_properties as at :44-45) and source_identity(), and assert that rank 0 and rank 1 produce identical digests that differ from the unbound baseline.

Subtract / Simplify

  1. Narrow with source_roots(extra_source_roots): in _peer to the prepare(...) block

    • Location: ignition/preparation/rank_group.py:59-143.
    • Why: Wrapping the entire _peer function 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 through serve_rank (:122) and serve_peer (:126,130). Nothing in _peer after prepare(...) (:60-74) reads _EXTRA_ROOTS or calls source_identity().
    • Fix: Wrap only lines :60-74 (around the if exporting: ... else: model = prepare(...) block, matching pr/670 ignition/preparation/rank_group.py:60-74 and ignition/preparation/tuning_replicas.py:158).
  2. Consider removing the =() default on private spawn targets _peer and _replica

    • Location: ignition/preparation/rank_group.py:44-45, ignition/preparation/tuning_replicas.py:142.
    • Why: Both functions are module-private multiprocessing targets whose other 10 / 7 positional parameters are all required, and each has exactly one production caller (both now passing extra_source_roots). Dropping =() makes omission a TypeError rather than silently reintroducing empty roots, requiring only a 1-line update to tests/preparation/test_native_processes.py:228-229.

Nits

Dropped on verification