Final review report · NVIDIA/hyperflare-inference #597

Raw Markdown for agents: https://autobot.eidonix.com/p/ba51970b-4833-4207-ae35-b5a25c4132fd.md

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

Walkthrough

Pre-merge Checks

Blockers

  1. 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 equals 2 GiB for discrete GPUs per ignition/preparation/host_memory.py:13-15) now runs inside for 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 raises MemoryError even 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-158 only tested 40 GiB (right inside the 2 GiB failure hole), which masked the bug.
    • Concrete fix: Keep the 2 GiB minimum-allowance fallback strictly for a single worker on the host (len(active_groups) == 1, preserving main's invariant), and require full resources[rank].worker_bytes for every seeded worker when len(active_groups) > 1 (or compile active SKU subgroups sequentially when host RAM fits only one worker). Add unit tests covering 12 GiB, 39 GiB, 40 GiB, 42 GiB, 71 GiB, and 72 GiB for 2 active SKU groups.

Should Fix

  1. Unnecessary on-disk gpu_tag filename suffix breaks homogeneous/mixed cache reuse and forks GPU identity (ignition/preparation/aot.py:939-944, 967, 1024, 1065 vs aot.py:750-763 and ignition/preparation/inductor_tuning.py:248).
    • ForwardCache.__init__ (aot.py:750-763) already hashes properties.name into self.root, so distinct GPU product names never share a cache directory in production. The cross-SKU sharing bug on main occurred only because _variant_compilers and paths[name, variant] keyed on compilation_variant alone.
    • Suffixing _variant(forward) with a normalized gpu_tag when heterogeneous = len(set(gpu_names)) > 1 also changes name=f"{name}.{variant}" passed to _restore/_path, causing the exact same GPU card to write different .bin hashes in the same self.root depending 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 normalized gpu_tag (aot.py:940) vs raw gpu_name (aot.py:996, 1000-1004; inductor_tuning.py:248).
    • Concrete fix: Remove heterogeneous and gpu_tag. Key selections, compilers, and paths in _prepare_ranks by (base_variant, gpu_name) (matching InductorSelections.warm and working natively with _variant_compilers at aot.py:657-670), while passing name=f"{name}.{base_variant}" to self._restore and self._path. In test_mixed_gpu_inductor_keying.py, give each SKU its own cache.root (mirroring ForwardCache.__init__) and assert cache reuse between homogeneous and mixed runs on the same GPU.
  2. Multi-host mixed-SKU _share_artifacts writes foreign-SKU artifacts into unlocked cache roots (ignition/preparation/aot.py:698-734, 1102-1104, 1168-1169 vs :788-804).
    • _publication_lock acquires publication.lock only for (host, self.root.resolve()) pairs present on each host. When coordinator.spans_hosts is True, _share_artifacts still marks every path compiled on any other rank as missing and writes it via target.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 its publication.lock.
    • Concrete fix: Filter missing in _share_artifacts so each rank only fetches artifacts under its own self.root (or paths it selects from paths[name, variant]).
  3. 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-245 still 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 or ValueError when the host worker limit is below the active group count.
    • docs/preparation-development.md:351-371 still 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.
  4. Provide a main failure reproduction and isolated preparation-stage verification.
    • Attach the concrete failure observed on current main for the mixed-SKU SM120 export, an isolated preparation comparison (main vs this branch: compile phase outcome, wall clock, and admitted workers), and the exact pytest command/output (and run tests/preparation/test_inductor_tuning_cuda.py if hardware is available, or explicitly note it as unrun).

Subtract / Simplify

  1. Delete the unreachable duplicate cross-architecture gate in InductorSelections.warm (ignition/preparation/inductor_tuning.py:249-255 and tests/preparation/test_mixed_gpu_inductor_keying.py:326-340).
    • Every coordinator-backed InductorSelections is constructed solely inside ForwardCache._prepare_ranks (ignition/preparation/aot.py:1122), ~185 lines after aot.py:933-938 already rejects cross-architecture ranks on the same coordinator and self.device. Every other call site (aot.py:835, 1256, scripts/inspect_forward_kernels.py:93 (not opened)) passes coordinator=None, where _gather returns [value] (inductor_tuning.py:129-131). Dropping capability from warm's gather payload removes the dead check and its stub-only test while keeping cross-architecture coverage in test_cross_architecture_ranks_are_rejected_before_forward_sharing.
  2. Simplify allocate_workers by removing the redundant groups is None branch and admitted counter (ignition/preparation/compile_pool.py:75-85, 94, 103, 115, 120).
    • Normalizing groups = hosts if groups is None else groups collapses if groups is None: cleanly into the single active_groups comprehension (since jobs > 0 is already enforced at :73-74).
    • After the MemoryError check at :116-118, every active subgroup has received exactly 1 worker, so admitted always equals len(active_groups); delete admitted and use range(limit - len(active_groups)) at :120.
  3. 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-implement aot.py:940 verbatim) disappear. Consider extending _lending_rank in tests/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.

Nits

Dropped on verification