#1 [high] #642 correctness: verified code-level findings (device_binding.py)
PR #642 head 5f6e6a6. Files read in full: ignition/preparation/device_binding.py (212 lines), ignition/preparation/inductor_tuning.py (350 lines), tests/preparation/test_inductor_prepared_winners.py (665), aot.py (_load_inductor 46-87, deserialize_compile_artifacts 500-548, _prepare_ranks 1213-1282, _warm 1359-1382), compilation.py:258-319, scripts/inspect_forward_kernels.py:40-99, tests/preparation/test_inductor_tuning_cuda.py:434-536.
F1 (Minor, NEW compat failure on paths that never call register). device_binding.py:182-188 no-relocate frozen path now raises on artifacts that main loaded fine:
if not relocate:
if bundle := graph._triton_bundle:
retained = _filter_static_autotuners(bundle, graph.source_code, _source_kernel_keys(graph.source_code))
retained_bundle = replace(bundle, static_autotuners=retained)
_freeze_tuning_winners(retained_bundle)
graph._triton_bundle = retained_bundle
return
main (device_binding.py:141-144) did only _freeze_tuning_winners(graph._triton_bundle) then return. So a frozen artifact with a bundle entry whose cache key has no async_compile.triton definition but whose kernel_name IS a module identifier previously loaded through _load_inductor and only failed later at InductorSelections.register. Two callers never reach register: ignition/preparation/compilation.py:302 (_load_inductor(serialized, original), portable-device cache-hit path, frozen defaults False -> no-relocate+no-freeze -> early return at :171, so actually safe) and scripts/inspect_forward_kernels.py:85 with frozen=True (passes artifact's _tuning_frozen from :62) — that path now raises where main returned an artifact. Impact: diagnostic tool hard-fails on already-exported cores. Fix: pass a flag to skip the referenced-unbound check (drop-only) on the pure-reload path, or have inspect_forward_kernels catch/log it (it already try/excepts register at :90-98 but not _load_inductor).
F2 (Minor, unbudgeted cost on the hot reload path). device_binding.py:184 parses the whole generated module unconditionally whenever a bundle is present and freeze_tuning is on: _source_kernel_keys(graph.source_code) (own ast.parse at :109) and then possibly a second full parse in _referenced_kernel_names (:95, lazily at :127). main's no-relocate path (:141-144) did zero source parsing. Every frozen single-GPU forward reload pays 1-2 extra full AST parses of a several-thousand-line module. Not measured or disclosed in the description. Fix: derive keys from the existing single parse, or compute once and pass both.
F3 (Minor, undeclared identity/aliasing change). device_binding.py:185-187 and :194-196 replace the bundle object (replace(bundle, ...)) instead of mutating in place as main did (:141-142). _freeze_tuning_winners still mutates the entry kernels in place (:161-163), so kernel objects remain shared with the pre-filter bundle, while bundle.static_autotuners[:] = entries.values() (:164) of the replaced bundle is a new dataclass field. kernel_artifacts list object is shared, so aot.py:79-82 graph._triton_bundle.kernel_artifacts.clear() still affects both graphs — no regression found there. Reported for completeness; no concrete defect proven.
F4 (verified SOUND — say so). The KeyError is structurally gone: in the relocate path device_binding.py:190-208, kernel_keys is populated by _device_source(..., kernel_keys) before _filter_static_autotuners(bundle, rebound_source, kernel_keys) (:192), and retained entries are exactly those with cache_key in kernel_keys (:123-125), so kernel_keys[entry_kernel.cache_key] at :208 cannot KeyError. Pre-mutation ordering is correct: graph.source_code/cache_key/device_idxs are written only at :197-199 after the filter, and per-kernel device metadata mutation at :202-211 only touches retained entries; the ValueError at :129 leaves graph and sibling tuners untouched (asserted by tests at test_inductor_prepared_winners.py:518-526). register likewise validates at inductor_tuning.py:166-168 before any self.instances/_install mutation at :169-175, and _filter_static_autotuners scans all entries (no cache_key dedup) so a later unused same-key snapshot cannot shadow a referenced one — this genuinely fixes the old collapse-then-check bug.
#2 [high] #642 claim accuracy + test coverage verdict
F5 Claim accuracy — test counts are ACCURATE (verified by counting the file). tests/preparation/test_inductor_prepared_winners.py at PR head: 18 pre-existing test cases (test_static_restore 1, test_prepared_winner_does_not_reopen 1, test_frozen_config_restores 1, test_prepared_winner_rejects_unresolved 4 params, test_prepared_winner_accepts_completed 2, test_ineligible_coordinate_descent 4, test_frozen_tuning_contract 1, test_forward_cache_load 1, test_artifact_binding_freezes 2 params, test_effective_last_snapshot 1) + 9 new cases = 27, exactly matching the description's "27 passed ... adding 9 test cases across 5 functions" (new functions at :317, :399-400 3 params, :471-472 3 params, :529, :606).
F6 (Major, claim accuracy) The "Claimed Result" leads with hardware language that the submitted diff did not produce. PR text: "on 4x RTX PRO 6000 Blackwell (sm_120, TP4) using a locally patched checkout of Flare v0.4.4 (99339606), skipping unreferenced static_autotuners entries in relocate_inductor unblocked qwen38 TP4 preparation". The provenance section admits it was "an uncommitted guard in relocate_inductor that skipped static_autotuners entries absent from kernel_keys when entry.kernel_name was not a substring of graph.source_code" — the substring mechanism this PR replaces as unsound, at a commit that is not in this repository (dossier: search_history finds no 99339606). Plus the disclosed "No GPU preparation was run on 0a8c20f4 with this exact submitted diff". So the only end-to-end evidence for the fail-closed AST matcher is CPU fixtures with monkeypatched torch internals. Reviewer-relevant because the Claimed Result paragraph is what gets skimmed.
F7 (Minor/Major, coverage) The existing GPU test that exercises exactly this contract was neither updated nor run: tests/preparation/test_inductor_tuning_cuda.py:490-536 test_unreferenced_bundled_candidates_are_dropped_and_named_kernels_still_bind. I traced it against the new logic and it appears compatible — the injected candidate uses kernel_name=str(Placeholder.DESCRIPTIVE_NAME) (:514) which will not appear in _referenced_kernel_names, so it is still dropped and bundled[True] == bundled[False] - {'unreferenced-candidate'} (:530) still holds; the second half keeps the original kernel_name (:533-534) and still expects the ValueError (:535). But the neighbouring test_distributed_catalog_reconciles_real_conflicting_candidates (:553+, the only >=2-rank torchrun test) is the true TP peer-rank regression and was not run. Description discloses this under Limitations.
F8 (Minor) New tests reach into torch privates that #623/#624 just had to repair: CompiledFxGraph.new, torch._functorch._aot_autograd.aot_autograd_result.deserialize_bundled_cache_entry, standalone_compile.AOTCompiledArtifact, SerializableCompiledFunction, simple_wraps (test_inductor_prepared_winners.py:317-328, :372-381). Highest future breakage risk on a torch bump.
F9 (SOUND, no issue found) Charter fit: change is confined to shared ignition/preparation orchestration, no env vars (AGENTS.md "Configuration" forbids env-selected behaviour; none added), no per-model branches, no new flags — the only new option-free code paths. _filter_static_autotuners reproduces what InductorSelections.freeze already does at inductor_tuning.py:322-325 (snapshots built from bindings.values() only), so the policy matches an existing invariant rather than inventing one. Principle 14 (docs/design-review.md) permits preparation orchestration. No metric/rate/admission span is touched (grep for inbound_rate/estimated_seconds: no relation).
#3 [high] Research summary
I reviewed PR #642's two 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) in context at head 5f6e6a6.
The core fix is sound. The KeyError is structurally gone: in the relocate path _device_source(..., kernel_keys) populates kernel_keys before _filter_static_autotuners uses it, retained entries are exactly those with cache_key in kernel_keys, so kernel_keys[entry_kernel.cache_key] at device_binding.py:208 cannot miss. Pre-mutation ordering is genuinely fixed — graph.source_code/cache_key/device_idxs are written only after validation, and per-kernel device mutation touches retained entries only; register likewise validates before touching self.instances/_install. The helper scans all entries without cache_key dedup, so the old "collapse duplicates then check" bug is really fixed, and dropping unreferenced entries reproduces what InductorSelections.freeze already does at inductor_tuning.py:322-325. Charter fit is fine: no env vars, no flags, no per-model branches; principle 14 permits preparation orchestration.
Findings worth adjudication (all with file:line and verbatim quotes in my notes): (1) Minor — the no-relocate frozen branch (device_binding.py:182-188) now raises on artifacts main loaded fine; scripts/inspect_forward_kernels.py:85 passes frozen=True and never reaches register, so that diagnostic tool regresses from "loads" to "dies" on already-exported cores. (2) Minor — _source_kernel_keys(graph.source_code) at :184 adds one or two full AST parses of the whole generated module on every frozen single-GPU reload, where main did zero parsing; unmeasured and undisclosed. (3) Minor — the bundle is now replaced via dataclasses.replace rather than mutated in place; I traced aot.py:79-82 and the shared kernel_artifacts list and found no concrete defect, so this is flagged for completeness only. (4) Major, claim accuracy — the "Claimed Result" leads with TP4 hardware language, but the PR itself admits the run used "an uncommitted guard ... substring of graph.source_code" (the mechanism this PR replaces as unsound) at 99339606, a commit not in this repo, and that "No GPU preparation was run on 0a8c20f4 with this exact submitted diff". (5) Coverage — the GPU test that asserts this exact contract (test_inductor_tuning_cuda.py:490-536) was neither updated nor run; I traced it against the new logic and it appears compatible, but the only ≥2-rank torchrun test in the neighbourhood was not run either.
The description's test-count claims are accurate: I counted 18 pre-existing cases plus the 9 new ones in test_inductor_prepared_winners.py — 27, matching the stated "27 passed ... 9 test cases across 5 functions", with the new functions at the lines claimed. I found no metric/rate/admission span affected, no concurrency or lock-ordering hazard introduced (the changed functions run serially inside the per-forward loop), and no cross-platform parity concern.
#4 [high] #642 system-level analysis: cleared areas + F11-F14
F10 (system-level / concurrency / memory — CLEARED, no finding). The three changed functions run serially inside the per-forward loop of _prepare_ranks (aot.py:1216-1274: selections.register(bound) at :1232, selections.warm :1241, selections.freeze :1247, then coordinator.barrier(...) at :1239). No lock, mutex, queue or semaphore is added or moved; _GUARD_LOCK (aot.py:40) and CachingAutotuner.lock are untouched. No new collectives: _filter_static_autotuners is pure local computation, so the all-gather/broadcast sequence in _gather/_check (inductor_tuning.py:121-133) and warm/_reconcile is unchanged — no new deadlock or rank-divergence surface beyond the changed failure behaviour below.
F11 Failure-propagation blast radius (Minor, consequence of F1/F2 ordering). Because the filter now runs before _freeze_tuning_winners (device_binding.py:184-186 and :192-196), a referenced-unbound entry now raises ValueError at load time instead of at InductorSelections.register. On a peer TP rank this converts the old KeyError into a ValueError raised inside _load->_load_inductor->relocate_inductor, i.e. during ForwardCache._load (aot.py:1229), which is caught per-forward at aot.py:1233-1238 and reported through the cross-rank selections._check(failure) at :1238. Net effect: same per-forward failure point, honest error message, no new poisoning of sibling forwards — this is an improvement, not a regression, but it does mean the error now surfaces before register for cases that previously got a clearer type/binding diagnostic from register's TypeError at inductor_tuning.py:157-162. Worth noting since register's message names the module global, key and counts while _filter_static_autotuners's ValueError names nothing (device_binding.py:129: raise ValueError("compiled forward has unbound static Inductor kernels") — no kernel name, key, or graph). Concrete, cheap fix: include entry_kernel.kernel_name, entry_kernel.cache_key and the count of unbound entries in the message, as register does.
F12 Memory (no finding). _filter_static_autotuners builds a list of references to existing entries (retained.append(entry_kernel), device_binding.py:124) and at most one set of AST Name strings; no kernel, cubin or compile-result copies. replace(bundle, ...) creates one shallow dataclass. _referenced_kernel_names holds only identifier strings for the duration of the call. Net new retention: bounded by module identifier count. No unbounded buffering.
F13 Cross-platform parity: no issue. This is CUDA-only preparation code (guarded by graph.device_idxs != OrderedSet((original.index,)) at device_binding.py:180); ast/dataclasses are stdlib and identical on Unix/Windows. scripts/inspect_forward_kernels.py is not shipped to the Windows client (flare-winui does not import ignition).
F14 Architecture/contracts: no wire/proto/captured-graph/public format change. _filter_static_autotuners, _referenced_kernel_names, _source_kernel_keys are new module-private helpers; no existing signature changed; relocate_inductor(entry, original, *, freeze_tuning=False) and InductorSelections.register(bound) keep their signatures. Prepared-artifact formats are unchanged (_load_inductor still round-trips the same pickle). The only observable contract change is which bundle entries survive a frozen/prepared reload — and that set already matched InductorSelections.freeze's output on every rank, so artifacts remain self-consistent. No owner sign-off gate applies (preparation orchestration is the permitted category under principle 14, AGENTS.md "CUDA kernel and model optimization authorship").