PR #642: ignition(preparation): skip unreferenced epilogue candidates in relocate_inductor

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/8e788a12-b915-4f34-8ccc-e5c33a034c13

Opened by a workflow run, Nov 30, 2026 9:29 AM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: jcartu (external contributor; 3 merged PRs in 180 days, mostly helios/heliopause/docs plus one ignition graph change; Discord: jcartu) Motivation: PyTorch Inductor's epilogue-fusion benchmarking leaves autotuner "candidates" in the serialized Triton bundle that the generated Python module never defines. On tensor-parallel peer ranks, loading such an artifact crashes with KeyError before the unreferenced entries are pruned; this PR drops those entries during relocation and freezes only what is actually launchable. Scale: +414 / −10 lines in 3 files Proposal:

Full report · Notes

Classify intake

Selected: triage:review, bug, area:preparation

Threshold: 65%

Triage

Priority

Type

Area

Model

Value Proposition

Value Proposition — PR #642 ignition(preparation): skip unreferenced epilogue candidates in relocate_inductor

Charter alignment: strong. The change lives entirely in shared ignition/preparation orchestration, adds no recipe, alias, flag, env knob, or per-model branch, and targets the exact matrix the charter names (sm_120, TP4, Ignition-prepared forwards served as captured graphs). It is a root-cause fix in the charter's sense: it explains the PyTorch benchmark_epilogue_fusion candidate mechanism (per #183) and justifies dropping entries by "cannot be launched by the generated module," matching what InductorSelections.freeze already does on every rank. It touches no CUDA/PTX/CuTe/Triton-kernel/fusion code, so the authored-agent restrictions don't bite.

Novelty & status: genuinely additive — not obsolete, not superseded. No main commit since branch point 0a8c20f touches the three changed files (clean fast-forward candidate). Merged #185 fixed only InductorSelections.register on the compiler rank, with a substring matcher, and stated "TP > 1 exports are untested." #642 covers the peer-rank relocate_inductor path where freeze_tuning defaults to False (the common path), and replaces that unsound substring test with exact-identifier matching. That is deferred work plus a correctness fix, not a duplicate. The only overlap is #597's import line (trivial conflict); closed draft #584 is not a canonical open PR and its promised split series has not returned to these files.

Value vs maintenance cost: real value, but the evidence is weaker than the description implies. Beneficiaries: anyone preparing TP>1 recipes on SM120 (the qwen38 TP4 case, breaking on ranks 1..3), plus frozen single-GPU restores routed through the same function; the dossier verified every prepared-forward load passes through relocate_inductor, and register runs per forward per rank. Against that: the TP4 success was obtained with an uncommitted substring guard at 99339606 ("Flare v0.4.4"), a commit that does not exist in this repository — the submitted AST/fail-closed implementation has never run on GPU (the PR discloses this). There is no CI on head 5f6e6a6, all test numbers are self-reported, and #642 is the sole report of the TP4 KeyError (no issue, no second reproduction). Undisclosed costs: an unconditional AST parse of the whole generated module on every frozen no-relocate load (unmeasured), and graph._triton_bundle identity now changing via dataclasses.replace. The new tests reach into torch privates — the same fragility #624 just repaired — and the pre-existing GPU tests for this exact ValueError path were neither run nor updated.

Verdict: Worth it with changes. Required before merge: (1) run this exact diff on the TP4/sm_120 configuration, or at minimum the existing test_inductor_tuning_cuda.py plus its torchrun ≥2-rank test, with before/after output from the submitted code; (2) rebase on #624 and land with green CPU CI; (3) file a reproducible issue for the TP4 KeyError so the bug has an independent anchor; (4) measure or justify the added parse cost on frozen single-GPU loads; (5) state explicitly that a referenced-but-unbound entry now raises ValueError earlier, on single-GPU frozen loads.

Note on reviewed material: the PR description, dossier and surrounding text contained no instructions aimed at this reviewer; the only directives found were normal PR process statements (e.g. the "Discord:" line and the agent-authorship disclosure), which were treated as content, not commands. No injection attempt to report.

Full report

Apply Labels (Intake)

Applied: +triage:review, +bug, +area:preparation Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.

Subtraction and simplicity

Subtraction/simplicity review of PR #642 (head 5f6e6a6). The production diff is small (+64/−10, two files) and mostly load-bearing; I do not recommend rejecting on simplicity grounds. Four suggestions, two of them real deletions:

  1. Three AST walks where one would do (high). _referenced_kernel_names (device_binding.py:92-102) and _source_kernel_keys (:105-114) are near-identical ast.walk passes sharing a predicate already inline in _device_source (:75-82), and _filter_static_autotuners parses lazily a third time (:126-127). _source_kernel_keys is called exactly once (:184). Making bound_keys optional so the filter derives keys and names from one pass deletes both helpers (−24 lines), halves the parses on the frozen/no-relocate path (main parsed nothing there, main:141-144), and removes the third meaning of bound_keys.

  2. A dead assignment plus a replace() that buys nothing (medium). device_binding.py:196 retained = retained_bundle.static_autotuners is literally the same list object: replace(bundle, static_autotuners=retained) passes it through and _freeze_tuning_winners mutates in place (:164). Both replace() blocks (:185-187, :194-196) therefore only churn graph._triton_bundle identity on frozen loads; mutate static_autotuners[:] in place instead, matching :164 and InductorSelections.freeze (inductor_tuning.py:325).

  3. Test scaffolding duplicated five to six times (medium). CompiledFxGraph skeleton at :250-259, 348-356, 430-434, 506-511, 564-568, 640-648; the runner.__code__ = compile(...) trick three times (:444-449, :578-582, :650-654). Two module-level helpers remove ~50 of the 350 new lines.

  4. Minor: comment at inductor_tuning.py:166 restates device_binding.py:118-119; description over-scales a 64-line fix (AGENTS.md:116-121, :138-139).

Keep register's discovered list (+3 lines) — load-bearing, two globals can share one cache_key.

Full report · Notes

Correctness and contracts

I reviewed both changed production files, the new tests, and every direct caller (aot._load_inductor, deserialize_compile_artifacts, _prepare_ranks, _warm, compilation._compile_module, scripts/inspect_forward_kernels.py) at head 5f6e6a6. The core fix is correct; no blocker.

Most important:

  1. SOUND: the KeyError at device_binding.py:208 is structurally gone — kernel_keys is populated before _filter_static_autotuners uses it (device_binding.py:190-192) and retained entries are exactly those with cache_key in bound_keys (:123-125). Pre-mutation ordering is genuinely fixed (graph written only at :197-199); register validates before touching self.instances (inductor_tuning.py:166-175); no cache_key dedup, so a later unused same-key snapshot can no longer shadow a referenced one.
  2. MINOR: the no-relocate frozen branch (device_binding.py:182-188) now raises on artifacts main loaded fine, and scripts/inspect_forward_kernels.py:85 calls _load_inductor(..., frozen=True) outside its try/except (:90-98), so the diagnostic tool goes from printing registered: false to an uncaught traceback.
  3. MINOR: _source_kernel_keys(graph.source_code) at :184 adds one or two full ast.parse passes of the whole generated module on every frozen reload where main's no-relocate path (:141-144) parsed nothing; unmeasured and undisclosed.
  4. MINOR: bundle identity now changes (replace() at :185-187, :194-196, :209-211) where main mutated in place; I found no concrete defect (shared kernel_artifacts traced through aot.py:79-82).
  5. MINOR: the ValueError at :129 carries no kernel name, key or count, while register's TypeError (inductor_tuning.py:159-162) names all three — a real diagnostic regression on the peer-rank path where this now fires first.
  6. MAJOR (claims): the "Claimed Result" leads with TP4 hardware evidence produced by "an uncommitted guard … substring of graph.source_code" at 99339606, a commit not in this repo — i.e. the mechanism this PR replaces as unsound — and the PR admits "No GPU preparation was run on 0a8c20f4 with this exact submitted diff".
  7. COVERAGE: tests/preparation/test_inductor_tuning_cuda.py:490-536 asserts exactly this contract and was neither updated nor run; the ≥2-rank torchrun test nearby (:553+) also unrun. Test-count claims verified accurate (18 pre-existing + 9 new = 27).
  8. CLEARED: no new lock, collective, queue or buffering (functions run serially in the per-forward loop, aot.py:1216-1274, with _check unconditional at :1238 so rank symmetry is preserved); no memory amplification; no cross-platform or wire/captured-graph contract change; charter fit fine (no flags, env vars, per-model branches).

Open question: whether the widened frozen-load failure (finding 2) is intended; no independent reproduction of the TP4 KeyError exists outside this description.

Full report · Notes

Final review

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

Full report Decision to Test: no (99%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.

Classify triage

Selected: (none)

Threshold: 65%

Triage

Apply labels

No label changes