Correctness, Contracts & System-Level Consequences review — PR #668 (fix(ignition): reconcile divergent multi-host selections…), head d6a0069
Key findings
The diff is well-structured in its atomics and in its wire handling, but three findings carry the review and all three are verified from source at head:
- Major — the peer
b12x_environmentis applied after b12x is already imported, so the PR's central ordering claim is false (ignition/cli/serve.py:547→ignition/cli/environment.py:82→ignition/runtime_patches/workers.py:27, versus the apply atignition/preparation/host_ranks.py:645-648). Theassignment["b12x_environment"]re-application at:666-668can never add anything, so it is redundant. - Major —
ForwardCache._loadnow swallowsOSError/ValueError/TypeError/KeyError/AttributeError/RuntimeError, unlinks the cached.binand returns a cache miss (ignition/preparation/aot.py:64-76, handler:1371-1380), which is precisely the "swallow, skip or retry an unexplained error" pattern charter #397 forbids, and the unguardedunlinkconverts a read-only cache into a fatal error. - Major system-level consequence — a divergent rank 1 now forces every job's re-preparation on all ranks via
changedcomputed over all gathered ranks (ignition/preparation/collectives.py:436-440) whileconfigsholds only locally divergent entries (:441-449), consumed byignition/preparation/tuning.py:521-535; it multiplies the cost of the very retry loop (#651) the PR aims to end.
Lesser findings: the forward-cache key hashes ambient B12X_* while only the recipe mapping crosses to peers (hosts silently fork the cache; the exclusion list is a denylist so future knobs fork by default); reconcile keys on (name, variant, component_id) while agree_selections keys on bare name and reconcile is unscoped by operation group, contradicting its own docstring; HostRendezvous.prepare(..., b12x_environment=None) has no caller. Areas I verified as sound are listed at the end, plus a documentation gap against AGENTS.md:234.
I found no maintainer review, and no evidence that this diff ran on 2× GB10; the two hardware comments on the PR validate the diagnosis and the manual workarounds, not this head.
F1 — Major: peer b12x_environment is applied after b12x.preparation is imported; the description's ordering claim is factually wrong
Citations: ignition/cli/serve.py:547-555, ignition/cli/environment.py:5-11 and :82, ignition/runtime_patches/__init__.py:119, ignition/runtime_patches/workers.py:26-29, ignition/preparation/host_ranks.py:645-648, :666-668, :297, :313-326.
PR text (What changed → peer propagation): "HostRendezvous.prepare sends non-empty b12x_environment ahead of assignment unpickling (so import-time reads see it)".
ignition/cli/serve.py:547-555 (verbatim):
environment.apply(configuration, (gpu,))
identity = source_identity()
control, executor = knock(args.rendezvous, args.rank, args.ranks, identity=identity,
topology=local_topology(gpu), report=progress)
serve_peer(control, executor, args.rank, args.ranks, hub_cache=hub_cache, progress=progress,
export_staging=configuration.directory("export_staging"), identity=identity,
core_cache=configuration.directory("core_cache"),
kernel_cache=configuration.directory("kernel_cache"),
checkpoint_token_file=configuration.get("preparation.checkpoint_token_file").value)
environment.apply ends with runtime_patches.apply() (ignition/cli/environment.py:82), which calls workers.register_hooks() (ignition/runtime_patches/__init__.py:119), which does from b12x.preparation import register_worker_initializer (ignition/runtime_patches/workers.py:27). The peer env only arrives afterwards, inside serve_peer:
ignition/preparation/host_ranks.py:645-648
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)
The contract that makes this a defect is stated in ignition/cli/environment.py:5-11: "PyTorch, b12x, Triton, and the CuTe DSL read these variables when they are imported or first used. apply sets the environment before installing runtime patches." Rank zero gets its recipe env at ignition/cli/serve.py:211 (environment.apply(configuration, local, plan.recipe.b12x_environment)) before apply installs patches; a peer gets it after. Any B12X_* variable that b12x caches at import time therefore still differs between rank zero and peers — the exact asymmetry #668 claims to remove.
The accurate statement of what the code does: the peer env precedes the recipe/operator imports and preparation, because those happen later at host_ranks.py:665 (assignment = receive_object(control)) and :670 (prepare = assignment["prepare"]). That is sufficient for B12X_W4A16_A4_PREFILL, which is read from os.environ during preparation, and explains why the two 2× GB10 comments on the PR see the expected speedup. It is not sufficient for anything read at b12x import time.
Consequence: assignment["b12x_environment"] re-application at host_ranks.py:666-668 is dead weight — it can only re-set what the early frame already set (prepare sends exactly the same validated mapping at :345-347), so there is no second chance, just a redundant write.
Fix (the dropped #675 ordering): validate and reply with the mapping in _admit (host_ranks.py:276-299; the reply at :297 is currently send_json(sock, {"accepted": True, "session": self.session})), and in join run knock() first, then environment.apply(configuration, (gpu,), b12x_environment), then serve_peer. Failing that, correct the description and document the invariant "peer env is not visible to b12x.preparation's import" — no doc currently records it (search_code over docs/ for b12x_environment|reconcile_selections returns nothing).
F2 — Major: _CORRUPT_ARTIFACT_ERRORS swallows transient and genuine errors and deletes the artifact
Citations: ignition/preparation/aot.py:64-76, :1371-1380, :1377; test tests/preparation/test_forward_cache_sources.py:194-217.
aot.py:64-76
_CORRUPT_ARTIFACT_ERRORS = (
EOFError,
pickle.UnpicklingError,
struct.error,
zlib.error,
zipfile.BadZipFile,
OSError,
ValueError,
TypeError,
KeyError,
AttributeError,
RuntimeError,
)
aot.py:1371-1380
def _load(self, forward, path, *, required=False, before_run=None):
try:
with bind_device(self.device, freeze_tuning=self.options.get(
'triton.autotune_at_compile_time', False)), 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
Two concrete impacts:
- Transient I/O and real runtime faults are reported as "corrupt cache".
path.open('rb')is inside the try (:1374), so anEMFILE,EIOor ENOSPC-on-readOSErroris reinterpreted as a corrupt artifact and the valid.binis deleted, forcing a full recompile of that forward — expensive in wall-clock (the dossier prices a failed multi-host attempt at ~2h15m) and invisible to the operator because nothing is logged.RuntimeErrorsimilarly covers driver/version faults andtorch.OutOfMemoryErroris only singled out to be re-raised. This is the charter #397 antipattern verbatim: "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error." - Unguarded unlink on a read-only cache.
unlink(missing_ok=True)only toleratesFileNotFoundError; on a read-only or root-owned cache directory it raisesPermissionErrorout of an opportunistic restore, turning "cache miss → recompile" into a hard preparation failure.
Fix: narrow the tuple to true deserialization errors (EOFError, pickle.UnpicklingError, struct.error, zlib.error, zipfile.BadZipFile, a short allowlist of torch archive errors), log the swallowed exception at warning level with the path, and wrap the unlink (try: Path(path).unlink(missing_ok=True) except OSError: pass).
Also (Minor, claim accuracy): the MemoryError arm at :1377 is dead — MemoryError is a subclass of neither listed type (only torch.OutOfMemoryError subclasses RuntimeError). The appended test test_forward_cache_recovers_from_corrupt_cached_bin_on_restore (tests/preparation/test_forward_cache_sources.py:212-217) monkeypatches load_compiled_function to raise MemoryError and asserts it propagates, which it does trivially because MemoryError is outside _CORRUPT_ARTIFACT_ERRORS; the assertion does not exercise the :1377 branch it claims to cover. The description's "while still raising on … MemoryError / torch.OutOfMemoryError" therefore overstates what the code does for MemoryError (it raises by omission, not by design).
F3 — Major: widened mismatch detection makes every rank re-prepare every job, with an empty override map on the ranks that agreed
Citations: ignition/preparation/collectives.py:436-449, ignition/preparation/tuning.py:521-535, evidence in tests/preparation/test_tuning_shards.py:264-324.
collectives.py:436-449
changed = any(
(target := target_for(decl_key, name_key)) is not None and payload != target[0]
for rank_entries in gathered
for decl_key, name_key, payload, _ in rank_entries
)
configs = {}
for plan, decl_key, name_key, payload, _ in entries:
target = target_for(decl_key, name_key)
if target is not None and payload != target[0]:
target_payload, config = target
if plan in configs and plan.contract.config_payload(configs[plan]) != target_payload:
raise ValueError("one plan has conflicting rank-shared configurations")
configs[plan] = config
return configs, changed
tuning.py:521-535
if (self._coordinator is not None and len(self._coordinator.ranks) > 1
and (self.tuning_replica is None or self.tuning_replica.index == 0)):
configs, changed = self._coordinator.reconcile_selections(requests)
if changed:
if shard_ranks is not None:
self.configure_tuning_shard(0, (0,))
try:
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}))
changed is computed over all gathered ranks (so all ranks enter the pass in lockstep — that part is correct and deliberate), but configs only holds entries where this rank's payload differs from the target. In the exact #651 GLM-5.3 TP2 case the new 2-rank test in this PR asserts this asymmetry directly: rank 0 ends with configs == {} while rank 1 gets both entries. Rank 0 then re-runs prepare(..., autotune=self.autotune, selected_configs={}) for every job — i.e. it re-enters autotuning with no overrides, only to re-derive the selections it already had, while rank 1 re-prepares with the adopted config. The PR widens the trigger ((request.name, variant, component_id) matches now reconcile payloads that the old portable_declaration-only rule ignored — the dossier's 1,648 differing selections on the real hardware), so this wasteful full re-prepare fires on cases that previously did not reach the pass at all.
Fix: pass the rank's own already-agreed selection for each plan in configs for every plan in plans (from request.plan.selection), so the reconcile pass re-binds rather than re-races, and/or pass autotune=False on this second pass. At minimum, the description's "Expected result" should state that one divergent rank costs all ranks a full re-preparation pass, rather than implying convergence is cheap.
F4 — Minor: forward-cache identity hashes ambient B12X_*, but peers only receive the recipe-declared mapping
Citations: ignition/preparation/aot.py:79-87, :897-899, :47-62; ignition/preparation/host_ranks.py:201-209; ignition/cli/serve.py:193-197, :416-420.
aot.py:897-899
key = hashlib.sha256(pickle.dumps((namespace, options, _b12x_forward_env(), torch_key(),
runtime_patches.identity(), properties.name, properties.major, properties.minor,
properties.multi_processor_count)))
_b12x_forward_env() (:79-87) reads os.environ on the local host. The peer side only ever receives the validated recipe mapping — _validate_b12x_environment rejects non-B12X_ names, B12X_COMPILE_CACHE_DIR and non-string values (host_ranks.py:205-208), and rank zero sends model.recipe.b12x_environment (serve.py:197, :420). So a B12X_* variable exported in rank zero's shell changes rank zero's ForwardCache.root and not the peers'.
Impact: the stated goal ("distinct hosts with different cache paths keep identical forward-cache root names") holds for filesystem paths, but the same divergence re-enters through the environment — heterogeneous hosts silently fork the forward cache, losing the peer transfer that _share_artifacts exists to provide, and each fork recompiles the catalog. The exclusion list _NON_EXECUTION_B12X_ENV (aot.py:47-62) is a denylist, so any future B12X_* diagnostic knob not added to it forks the cache by default (with a full one-time recompile as the failure mode — the description even accepts this for existing knobs).
Fix: hash the recipe's declared b12x_environment mapping (already transported to peers, so rank zero and peers agree by construction) instead of ambient os.environ; or make the exclusion list an allowlist of execution-relevant names.
F5 — Minor: reconcile keys differ from agree_selections keys and are unscoped by operation group
Citations: ignition/preparation/collectives.py:218, :377-392, :398-410, :429-434, docstring :399-406, error text :394-396.
_selected_plan_catalog now records (plan, decl_key, (name, variant, plan.component_id), payload, config) (:218), and target_for prefers the name key (:429-434); agree_selections compares bare names: local = {item["name"]: (item["component"], json.dumps(...)) (:377) scoped by self.operation_ranks (:381-392). Two consequences:
- A pair that agrees on
namebut differs oncomponent_idis treated as "matching" by neither mapping in the same way — reconcile will not flag it (samename_keymeanstarget_forreturns a target only on payload difference, and a differingcomponent_idchanges the key so the two never match), soagree_selectionscan still fail forever on a name that reconcile cannot repair. reconcile_selectionsgathers the whole group with nooperation_ranksscoping (:411-425), so for a request owned by a subgroup that excludes rank zero,chosen_name/chosen_declcome from the lowest participating rank, contradicting the docstring "adopt rank zero's configuration" (:403-405) and the error text "differ from rank zero's" (:395-396). Behaviourally this matchesagree_selections'root = gathered[positions[0]], so it is not a bug — but the comments say something the code does not do.
Fix: derive both keys from one function so reconcile and agree cannot disagree about "the same selection"; replace "rank zero" with "the operation's first rank" in the docstring and error text; scope the gather by self.operation_ranks like agree_selections does.
F6 — Minor: HostRendezvous.prepare(..., b12x_environment=None) has no caller
Citations: ignition/preparation/host_ranks.py:313-326; sole caller ignition/preparation/rank_group.py:278-290.
host_ranks.py:313-326
def prepare(self, snapshot, config, prepare, *, checkpoint, progress=None, core_storage=None,
b12x_environment=None):
...
b12x_env = (self.b12x_environment if b12x_environment is None
else _validate_b12x_environment(b12x_environment))
rank_group.prepare_group calls ranks.prepare(snapshot, config, prepare, checkpoint=checkpoint, progress=progress, core_storage=core_storage) (rank_group.py:289) and never passes the new kwarg, so the override path is dead and the two env sources (constructor vs per-call) can silently diverge. The description's "wired from model.recipe.b12x_environment in _export_hosts and debug_serve" is true only via the constructor (serve.py:197, :420). Either drop the parameter or thread it from prepare_group.
Tests and claim accuracy
- Missing test for the finding that matters most. No in-repo test asserts the peer env lands before
environment.apply/the b12x import; the newserve_peertest (tests/preparation/test_host_ranks.py:346-438, verified) stubsdist.init_process_groupand only checksos.environand the remappedconfig.kernel_cache, which is why F1 passes CI. _remap_peer_confignon-dataclass branch untested (host_ranks.py:212-219,setattrat:218).- The
MemoryErrortest does not test theMemoryErrorarm (see F2 sub-note). - Description vs code, enumerated: (a) "so import-time reads see it" — false for
b12x.preparation(F1); (b) "while still raising on …MemoryError" — raises by omission (F2); (c) "includes sorted execution-relevantB12X_*environment bindings … so distinct hosts with different cache paths keep identical forward-cache root names" — true for paths, not for heterogeneous env (F4); (d) "reconcile … adopt rank zero's selected configuration" — the code adopts the operation's first rank's (F5). The validation section's "live 2-host GB10 TP2export+joinof GLM-5.3 were not executed" is honest, and per the dossier no one has run this head on 2× GB10;Fixes #651should be softened toRelated:until that run happens. - Charter/#210: this is a correctness PR, not a performance claim, so no served-workload A/B is owed — but the PR body does report a speedup indirectly ("peers prepared with different b12x behavior … directly contributing to declaration divergence"), which is only supported by third-party comments, not by a run of this diff.
Verified sound (no finding)
- Atomic
.binpersistence._save_compiled_function(aot.py:90-100) writes a sibling.tmpviaNamedTemporaryFile(delete=False), thenos.replace, thenfinally: temporary.unlink(missing_ok=True); used at all three save sites (:1326,:1454,:1463). POSIX rename is atomic, concurrent readers keep the old inode, and the explicit close makes it Windows-correct. The_share_artifactstemp handling (:870-877) preserves the same guarantee. - Peer
kernel_cacheremapping._remap_peer_configusesdataclasses.replacefor the frozenBasePreparationConfig(bootstrap.py:25-38, field at:37) and only replaceskernel_cache, which is the sole absolute path in that dataclass — no other rank-zero path leaks.export_options(..., remote_cache=True, kernel_cache=kernel_cache)(host_ranks.py:723-725) now composes correctly with the merged #667. - Lockstep.
changedis derived identically on every rank from the sameall_gather_object(collectives.py:436-440), so all ranks enter or skip the reconcile pass together; no collective divergence is introduced (the cost of entering it is F3). - New channel is not a wire-contract break.
PROTOCOL = 5(host_ranks.py:41) is unchanged and the("b12x-environment", …)frame is only sent after admission, so old/new rank mismatch is still caught by the version check (:285-286). The assignment dict remains advisory via.get(:666,:678). B12X_COMPILE_CACHE_DIRrejected over the new channel (host_ranks.py:205-208), so a peer cannot be pointed at rank zero's compile cache.- Platform parity: no new Unix-only call;
os.replaceandunlink(missing_ok=True)are correct on both POSIX and Windows. - Metric/rate/admission span check: this PR changes no rate, latency, admission metric,
estimated_secondsspan, or sampled scope, so there is nothing to re-price downstream. - Docs gap (not a blocker):
AGENTS.md:234asks multi-host preparation changes to updatedocs/multi-host.md; neither the peer env channel nor the reconcile contract is mentioned anywhere underdocs/, and the PR changes no doc file.
Open questions
- Will the author adopt #675's ordering (apply in
_admit/join, beforeruntime_patches.apply()), or document that peer env is invisible tob12x.preparation's import? @Reederey87 asked exactly this on 2026-12-02; no reply as of head. - Which of
OSError/RuntimeErroris the corrupt-cache tuple meant to cover, and is the unlink intended to survive a read-only cache? Unanswered in the description and in review. - Does the reconcile pass intend to re-autotune on the ranks whose
configsis empty (F3)? If yes, the ~2h15m cost per divergent attempt should be stated; if no,autotune=Falseon the second pass. - Does #668 converge on 2× GB10/SM121 at head? Still unrun by anyone.
Not found: maintainer review or assignment; CI conclusion for d6a00698; any 2× GB10 run of this head; any doc/CHANGELOG entry for the peer env channel or peer-local kernel_cache remap; any coordination note on ordering with the open aot.py PRs #597/#678 and host_ranks.py/test PR #671.