Final review report · NVIDIA/hyperflare-inference #668

Raw Markdown for agents: https://autobot.eidonix.com/p/6437e3bb-abe9-4271-8026-bda87797c1ae.md

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

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Narrow _CORRUPT_ARTIFACT_ERRORS, log dropped artifacts, and guard unlink (ignition/preparation/aot.py:64-76, 1371-1380).

    • _load(..., required=False) wraps both path.open('rb') and torch.compiler.load_compiled_function(file) (which runs _load_inductor at aot.py:103-144, including Triton cubin disk writes, CUDA module deserialization, and Ignition's own ValueError/RuntimeError contract checks at lines 111 and 128) inside except _CORRUPT_ARTIFACT_ERRORS, which includes OSError and RuntimeError.
    • Any transient I/O error (EIO, ENOSPC, EMFILE) or non-OOM CUDA driver RuntimeError silently deletes a valid compiled .bin archive 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 uncaught OSError from inside the handler, turning a recoverable miss into a hard crash.
    • In addition, MemoryError in isinstance(error, (MemoryError, torch.OutOfMemoryError)) at line 1377 is unreachable because MemoryError is not a subclass of any member of _CORRUPT_ARTIFACT_ERRORS (only torch.OutOfMemoryError, a RuntimeError subclass, can reach line 1377).
    • Fix: Keep path.open('rb') outside the corrupt-archive handler (or handle FileNotFoundError separately), narrow _CORRUPT_ARTIFACT_ERRORS to genuine archive/deserialization errors (EOFError, pickle.UnpicklingError, struct.error, zlib.error, zipfile.BadZipFile, plus only the specific ValueError/RuntimeError raised by truncated torch.compiler.load_compiled_function headers if observed—not blanket OSError/RuntimeError), emit a warning naming path and error before unlinking, wrap Path(path).unlink(missing_ok=True) in try/except OSError, and drop the dead MemoryError check (keeping torch.OutOfMemoryError only if RuntimeError remains in the tuple).
  2. Fix the process-global os.environ leak 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) and monkeypatch.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_peer then calls os.environ.update(...) directly, leaking both B12X_* variables into os.environ for all subsequent tests in the same pytest worker—which directly perturbs _b12x_forward_env() and ForwardCache.root in later tests.
    • In test_forward_cache_recovers_from_corrupt_cached_bin_on_restore (test_forward_cache_sources.py:136-140), mocking MemoryError never enters the except _CORRUPT_ARTIFACT_ERRORS block, leaving the torch.OutOfMemoryError carve-out at aot.py:1377 untested.
    • Neither host_ranks.py:718-719 (forwarding kernel_cache into peer export_options) nor reconcile_selections returning changed is False on agreeing ranks is covered by a test.
    • Fix: Restore os.environ in test_serve_peer_applies_b12x_environment_and_remaps_kernel_cache (e.g., monkeypatch.setenv(k, "") followed by monkeypatch.delenv(k), or restore in finally:), test torch.OutOfMemoryError in test_forward_cache_sources.py, and add focused assertions for peer export_options(..., kernel_cache=...) and reconcile_selections with agreeing ranks (changed is False).
  3. 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+join of GLM-5.3 has not yet been run here, and CI runs against flashinfer main rather than paired flashinfer#199.
    • Fix: Either confirm convergence on live 2× GB10 GLM-5.3 before merge, or change Fixes #651 to Related: #651 in the PR body until verified on hardware (and note the expected one-time ForwardCache re-key for recipes with b12x_environment).

Subtract / Simplify

  1. Collapse the duplicate b12x_environment transmission and remove the unused prepare(..., 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.prepare sends ("b12x-environment", b12x_env) at lines 345-347 before assignment = receive_object(control) (line 665, which unpickles assignment["prepare"] and imports the recipe and its b12x operator modules), and then sends the exact same dict again inside assignment["b12x_environment"] at line 377 where serve_peer validates and applies it a second time at lines 666-668. Because the early command is always sent whenever b12x_env is non-empty, the assignment copy can never carry anything new (the test at test_host_ranks.py:400-412 only exercises both paths by fabricating different dicts that HostRendezvous.prepare cannot produce).
    • Separately, b12x_environment=None on HostRendezvous.prepare (host_ranks.py:314, 325-326) has no caller (ignition/preparation/rank_group.py:286 calls ranks.prepare(...) without it).
    • Fix: Keep the early ("b12x-environment", b12x_env) command as the single channel, drop "b12x_environment" from assignment and lines 666-668, remove the unused b12x_environment=None kwarg from HostRendezvous.prepare (using self.b12x_environment directly), and update the serve_peer test to assert one realistic message.
  2. Consolidate duplicated atomic-write blocks and fix the open-handle unlink in _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 to compile_pool.py:115-123 (which already imports from .aot at line 104), and aot.py retains three inline NamedTemporaryFile + os.replace + unlink blocks (: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 inside with tempfile.NamedTemporaryFile(...) as file:, so if file.write fails before file.close(), the handle is still open during unlink (which raises PermissionError on Windows and masks the original write error).
    • Fix: Have compile_pool.py:115-123 call _save_compiled_function, and move try/finally outside the with block at aot.py:870-877 (or extract one shared atomic-write helper in aot.py).

Nits

Dropped on verification