Correctness, Contracts & System-Level Consequences review — PR #597 (head f8a033a)
Reviewed: ignition/preparation/aot.py, ignition/preparation/compile_pool.py, ignition/preparation/inductor_tuning.py, tests/preparation/test_mixed_gpu_inductor_keying.py, plus direct callers/contracts (ignition/preparation/host_memory.py, ignition/preparation/compilation.py, ignition/cli/preparation.py, docs/model-preparation.md, docs/preparation-development.md) and the diff for each file.
Key findings
- Major — the PR's stated premise (cross-SKU artifact sharing on
main) is false.ForwardCache.roothas always hashedproperties.name(aot.py:752-763), so different GPU product names never shared a cache root or an artifact. Only the lending loop and the host-widepublication.lockwere shared. The new{variant}.{gpu_tag}suffix (aot.py:939-944) therefore buys no isolation — it only invalidates otherwise-reusable cache entries. - Major —
heterogeneousis computed over the whole TP group, so a homogeneous host is pushed onto suffixed variant names by its peers. Mixed TP4 and homogeneous TP2 runs on the same card can never reuse each other's forward cache, and mixed runs compile and store a full catalog per SKU. The new tests assert this doubling as expected (8 vs 4 artifacts) with no measurement. - Major — admission pricing span changed and now double-counts the discount. The per-group fallback in
compile_pool.py:107-114charges the 2 GiB "small forward" estimate once per SKU group while each such worker's conservative peak is 32 GiB (host_memory.py:13-15), so a host admitted for 2×2 GiB can start 2×32 GiB of compilers — the opposite of what the inline comment claims. - Major — the
MemoryErrorpolicy moved from per-host to per-group, so a mixed host that previously compiled serially now fails preparation outright;docs/model-preparation.md:238-243still documents the per-host policy. - Major — docs contradicted in three places, none updated (
docs/model-preparation.md:203-209, 231-245,docs/preparation-development.md:351-371). - Major — the headline benefit is not delivered by this PR and has no isolated evidence. The tuning half lives in still-open PR #150; the description's evidence is whole-pipeline serving it labels "not attributable solely to this PR" (charter #210).
- Minor —
ValueErrorfloor for compiler worker limit (compile_pool.py:89-92); a CUDA-unavailable rank is reported as "incompatible CUDA architectures" (inductor_tuning.py:21-26+aot.py:933-938); asymmetric GPU identity (normalized tag for names, raw name for grouping/lending); per-SKU_balance_compilationskeeps a host-wide error message; "96 passed" is unverifiable and no GPU/distributed suite covers the changedwarm(). - Verified sound:
(host, resolved_root)lock keying and sorted acquisition order, barrier parity per key,groups=Noneback-compat,_variant()applied at every artifact site, no new collective added towarm(), no hot-path contention regression.
A. Correctness, Safety & Platform Parity
A1. Major — a CUDA-unavailable rank is misreported as a mixed-architecture host
ignition/preparation/inductor_tuning.py:21-26 (new):
def _cuda_device_identity(device):
"""Return `(product_name, compute_capability)` for a CUDA device, or `('', None)` otherwise."""
resolved = torch.device(device)
if resolved.type != "cuda" or not torch.cuda.is_available():
return "", None
return torch.cuda.get_device_name(resolved), tuple(torch.cuda.get_device_capability(resolved))
ignition/preparation/aot.py:933-938:
capabilities = {cap for _, cap in identities}
if len(capabilities) > 1:
ordered = sorted(capabilities, key=lambda cap: (cap is None, cap))
raise RuntimeError(
f"tensor-parallel ranks span incompatible CUDA architectures: {ordered}"
)
Impact: anything that makes torch.cuda.is_available() false on exactly one rank (forked child before CUDA init, CUDA_VISIBLE_DEVICES leak, driver hiccup) folds that rank in as capability None and the operator gets "incompatible CUDA architectures" for a single-SKU host. The real fault — one rank has no usable CUDA device — is never named, and the same message appears at inductor_tuning.py:250-255. Fix: raise a distinct error when a nonempty gpu_name set and a None capability coexist ("rank N reported no CUDA device identity") before comparing capabilities, and apply the fix in both gates.
The None-ordering comparator itself is safe: (cap is None, cap) never compares None to a tuple, so no TypeError.
A2. Minor — two different definitions of "same GPU"; artifacts are safe but the identity is forked
aot.py:940 normalizes for artifact file names:
gpu_tag = "".join(ch if ch.isalnum() else "_" for ch in gpu_name).strip("_").lower()
while grouping, lending, and Inductor validation use the raw name (aot.py:995-1004 groups=gpu_names and gpu_names from _cuda_device_identity; inductor_tuning.py:247-249 variant_key = (…, gpu_name)).
I checked the collision hazard and it is not a correctness bug today: ForwardCache.root already keys on the raw properties.name (aot.py:752-753), so two names that normalize identically land in different roots and cannot collide on a file. What remains is a maintenance hazard: two identity definitions that must stay in lockstep, with only substring assertions in tests (tests/preparation/test_mixed_gpu_inductor_keying.py:145-146) and no injectivity test. Fix: define one identity helper (raw name + a hash of the raw name for the suffix) and assert distinct tags for the two real device names in the test.
A3. Verified sound — lock keying, ordering, barriers
aot.py:788-804:
index = coordinator.ranks.index(dist.get_rank())
key = (coordinator.hosts[index], str(self.root.resolve()))
gathered = [None] * len(coordinator.ranks)
dist.all_gather_object(gathered, key, group=coordinator.group)
holder = gathered.index(key) == index
keys = sorted(set(gathered))
Checked and cleared: Path.resolve(strict=False) works before self.root.mkdir (the tail component is not symlink-resolved, consistently across ranks); each holder acquires exactly one lock and every rank walks the same sorted keys, passing through one barrier per key, so there is no lock-ordering deadlock and no barrier-count skew; the failure path still skips only the final barrier exactly as on main (aot.py:806). Cost is one extra all_gather_object plus one barrier per distinct (host, root) — on a homogeneous host one extra collective total, not a hot path. No head-of-line-blocking finding.
InductorSelections.warm gained no collective: one _gather before, one after (inductor_tuning.py:249).
B. Unintended System-Level Consequences
B1. Major — admission pricing span changed: the 2 GiB discount is now multiplied per SKU group
compile_pool.py:105-118 (new):
# Small forwards can fit below the concurrency estimate. Preserve one worker per
# active group under the minimum allowance without multiplying that allowance.
able = [rank for rank in subgroup if resources[rank].capacity
and resources[rank].worker_bytes - host_memory.FORWARD_WORKER_BYTES
+ host_memory._WORKER_BYTES <= remaining]
if able:
rank = able[0]
workers[rank] = 1
remaining -= (resources[rank].worker_bytes - host_memory.FORWARD_WORKER_BYTES
+ host_memory._WORKER_BYTES)
admitted += 1
Constants (host_memory.py:13-15): _WORKER_BYTES = 2 << 30, FORWARD_WORKER_BYTES = 32 << 30, _HEADROOM_BYTES = 8 << 30; resources[rank].worker_bytes = FORWARD_WORKER_BYTES for discrete GPUs (compile_pool.py:57-59). So the fallback charges 32 − 32 + 2 = 2 GiB per admitted worker, while the same worker's conservative peak is 32 GiB, and the surplus loop right below charges the full resources[rank].worker_bytes (compile_pool.py:120-127).
The main version charged that 2 GiB discount once per host; this version charges it once per active group, i.e. len(active_groups) times. Concretely, on the PR's own 4-GPU mixed host with two SKUs and 44 GiB available host memory (8 GiB headroom → 36 GiB remaining): group 1 takes the full 32 GiB path, group 2 takes the fallback for 2 GiB — 34 GiB charged, ~64 GiB of real peak demand on a 44 GiB host. The comment "without multiplying that allowance" is exactly what the code now does. This is the metric/admission-pricing span check for this PR: the sampled scope went from host to (host, group) without re-pricing the estimate. Impact: OOM-killed preparation ranks, or _WORKER_BYTES-priced workers whose real footprint the next launch's admission decision also under-estimates — on exactly the hardware the PR targets (two 600 W workstation cards plus CPU compilers in one box). Fix: when the fallback discount is used, remember the discount per rank so the surplus loop and subsequent accounting use the same number, and gate the fallback on the discounted estimate times the number of active groups so the host total stays within the 32 GiB policy.
B2. Major — MemoryError policy moved from per-host to per-group, breaking hosts that used to prepare serially
compile_pool.py:116-118:
if any(not any(workers[rank] for rank in subgroup) for subgroup in active_groups):
raise MemoryError(f"host {host!r} has {jobs} missing forwards but no capacity for a forward compiler "
f"({available >> 20} MiB available host memory, {headroom >> 20} MiB headroom)")
main raised only when no rank on the host got a worker and then ran everything through one worker. Now every active SKU group must be admitted. The new test asserts the failure at 40 GiB (tests/preparation/test_mixed_gpu_inductor_keying.py:155-158), i.e. a host with 40 GiB available, which docs/model-preparation.md:238-243 still promises will "start under the 2 GiB minimum host allowance":
When that estimate admits no worker, one worker per host may start under the 2 GiB minimum host allowance plus integrated device storage.
Impact: a mixed-SKU workstation whose export previously finished slowly now aborts with MemoryError before compiling anything; the operator has no knob (see B3) and no doc that says the floor is now per SKU. Failure blast radius is the whole export, surfaced as preparation failed:, on the first host to be admitted. Fix: either keep the host-wide fallback and let a small host serve the second SKU serially through the one admitted pool, or update docs/model-preparation.md:238-245 to state the per-group floor and the RAM it implies.
B3. Minor — the new ValueError turns a CPU-budget reduction into a fatal error, with a narrower trigger than the PR implies
compile_pool.py:88-92:
limit = min(jobs, min(resources[rank].limit for rank in members))
if limit < len(active_groups):
raise ValueError(
f"host {host!r} has {len(active_groups)} active compiler groups but worker limit {limit}"
)
I traced the trigger precisely rather than repeating the PR's framing. limit comes from compiler_resources (compile_pool.py:42-44): min(cpu_workers(compile_workers), cpu_workers()), then min(limit, options['compile_threads']) when compile_workers is None, where compile_threads defaults to min(16, os.cpu_count() or 1) (compilation.py:30) and cpu_workers divides by the host CPU budget/affinity (host_memory.py:31-35). Because active_groups only contains groups with pending work, len(active_groups) <= jobs, so ValueError fires only when the host's CPU budget (affinity/cgroup or compile_threads) is smaller than the number of active SKU groups — not from --compile-workers alone, since the CLI already requires >= world_size (cli/preparation.py:85-86, :96-97). Homogeneous hosts can never hit it (active_groups == [members]). Severity is therefore Minor, but it is a real new hard-failure path for a containerized mixed host with a tight CPU affinity mask, and the error names a "worker limit" the operator may never have set. docs/model-preparation.md:232-233 says "Available RAM and device memory can reduce it", which no longer describes a fatal path. Fix: fall back to host-wide seeding (one shared pool serving both groups) instead of raising, and document the floor.
B4. Minor — per-SKU lending narrows _balance_compilations' message without narrowing its text
aot.py:1007-1008 now passes a per-SKU slice:
local = _balance_compilations([counts[index] for index in members],
[workers[index] for index in members])
where members is a single (host, gpu_name) subgroup (aot.py:1000-1004), but the error text at aot.py:681-682 is unchanged: raise MemoryError("no rank on this host has room for a forward compiler"). On a mixed host the operator reads "no rank on this host has room" while the other SKU on the same host is compiling fine. Fix: include the product name in the message.
C. Architecture, Contracts & Charter Compliance
C1. Major — the description's central premise is contradicted by unchanged code
PR text ("Why this change is proposed"):
Previously,
ForwardCache._prepare_ranks(ignition/preparation/aot.py) shared compiled forward artifacts and lent missing compilations across all ranks on a host without distinguishing GPU product names
aot.py:750-763 (untouched by this PR):
properties = torch.cuda.get_device_properties(device)
options = {name: value for name, value in self.options.items() if name != 'compile_threads'}
key = hashlib.sha256(pickle.dumps((namespace, options, torch_key(), runtime_patches.identity(),
properties.name, properties.major, properties.minor, properties.multi_processor_count)))
...
self.root = root / 'forwards' / key.hexdigest()
properties.name is part of the cache key, and _path hashes the variant name inside that root (aot.py:1212-1214). Two SKUs have never shared a root or a .bin. Only the lending/assignment loop and the single host-wide publication.lock were shared — the latter is genuinely fixed (aot.py:773-810), the former genuinely improved.
Impact: the artifact-name suffix (§C2) is justified by a premise that does not hold; reviewers cannot evaluate the cost/benefit from the description, and the real rationale (a variant name that is unambiguous across SKUs for human-readable cache listings) is never stated. Fix: correct the "Why" section to say only lending and the publication lock were shared, and either drop the suffix or justify it as naming hygiene.
C2. Major — heterogeneous is group-wide, so cache identity depends on peer set, not on the card
aot.py:929-944:
identities = [None] * len(ranks)
dist.all_gather_object(identities, (gpu_name, capability), group=group)
gpu_names = [name for name, _ in identities]
...
heterogeneous = len(set(gpu_names)) > 1
gpu_tag = "".join(ch if ch.isalnum() else "_" for ch in gpu_name).strip("_").lower()
def _variant(forward):
base = getattr(forward, "compilation_variant", "shared")
return f"{base}.{gpu_tag}" if heterogeneous else base
identities covers every rank of the TP group, including other hosts. Consequences, both verified from code:
- The same RTX PRO 6000 Workstation Edition card writes
{name}in a homogeneous TP2 run and{name}.nvidia_rtx_pro_6000_blackwell_workstation_editionin a mixed TP4 run — even though itsForwardCache.root(per-device-name key,aot.py:752-763) is byte-identical. So mixed and homogeneous runs on the same host can never reuse each other's forward cache, and a cross-host TP group whose peer host has a different card model suffixes a host that has none. - Combined with the existing per-device root, the suffix isolates nothing: it only changes the sha256 input at
aot.py:1213.
The new tests encode the cost: 8 artifacts for the mixed host vs 4 for the homogeneous one (tests/preparation/test_mixed_gpu_inductor_keying.py:143-146, :171, :262-263), i.e. a full extra compile of the catalog per SKU, with no wall-clock or disk number anywhere in the description. This is a cache-invalidation regression on common paths (homogeneous card, changed peer set) introduced by a change whose charter justification is "bug fixes need to address the root cause".
Fix: drop the suffix and rely on the already-per-device root for artifact isolation; or, if the readable filename is wanted, key heterogeneous on the (host, gpu_name) partitions actually used for lending/sharing rather than on the whole rank list, so a card's artifact name is a function of its own hardware.
C3. Major — the headline benefit lives in a separate, still-open PR, and the evidence is not attributable
PR text: "Enables tensor-parallel preparation (ignition export --gpus ...) on mixed-SKU same-architecture SM120 hosts without relaxing compute-capability invariants."
The diff touches aot.py, compile_pool.py, inductor_tuning.py only. InductorSelections.warm's change stops the inventory-agreement check from comparing across SKUs (inductor_tuning.py:247-260); it does not make cross-SKU tuning agree. The one documented mixed-SKU abort — #150's BindingMismatch: rank-local forward does not match compiled guards, layer 20 csf_inline_scales split 2/2 — is a tuning disagreement handled by reconcile_selections in ignition/preparation/tuning.py (not opened), which this PR does not change. So the PR alone cannot deliver the claim, and the description never says the enabling work is a separate open PR (#150, same author, CHANGES_REQUESTED from yatesdr 2026-11-18 for exactly "show the failure on main").
Charter compliance: the description's own qualifier — "Whole-pipeline serving metrics verify integration compatibility and are not attributable solely to this PR" — leaves no isolated measurement of the changed preparation step (compile wall clock, worker shape, cache footprint, mixed vs homogeneous on the same host) against main, which is what the charter's "bring real evidence… #210" requires for a performance/behaviour change. Fix for adjudication: request (i) a main-vs-f8a033a reproduction of the abort this PR removes, and (ii) an isolated measurement on the PR's own 4-GPU host: compile wall clock and forward-cache bytes, mixed vs homogeneous, before vs after.
C4. Major — the change contradicts three statements in shipped docs; none updated
No docs/*.md file is in the diff. Stale at head:
docs/model-preparation.md:231-236— "--compile-workers Nsets a positive CPU compiler process budget per host … Available RAM and device memory can reduce it; local preparation ranks share the budget." Reduction is now either fatal (compile_pool.py:89-92, B3) or fatal-by-MemoryErrorper group (B2).docs/model-preparation.md:238-243— "Ranks without a worker lend missing forwards to other ranks on that host … When that estimate admits no worker, one worker per host may start under the 2 GiB minimum host allowance plus integrated device storage." Lending is now(host, gpu_name)-restricted (aot.py:1000-1010) and the floor is per group (compile_pool.py:116-118).docs/preparation-development.md:351-371(per the dossier) — "Ranks on one host share its cache directory" and "select a variant key throughcompilation_variant"; on a mixed host variants are silently rewritten by the group-wideheterogeneousflag (C2), so a per-rankcompilation_variantno longer determines the artifact name.docs/model-preparation.md:203-204("tensor-parallel ranks on identical GPUs divide the candidates of a shared local kernel race") similarly presupposes homogeneous cards.
Fix: update all three in this PR; AGENTS.md:515 requires docs touched by a change that makes them stale.
D. Tests & Claim Accuracy
D1. Minor — the changed warm() has no real distributed or GPU coverage in the PR, and "96 passed" is unverifiable
The only added coverage of the changed path is stub-driven (tests/preparation/test_mixed_gpu_inductor_keying.py:277-306, scripting self._gather with a fixed reply list), so it asserts gather ordering, not distributed behaviour. The suite that actually exercises warm/prepare_many with a real coordinator — tests/preparation/test_inductor_tuning_cuda.py:565-655 — is not reported as run. "96 passed in 46.13s" has no attached command or log; the five named suites exist on main, so it is plausible but not verifiable from the PR. _prepare_ranks tests replace _load/_path/_allocation_sizes and the compile pool (tests/preparation/test_mixed_gpu_inductor_keying.py:48-56), so no real artifact, real Triton inventory, or real per-SKU root is exercised. Fix: run and report the CUDA tuning suite (or state it as an explicit limitation) and attach the exact command/log for the CPU run.
D2. Minor — new tests encode the doubled compile cost as expected, and inherit a rebase hazard
tests/preparation/test_mixed_gpu_inductor_keying.py:143-146 and :171 assert 8 artifacts for a mixed host vs 4 for a homogeneous one (:262-263) with no time/bytes bound — the cost of C2 becomes a test invariant. The file also imports private fixtures across modules (:17, from tests.preparation.test_forward_artifact_sharing import _Artifact, _Forward, _Pool, _replace_gpu_preparation), and that module is rewritten wholesale by the draft PR #584 (+1463/−4), so whichever lands first forces the other to rebase and the fork-context pattern used here (:98, :229) is the one voipmonitor flagged in #584. The private-import itself is not a core-boundary violation (checked against tests/preparation/test_core_boundary.py, which only forbids ignition importing recipes), and the monkeypatching at :51-56 happens in forked children, so it does not leak.
D3. Verified accurate parts of the description
Lending isolation (aot.py:1000-1010) and the multi-root publication lock (aot.py:773-810) are real and correctly described; cross-architecture rejection is indeed verified only by CPU tests, as disclosed; "Rust tests not run because only Python changed" is correct (three Python modules plus one test file). No proto, manifest, core-format or artifact-format change; serving and Rust untouched; no new flag, setting or environment variable, so no per-model-special-case or new-op-contract objection applies.
E. Open questions / what could not be found
- Does the Inductor-inventory mismatch or the cross-SKU lending abort reproduce on current
main? No log, issue, or link exists, and #150's reviewer asked the identical question without an answer. Without this, C3's cost/benefit cannot be settled. - What does the per-SKU seeding cost in wall clock on the PR's 4-GPU mixed host versus
main's one-worker-per-host admission? No measurement given; C2's forced recompiles make this the highest-value missing number. - Cross-host mixed TP (rank sets where one host has no rank of a given SKU) is not covered by any test;
_share_artifacts(aot.py:698, called at:1101-1104) still shares paths across hosts under the assumption that peers compiled what a rank lacks. I did not find a concrete failure, but nothing verifies the suffixed-variant case. - Interaction with #122 (configurable compiler headroom, same functions in
compile_pool.py) and #592 (architecture admission) is unaddressed; whichever lands first forces a rebase on the admission code that B1/B2 change. Signed-off-by/Design-Signed-Off-Bytrailers onf8a033acould not be confirmed from the available material;CONTRIBUTING.md(not opened) requires them.