#1 [high] Research summary
Reviewed all four changed source files in context (collectives.py, host_ranks.py, aot.py, cli/serve.py), their callers (tuning.py, rank_group.py, compile_pool.py, inductor_tuning.py, composition_tuning.py, environment.py, declaration.py, core_snapshot.py, runtime_core.py), the touched tests, AGENTS.md, and the multi-host/CLI docs. Findings below, all verified against the files.
1. Blocker — new control-channel message without a PROTOCOL bump. host_ranks.py:41 still PROTOCOL = 5 while prepare() now sends ("b12x-environment", b12x_env) as the first message (host_ranks.py:345-347). A stale peer binary rejects it in serve_peer at "if not (isinstance(command, tuple) and command[0] == "checkpoint-source"): raise RuntimeError(...)" (host_ranks.py:657-658) instead of the clean protocol mismatch _admit performs (285-286). It only fires for recipes that declare b12x settings (GLM-5.3, Kimi), so a stale ignition join looks model-specific; docs/multi-host.md:377 already expects operators to hit this. Fix: bump PROTOCOL to 6, or deliver the env only inside assignment (which is version-tolerant via .get).
2. Major — corrupt-cache recovery deletes artifacts on transient I/O and logs nothing. _CORRUPT_ARTIFACT_ERRORS (aot.py:69-81) includes OSError, ValueError, TypeError, KeyError, AttributeError, RuntimeError, and _load's handler is "except _CORRUPT_ARTIFACT_ERRORS as error: if required or isinstance(...): raise; Path(path).unlink(missing_ok=True); return None" (aot.py:1376-1380), wrapping both the file open and the unpickle. An EIO/ENOSPC/EROFS or a driver RuntimeError therefore unlinks a valid multi-GB artifact and silently recompiles; on a read-only cache the unlink raises from inside the handler. No log line at all. This is the charter/#397 "don't swallow an unexplained error" case and AGENTS.md's "do not suppress errors". Fix: narrow to parse/deserialization errors, exclude OSError (or only accept truncation/ENOENT), and emit a warning with path and exception before unlinking.
3. Major — tuning metrics double-count the reconcile pass. tuning.py:511-515 appends the second preparation's result to the same results list, and tuning.py:558-564 sums over it: ""elapsed_seconds": sum(result.elapsed_seconds for result in results), cache_hits, benchmarked_candidates, restored_candidates, rejected_candidates, parent_cute_compilations, parent_triton_compilations". Because #668 makes changed true exactly in #651's declaration-divergence case, these numbers inflate on every such run. Fix: keep reconcile results separate and report reconcile_elapsed_seconds / reconciled counts distinctly.
4. Major — the reconcile pass re-prepares every job, unsharded onto rank 0, when any plan changed. tuning.py:504-518: after changed, sharding is forced to (0,), and "for job in self._jobs(requests): ... results.append(self._coordinator.prepare(... selected_configs={plan: config for plan, config in configs.items() if plan in plans}))" — all jobs, including those containing no changed plan, are re-run. Against #631's 2h15m/attempt baseline this is an unbounded, unmeasured cost. Also rank 0 passes an empty dict rather than None, and collectives.py:499 distinguishes the two ("{} if selected_configs is None else {"selected_configs": selected_configs}"), so rank 0 enters the second pass with a selected_configs={} option it never had in pass one — untested against the real library. Fix: restrict to jobs containing a changed plan, pass None when the filtered mapping is empty, and report the added time.
5. Minor-Major — the gather payload lost its declaration dedup. Old: "local.setdefault(key, {}).setdefault(payload, config)". New: "local = [(decl_key, name_key, payload, config) for _, decl_key, name_key, payload, config in entries]" (collectives.py:408-410), i.e. one entry per request variant carrying the nested portable_declaration tuple, a (name, variant, component_id) tuple and a pickled config object, replicated for every rank in gathered. For #651-scale catalogs (1020–1319 records) this materially grows an already-memory-critical all_gather_object. Fix: exchange declaration-deduped payloads plus a compact name→index map.
6. Minor — B12X_* cache identity is a 14-name denylist. _b12x_forward_env() (aot.py:71-82) hashes everything in os.environ starting B12X_ minus _NON_EXECUTION_B12X_ENV, and feeds ForwardCache's root key (aot.py:897-899) which is also the source_identity of InductorSelections (aot.py:1288) → _execution_identity (inductor_tuning.py:100-106) → PreparedComposition.identity() used as a collective cache key (composition_tuning.py:93-97, 168). Any future host-local or debug knob outside the denylist re-keys every host's cache (full recompile) and can make rank keys differ for settings nothing validates. Fix: hash the recipe's declared b12x_environment names (already the authoritative set, and now transmitted to peers), not ambient env.
7. Minor — B12X_COMPILE_CACHE_DIR is legal in a recipe but fatal in multi-host. declaration.py:251-253 accepts any B12X_ string name; _validate_b12x_environment rejects that one (host_ranks.py:205-208) inside HostRendezvous.__init__, before the listener exists, with a bare ValueError while peers retry knock for 600 s (host_ranks.py:593-606). environment.apply itself overrides that variable from **dict(b12x) (environment.py:47, 51), so a recipe may reasonably set it. Fix: validate at declaration time, raise UsageError, and build the rendezvous after full plan validation.
8. Minor — Windows: the cleanup unlink runs while the temp file is still open. aot.py:870-877 places temporary.unlink(missing_ok=True) inside the with tempfile.NamedTemporaryFile(...) block, so on a write failure Windows raises PermissionError from finally and masks the original error; the inline file.close() is also redundant. _save_compiled_function (aot.py:93-100) does this correctly. Fix: move the unlink outside the with.
9. Minor — the "ahead of assignment unpickling" rationale does not hold for join. serve.py:547 runs environment.apply(configuration, (gpu,)) (which applies runtime patches) before knock at 549 and therefore before serve_peer reads the early env command at host_ranks.py:646-648; anything that reads b12x settings at import time has already done so. The env is additionally sent twice and validated/applied twice (host_ranks.py:345-347 + 377, then 647 and 666-668), and the new test locks that redundancy in. HostRendezvous.prepare(..., b12x_environment=...) (host_ranks.py:313-314) has no caller — rank_group.py:286 never passes it.
10. Test and claim gaps. The new 2-rank test asserts configs == {} on rank 0 and never exercises the actual re-prepare with those configs, so the reconcile→prepare→agree_selections loop is untested end to end (test_tuning_shards.py:287-303); no test covers the peer export_options(..., kernel_cache=kernel_cache) branch (host_ranks.py:718-719), the only place peers choose their own cubin directory; no changed is False case after the rewrite; and the live 2×GB10 GLM-5.3 export+join — the configuration of #651 — is explicitly not run, so Fixes #651 remains unproven.
Sound in this diff: changed is computed from the all-gathered catalogs with the same target_for used for configs, so ranks cannot split on whether to enter the pass; _save_compiled_function's same-directory temp + os.replace is correct on POSIX and Windows; _remap_peer_config handles both frozen dataclasses and mutable configs; and the sharing test double now round-trips real bytes (test_forward_artifact_sharing.py:153-154), which genuinely strengthens those tests.
#2 [high] PR #668 correctness/contracts review — findings with citations
PR #668 (NVIDIA/hyperflare-inference), head d4d7b2d, 8 files +423/-44. Files inspected in context: ignition/preparation/collectives.py, host_ranks.py, aot.py, ignition/cli/serve.py, plus callers tuning.py, rank_group.py, compile_pool.py, inductor_tuning.py, composition_tuning.py, environment.py, declaration.py, core_snapshot.py, runtime_core.py, cli/config.py, runtime_patches/init.py; tests test_tuning_shards.py, test_host_ranks.py, test_forward_cache_sources.py, test_forward_artifact_sharing.py; AGENTS.md; docs/multi-host.md, docs/cli-design.md.
FINDING 1 — Blocker — new control message without PROTOCOL bump.
host_ranks.py:41 PROTOCOL = 5 unchanged. host_ranks.py:345-347:
if b12x_env:
for control in controls:
send_object(control, ("b12x-environment", b12x_env))
Peer side host_ranks.py:645-658:
command = receive_object(control)
if isinstance(command, tuple) and command[0] == "b12x-environment":
os.environ.update(_validate_b12x_environment(command[1]))
command = receive_object(control)
...
if not (isinstance(command, tuple) and command[0] == "checkpoint-source"):
raise RuntimeError(f"rank zero sent {command!r} before its checkpoint")
A stale ignition join (protocol 5 accepted by _admit, host_ranks.py:285-286) falls into that RuntimeError instead of a clean version rejection; only recipes that declare b12x_environment (GLM-5.3, Kimi) trigger it, so it presents as model-specific. docs/multi-host.md:377 already expects operators to have stale executables ("All hosts need matching Flare executables and preparation sources"). Fix: PROTOCOL=6, or send the env only inside assignment (read via .get at host_ranks.py:666, version-tolerant).
FINDING 2 — Major — corrupt-load recovery unlinks on transient I/O, silently.
aot.py:69-81 _CORRUPT_ARTIFACT_ERRORS = (EOFError, pickle.UnpicklingError, struct.error, zlib.error, zipfile.BadZipFile, OSError, ValueError, TypeError, KeyError, AttributeError, RuntimeError).
aot.py:1371-1380:
try:
with bind_device(...), path.open('rb') as file:
artifact = torch.compiler.load_compiled_function(file)
except _CORRUPT_ARTIFACT_ERRORS as error:
if required or isinstance(error, (MemoryError, torch.OutOfMemoryError)):
raise
Path(path).unlink(missing_ok=True)
return None
The try block wraps path.open, so EIO/ENOSPC/EROFS (OSError) and driver RuntimeErrors delete a valid multi-GB artifact and recompile silently; on a read-only cache the unlink itself raises from inside the handler. No log line. Violates charter "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)" and AGENTS.md "Do not remove validation, suppress errors, silently substitute execution paths". Callers that pass required=False: aot.py:1420 (_restore). Fix: narrow the tuple to parse/deserialization errors, drop OSError (or only ENOENT/short read), warn with path+exception before unlinking.
FINDING 3 — Major — reconcile pass double-counts tuning metrics. tuning.py:511-515 appends second-pass results to the same list:
for job in self._jobs(requests):
plans = {plan for request in job for plan in iter_plans(request)}
results.append(self._coordinator.prepare(self, job, progress=progress,
autotune=self.autotune,
selected_configs={plan: config for plan, config in configs.items() if plan in plans}))
tuning.py:556-564 sums over results: elapsed_seconds, cache_hits, benchmarked_candidates, restored_candidates, rejected_candidates, parent_cute_compilations, parent_triton_compilations. Since #668 makes changed true precisely in #651's divergence case, these inflate on exactly those runs. Fix: separate reconcile results and report reconcile_elapsed_seconds / reconciled counts.
FINDING 4 — Major — reconcile re-prepares every job unsharded when any plan changed; rank 0 passes {} not None.
tuning.py:504-518: if changed: if self._sharded: self.configure_tuning_shard(0, (0,)) then re-runs all jobs in self._jobs(requests), including jobs with no changed plan. Cost is unmeasured against #631's ~2h15m/attempt. Also selected_configs={...} is always a dict, so rank 0 sends selected_configs={} where pass one sent nothing; collectives.py:499 distinguishes (options = {} if selected_configs is None else {"selected_configs": selected_configs}), so rank 0 enters an untested code path in the real library. Fix: re-run only jobs containing a changed plan; pass None when the filtered mapping is empty; report added time.
FINDING 5 — Minor/Major — all_gather payload lost declaration dedup and grew. collectives.py:408-410:
local = [(decl_key, name_key, payload, config)
for _, decl_key, name_key, payload, config in entries]
Old code was local.setdefault(key, {}).setdefault(payload, config) (per PR diff). New payload is one tuple per request variant containing the nested portable_declaration(plan) tuple, a (name, variant, component_id) tuple, the config payload and the config object, replicated into every rank's slice of gathered (collectives.py:411-412 dist.all_gather_object). For #651-scale catalogs (1020-1319 records per the issue) this grows an already memory-critical gather. Fix: gather deduped payloads plus a compact name→index map.
FINDING 6 — Minor — B12X cache identity uses an ambient-env denylist.
aot.py:47-65 _NON_EXECUTION_B12X_ENV (14 names) + aot.py:71-82:
def _b12x_forward_env():
return tuple(sorted(
(name, value)
for name, value in os.environ.items()
if name.startswith("B12X_")
and name not in _NON_EXECUTION_B12X_ENV
and not name.startswith("B12X_LOG_")))
Included in the ForwardCache root key at aot.py:897-899. window self.root.name is then the source_identity of InductorSelections (aot.py:991, 1288, 1451) → _execution_identity (inductor_tuning.py:100-106) → PreparedComposition.identity() used as a collective cache key (composition_tuning.py:52-61, 93-97, 168). So any future host-local/debug B12X_ knob outside the denylist silently re-keys every host's forward cache (full recompile) and can make ranks disagree on a key that nothing validates. Fix: hash the recipe's declared b12x_environment names (authoritative set, already transmitted to peers), not ambient env.
FINDING 7 — Minor — B12X_COMPILE_CACHE_DIR legal in a recipe, fatal in multi-host.
declaration.py:251-253 allows any B12X_ name: if any(not name.startswith("B12X_") or not isinstance(value, str) for name, value in self.b12x_environment.items()). host_ranks.py:205-208 rejects it: if any(not isinstance(name, str) or not name.startswith("B12X_") or name == "B12X_COMPILE_CACHE_DIR" or not isinstance(value, str) ...). Raised from HostRendezvous.__init__ (host_ranks.py:233), before create_server, so no listener exists and peers retry for 600 s (knock, host_ranks.py:593-606) before an unrelated "did not join" error. environment.apply itself overrides that variable from **dict(b12x) (environment.py:47 then 51), so a recipe may legitimately set it. Fix: validate at declaration time, raise UsageError, construct the rendezvous after full plan validation.
FINDING 8 — Minor — Windows: unlink while temp file still open in _share_artifacts. aot.py:870-877:
with tempfile.NamedTemporaryFile(dir=target.parent, suffix=".tmp", delete=False) as file:
temporary = Path(file.name)
try:
file.write(payload[0])
file.close()
os.replace(temporary, target)
finally:
temporary.unlink(missing_ok=True)
On Windows a write failure reaches finally with the handle open → PermissionError masks the original error; file.close() inside the try is redundant. _save_compiled_function (aot.py:90-100) does it correctly by unlinking after the with. Fix: move unlink outside the with.
FINDING 9 — Minor — duplicate env channel has no effect in the join path; unused parameter.
serve.py:547 environment.apply(configuration, (gpu,)) runs (and applies runtime patches) before knock (549) and therefore before serve_peer reads the early command at host_ranks.py:646-648, so import-time b12x reads cannot be influenced by it. Env sent twice (host_ranks.py:345-347 and in assignment, :377) and validated/applied twice (647, 666-668); the new test (test_host_ranks.py:405-411) locks in the redundancy. HostRendezvous.prepare(..., b12x_environment=None) (host_ranks.py:313-314) has no caller — rank_group.py:286 calls ranks.prepare with only checkpoint/progress/core_storage.
FINDING 10 — Tests/claims.
- test_tuning_shards.py:287-303 asserts rank 0
configs == {}and rank 1{divergent.plan: 1, aliased.plan: 1}, then hand-rewrites_prepared; the realcoordinator.prepare(..., selected_configs=...)(collectives.py:484-519) and the tuning.py:506-518 loop are never exercised, so reconcile→re-prepare→agree_selections is untested end to end. - No test covers the peer export branch
export_options(core_cache, ..., kernel_cache=kernel_cache)(host_ranks.py:718-719) → runtime_core.py:405-408compile_gpu_codec_cubin(cache_dir=cache.kernel_cache), the only place peers choose their own cubin dir. - No post-rewrite test for
changed is False. - The live 2x GB10 TP2 GLM-5.3 export+join (the #651 configuration) is explicitly not run, so
Fixes #651is unproven; PR body claims convergence not root cause (#651's_mixed_tuning_batches53-vs-65 catalog skew is untouched, tuning.py:229-255).
SOUND (say plainly): changed and configs both derive from target_for over the same all-gathered catalogs (collectives.py:429-449), so ranks cannot split on whether to enter the pass (fixes the #647-era liveness hole); _save_compiled_function same-dir temp + os.replace is correct on POSIX and Windows; _remap_peer_config handles frozen dataclasses and mutable configs (host_ranks.py:212-219); test_forward_artifact_sharing.py:153-154 now round-trips real bytes, strengthening the sharing tests.