Correctness, Contracts & System-Level Consequences — PR #635
PR: Pass candidate GPUs into filter_world_sizes during planning (#635) · head 3c3c4df, one commit on main's 0a8c20f4.
Scope note: head 3c3c4df is newer than the Discovery Dossier's c2ef797 snapshot. The hoisted architecture check, supported as a tuple, the filter_gpus reuse in candidates(), and the documented docstring are all now on the branch; the dossier's A4 ("the review's suggested fix has its own defect") and A5 ("the author's reply is not on the branch") are therefore superseded — the fix landed, and its defect is now a live finding below (F1).
Key findings
No Blocker. No Major. The core invariant the PR claims holds: filter_world_sizes can never observe an unsupported device, and the automatic (no --gpus) path is behaviorally identical to main.
Three concrete Minors (ordered by priority):
- (Minor) Mixed explicit
--gpusselections losemain's parameter-first error precedence — the hoist atignition/planning.py:573-575now pre-empts the recipe-UsageErrorpath at:582-585, contradicting that block's own comment (:583-584) and changing the exit class from 2 to 4 for those selections. - (Minor) The new
context.gpuscontract sentence is inaccurate on the multi-host path this PR exists to enable —ignition/parameters.py:563-564vsignition/cli/serve.py:411-414,:421,:426. - (Minor) Test gaps and one vacuous assertion — no mixed-selection case, no exit-code assertion, and
tests/cli/test_planning.py:589-590passes unchanged onmain; only:594-595exercises the newcandidates()passthrough.
Also retracted: an earlier hypothesis of mine that the automatic path flipped exit 4 → exit 2 on wholly-unsupported hardware. It does not — filter_gpus is supported there (:566, :576).
1. Correctness, Safety & Platform Parity
F1 — (Minor) Mixed explicit --gpus selection: architecture CapacityError now pre-empts the recipe's parameter UsageError
ignition/planning.py:573-585 (head):
573 for gpu in chosen:
574 if not gpu.supported:
575 raise CapacityError(f"GPU {gpu.index} ({gpu.name}) is not an {SUPPORTED_ARCHITECTURES} device")
576 filter_gpus = chosen if chosen is not None else supported
577 plan_sizes = params.filter_world_sizes(world_sizes, replace(pre_context, gpus=filter_gpus))
...
582 if len(chosen) not in plan_sizes:
583 # Let parameter validation surface explicit UsageErrors (such as TP restrictions)
584 # before falling back to a generic capacity/GPU-count error.
585 params.validate(replace(pre_context, gpus=chosen, world_size=len(chosen)))
main put the same architecture check after that block (ref=main ignition/planning.py:577-587):
577 if len(chosen) not in plan_sizes:
578 # Let parameter validation surface explicit UsageErrors (such as TP restrictions)
...
585 for gpu in chosen:
586 if not gpu.supported:
587 raise CapacityError(f"GPU {gpu.index} ({gpu.name}) is not an {SUPPORTED_ARCHITECTURES} device")
Impact: for a selection that mixes supported and unsupported devices (e.g. --gpus 0,1 on a host whose GPU 1 is SM90), main reached params.validate(...) first and surfaced the recipe's own parameter UsageError (exit 2); head raises the architecture CapacityError (exit 4). Exit classes are user-visible: UsageError.exit_code = 2, CapacityError.exit_code = 4 (ignition/errors.py:13-22), returned to the process at ignition/cli/__init__.py:373-377. In-repo precedent for the masked error class is the SM103 rejection at tests/cli/test_planning.py:105-106 (raise UsageError("--sharded-prefill is not qualified on SM103; select SM120 or SM121 GPUs")). The new classification is defensible — the hardware genuinely is unusable — but it is an undeclared behavior change, and it makes the :583-584 comment untrue for any selection containing an unsupported device.
Fix (either): keep the architecture check where main had it and pass filter_gpus = tuple(gpu for gpu in chosen if gpu.supported) to :577; or keep the hoist and delete/reword the :583-584 comment. Add a mixed-selection test either way.
Same family, explicit path (also Minor): with --gpus 0 on a 4-GPU host and a recipe whose TP set is (4,), a recipe that now (legitimately, per the new docstring) narrows on context.gpus/len(context.gpus) returns () at :577, producing UsageError("no supported tensor-parallel size remains …") (exit 2, :578-579) where main's len(chosen) not in plan_sizes branch produced the actionable CapacityError("… needs 4 GPUs; 1 selected; use --gpus 0-3") (exit 4, main:581-584). Derived from both files; not executed.
F2 — (Minor) The new context.gpus contract sentence is inaccurate on the multi-host path
ignition/parameters.py:563-564 (new text):
563 ``context.gpus`` contains the explicitly selected GPUs (when ``--gpus`` is given)
564 or all supported host GPUs (during automatic planning), and ``context.world_size`` is ``None``.
Counterexample — ignition/cli/serve.py:411-426:
411 selected = planning.parse_gpus(args.gpus or "0")
412 if len(selected) != 1 or selected[0] >= len(host.gpus):
413 raise UsageError("multi-host ranks each use one GPU; --gpus names this host's")
414 local = (host.gpus[selected[0]],)
...
421 gpus = tuple(topology_gpu(topology, index) for index, topology in enumerate(topologies))
422 plan = planning.plan(
...
426 selected=None if args.ranks == 1 and args.gpus is None else tuple(range(len(gpus))),
With --ranks > 1, --gpus names exactly one local device, but plan() receives selected=tuple(range(len(gpus))) over every peer's GPU, so chosen — and hence context.gpus — is the whole cluster, not "the explicitly selected GPUs".
Impact: (a) a recipe written to the docstring misreads a 3-rank cluster as a 3-device local explicit selection; (b) an unsupported peer GPU trips the local-looking message at ignition/planning.py:574-575 ("GPU 2 (…) is not an SM…") even when this host's --gpus device is fine; (c) on multi-host the filter never receives the supported-only tuple the docstring calls the automatic case.
Fix: document the multi-host case in the docstring (candidate devices = the ranks' GPUs), or in docs/preparation-development.md:32-36, which lists the hooks but states no per-hook context contract.
F3 — (Minor) validate()/filter_world_sizes() context asymmetry, now more visible
params.validate(pre_context) at ignition/planning.py:563 still receives gpus=() and world_size=None (pre_context is built at :556-562 with neither field; defaults at ignition/parameters.py:130-131), while the filter at :577 now gets real GPUs. A recipe that reads context.gpus inside validate() — the in-repo precedent, tests/cli/test_planning.py:105-106 — can never fire pre-planning, whereas the same read inside filter_world_sizes() now does. fit() uses yet a third shape (gpus=gpus, world_size=len(gpus), :469-477) and Plan.parameter_context a fourth (:232-239). Fix: one sentence in the :561-565 docstring saying validate() runs before GPU resolution.
No parity/safety defect found
- Platform parity: the diff is pure Python. The only OS-conditional code nearby is
discover_gpus/_integrated_memory(ignition/planning.py:56-120,os.name == "nt"), untouched;topology_gpu(ignition/preparation/host_ranks.py:135-140) forwardscapabilityidentically on Linux and Windows. - State/reset, races, panics, error gaps:
plan()is one-shot and single-threaded in setup;ParameterContextis frozen andreplace()copies, so no shared mutable state. Notry/exceptswallowing, no retry, no partial-failure path added. - Metrics/observability: nothing samples rate, latency, or admission in or around this function; no metric span shrank or grew, so the metric/rate/pricing span check does not apply.
2. Unintended System-Level Consequences
No defect found, stated plainly. plan() is a one-shot setup function reached only from ignition/cli/preparation.py:70 (→ ignition/cli/serve.py:270, ignition/cli/bench.py:186) and ignition/cli/serve.py:200, :422. It runs before preparation and never on a serving path.
- Locks/queues/HOL blocking: none touched; no background workers, retries, or coalescing in the changed code.
- Memory/buffering/IO: no new buffers or copies;
supportedchanges from list to tuple (:566) and is used only read-only at:590,:602,:604,:614,:646. The filter call count is unchanged (one at:577plus one percandidates()call), so planning latency and allocation volume are the same asmain. - Failure blast radius: unchanged — every raise here terminates one CLI invocation.
- Interaction with recently merged features / invariant reversal: none. Both in-repo
filter_world_sizesoverrides ignorecontext.gpusand behave identically (tests/cli/test_planning.py:81-85,tests/cli/test_commands.py:55-59), so backward compatibility as claimed is real.
3. Architecture, Contracts & Charter Compliance
No defect found. The placement is the one the charter asks for: RecipeParameters signatures are unchanged, GPU-capability policy stays in recipes, and no model-specific branch or flag enters ignition.planning (charter: "Solve the right problem in the right place", "No per-model special cases or flags").
- Wire/captured-graph/public contracts: no protobuf, manifest, or serialized-plan change.
Plan.to_dict(ignition/planning.py:383-420) omitscapability, andignition.preparation.rebuild_manifest.from_plan(:258,:308) consumes plan parameters only. No owner sign-off trigger underAGENTS.md:227-232(Helios runtime / proto-core / speculation-logprob contracts) is engaged. - Charter evidence bar: this is not a performance PR, so the #210 served-workload A/B requirement does not apply. The declared limitation is honest — live 3-node SM121 validation lives in
local-inference-lab/hyperflare-recipes#103, unreadable from this repo; in-repo evidence is CPU-only with syntheticGpudescriptors. - PR-description accuracy vs head (verified): the description's "What changed" matches the diff exactly — hoisted
--gpusbounds and architecture checks,supportedas a tuple,filter_gpuspassed at:577and reused at:611-613, docstring added. The author reply's "Moved theif not gpu.supported:CapacityErrorcheck ahead ofparams.filter_world_sizes(...)… added an explicit SM90 test case" is now true of the code (:573-575;tests/cli/test_planning.py:596-599), as are the tuple, thecandidates()reuse, and the docstring. "29 passed, 0 failed" is consistent with head: exactly 29 tests collect across the four named files (test_planning7,test_commands2 + 3 parametrized,test_parameters7,test_gpu_discovery7 + 3 parametrized). - One residual imprecision: "preserving
CapacityErrorclassification for unsupported hardware" is silent about the narrowing described in F1 (a mixed selection's recipeUsageErrorprecedent is dropped). Not a false claim, but it should be disclosed.
4. Tests & Claim Accuracy
F4 — (Minor) Gaps in the new test; one assertion is vacuous
tests/cli/test_planning.py:568-599 is the only new test. Its fixture policy (:571-577) and assertions (:589-599):
589 # Automatic planning on 4x SM120 selects TP4, not TP3.
590 assert planning.plan(model, ckpt, sm120_gpus).world_size == 4
591 with pytest.raises(CapacityError, match="needs 4"):
592 planning.plan(model, ckpt, sm120_gpus[:3], selected=(0, 1, 2))
593 # Explicit and automatic planning on 3x SM121 allow TP3.
594 assert planning.plan(model, ckpt, sm121_gpus, selected=(0, 1, 2)).world_size == 3
595 assert planning.plan(model, ckpt, sm121_gpus).world_size == 3
596 # Explicitly selecting an unsupported GPU raises CapacityError before world-size filtering.
597 unsupported_gpus = tuple(_gpu(i, capability=(9, 0)) for i in range(4))
598 with pytest.raises(CapacityError, match="not an SM"):
599 planning.plan(model, ckpt, unsupported_gpus, selected=(0, 1, 2, 3))
:589-590is not evidence for the change. Withgpus=()(main's behavior) the:575condition is falsy and:577returnssize == 4— TP4 — so this assertion passes identically onmain. Only:594-595(3× SM121 automatic → TP3) exercises the newcandidates()passthrough atignition/planning.py:611-613, because onmaincontext.gpuswas empty and the fallback would yield only TP4.- No mixed-selection case, i.e. exactly the F1 path where head's precedence now differs from
main. - No exit-code assertion anywhere (
exc.value.exit_codeis never checked), although the PR's stated motivation is precisely exit 4 vs exit 2 (ignition/errors.py:13-22). - No multi-host test. The PR's motivation is cross-host SM121 TP3 vs single-host TP4, yet no test reproduces the shape at
ignition/cli/serve.py:411-414,:421,:426(one local--gpusdevice, all ranks' GPUs passed toplan()with a full-rangeselected). No heterogeneous-capability cluster case exists intests/cli/at all (SM90/(9, 0)appears only attests/cli/test_planning.py:597here).
Fix: add (a) a mixed selection asserting the intended error class and exit_code, (b) a synthetic two-host heterogeneous plan() test, (c) keep :594-595 as the passthrough evidence and either drop :589-590 or make it assert something the change actually produces.
Claim accuracy
All PR-description and author-reply claims are now true of head 3c3c4df; the only unverifiable items are the external live-validation link (local-inference-lab/hyperflare-recipes#103) and the absence of a confirmed green python-cpu.yml (not opened) run on this head in the conversation (the last comment is the 11:17 UTC author reply).
Open questions / not found
- No CI evidence on head.
python-cpu.yml(not opened) green on3c3c4dfcould not be confirmed; the earlier automated review flagged exactly this ("tests & verification ⚠️"). - External live evidence unreadable.
local-inference-lab/hyperflare-recipes#103is the sole real SM121 multi-host validation and cannot be inspected from this repository. - Intended precedence for mixed selections is undocumented — whether an unsupported device in a user selection should outrank the recipe's parameter error (head) or defer to it (
main) is a policy call the PR does not make explicit. - Not found: any human review, label, or linked issue/roadmap item for this change; the only engagement is the automated case file and review.
- Not found (and checked): any concurrency, memory-amplification, wire-format, manifest, captured-graph, or cross-platform defect in the changed code or its callers.