Final review report · NVIDIA/hyperflare-inference #642

Raw Markdown for agents: https://autobot.eidonix.com/p/993c0b0c-c10d-4bb0-a619-cd1a6fa2885d.md

Recommendation: Changes Requested

The core fix is technically sound with no blockers: relocate_inductor structurally eliminates the peer-rank KeyError on unreferenced epilogue-fusion candidates, replaces #185's substring check with exact AST identifier and async_compile.triton kernel-name matching, fixes duplicate-key shadowing, and preserves pre-mutation and multi-global registration invariants without affecting cross-rank collective safety. However, the submitted AST implementation has neither a green CI run on head 5f6e6a6 (the branch predates #624's CPU CI fix) nor any GPU execution (tests/preparation/test_inductor_tuning_cuda.py was not run, and the TP4 hardware unblock cited in Claimed Result came from a different uncommitted substring guard on a non-repo commit 99339606), and the frozen same-device reload path adds an avoidable redundant AST walk (_source_kernel_keys) that unconditionally parses and hashes generated modules even when static_autotuners is empty. Addressing the verification/evidence gap and collapsing the redundant AST helper will make this ready to merge.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Run verification on the submitted diff and align Claimed Result with what actually ran (docs/design-review.md:106-115, 171-189, tests/preparation/test_inductor_tuning_cuda.py:490-536, 553+):

    • Rebase onto current main (which includes #624) so .github/workflows/python-cpu.yml (not opened) executes and passes cleanly on the PR head instead of relying on self-reported local CPU runs with two baseline failures.
    • Run tests/preparation/test_inductor_tuning_cuda.py on this exact submitted diff (at minimum test_unreferenced_bundled_candidates_are_dropped_and_named_kernels_still_bind at :490-536, and ideally the ≥2-rank torchrun test at :553+ or a TP>1 export check if multi-GPU hardware is available) and report the actual command and result.
    • Tighten the Claimed Result paragraph so it leads with what was verified on this diff and clearly qualifies upfront that the 99339606 TP4 run validated an earlier substring-guard prototype rather than this submitted AST implementation (instead of leaving that distinction to the later provenance section).
  2. Collapse the duplicate AST walk and avoid unconditional parsing/hashing when static_autotuners is empty (ignition/preparation/device_binding.py:92-130, 182-188):

    • _source_kernel_keys (:105-114) duplicates _referenced_kernel_names's ast.walk(ast.parse(source)) (:92-102) and has a single caller at :184. On every frozen same-device load (not relocate + freeze_tuning=True), :184 unconditionally parses the entire generated module and computes CompiledTritonKernels.key(...) across all kernels even when bundle.static_autotuners is empty, and parses the module a second time (:127) if any unbound entry is encountered (on main, this branch did zero parsing).
    • Fix: Merge _referenced_kernel_names and _source_kernel_keys into a single helper _source_kernel_refs(source, *, include_keys=False) and make bound_keys=None optional in _filter_static_autotuners:
      • Return [] immediately when not bundle.static_autotuners (skipping AST parsing completely for graphs without static autotuners).
      • When bound_keys is None (not relocate branch at :184), collect both bound_keys and referenced_names in one AST pass (_source_kernel_refs(source, include_keys=True)).
      • When bound_keys is already supplied (relocate=True at :192 and InductorSelections.register at inductor_tuning.py:168), preserve the lazy fast path — do not parse or hash at all unless an unbound cache_key is actually encountered, and then call _source_kernel_refs(source, include_keys=False) so common-path loads incur zero extra AST parses or SHA-256 hashes.

Subtract / Simplify

  1. Delete the dead assignment at ignition/preparation/device_binding.py:196: retained = retained_bundle.static_autotuners is a no-op because replace(bundle, static_autotuners=retained) aliases the same retained list and _freeze_tuning_winners mutates bundle.static_autotuners[:] in place at :164 (keep replace(bundle, static_autotuners=retained) itself so bundle.static_autotuners stays untouched if _freeze_tuning_winners raises, matching InductorSelections.freeze at inductor_tuning.py:325).
  2. Factor repeated test scaffolding in tests/preparation/test_inductor_prepared_winners.py:250-259, 348-356, 430-434, 444-449, 506-511, 564-568, 578-582, 640-654: Extracting two small module-level helpers (_stored_graph(source_code, bundle) and _generated_callable(graph, tuners)) removes ~50 lines of duplicated CompiledFxGraph.__new__ and runner.__code__ = compile(...) boilerplate while keeping the existing function-local torch imports intact.

Nits

  1. Include kernel diagnostics in the ValueError (ignition/preparation/device_binding.py:129): Append entry_kernel.kernel_name and entry_kernel.cache_key (while preserving the "compiled forward has unbound static Inductor kernels" prefix matched by tests/preparation/test_inductor_tuning_cuda.py:535 and test_inductor_prepared_winners.py:515, 589, 598) to make multi-rank logs actionable without needing a debugger.
  2. Diagnostic script edge case (scripts/inspect_forward_kernels.py:85-98): For a corrupt frozen artifact with ordinal == 0 and a referenced unbound kernel, _load_inductor (:85) now raises ValueError before the try: block (:90), aborting a multi-artifact sweep instead of emitting JSON with registered: false. Wrapping :85-94 in the existing try: block would preserve per-artifact reporting (do not add a drop-only bypass to relocate_inductor).
  3. Remove duplicate comment (ignition/preparation/inductor_tuning.py:166) and trim PR description inventory (AGENTS.md:116-121, 138-139): Line 166 repeats the rationale already documented at device_binding.py:118-119.

Dropped on verification