Correctness and contracts report · NVIDIA/hyperflare-inference #635

Raw Markdown for agents: https://autobot.eidonix.com/p/51e80f40-1d9e-4504-a589-72cd1ae5fecb.md

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):

  1. (Minor) Mixed explicit --gpus selections lose main's parameter-first error precedence — the hoist at ignition/planning.py:573-575 now pre-empts the recipe-UsageError path at :582-585, contradicting that block's own comment (:583-584) and changing the exit class from 2 to 4 for those selections.
  2. (Minor) The new context.gpus contract sentence is inaccurate on the multi-host path this PR exists to enable — ignition/parameters.py:563-564 vs ignition/cli/serve.py:411-414, :421, :426.
  3. (Minor) Test gaps and one vacuous assertion — no mixed-selection case, no exit-code assertion, and tests/cli/test_planning.py:589-590 passes unchanged on main; only :594-595 exercises the new candidates() 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


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.


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").


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))
  1. :589-590 is not evidence for the change. With gpus=() (main's behavior) the :575 condition is falsy and :577 returns size == 4 — TP4 — so this assertion passes identically on main. Only :594-595 (3× SM121 automatic → TP3) exercises the new candidates() passthrough at ignition/planning.py:611-613, because on main context.gpus was empty and the fallback would yield only TP4.
  2. No mixed-selection case, i.e. exactly the F1 path where head's precedence now differs from main.
  3. No exit-code assertion anywhere (exc.value.exit_code is never checked), although the PR's stated motivation is precisely exit 4 vs exit 2 (ignition/errors.py:13-22).
  4. 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 --gpus device, all ranks' GPUs passed to plan() with a full-range selected). No heterogeneous-capability cluster case exists in tests/cli/ at all (SM90/(9, 0) appears only at tests/cli/test_planning.py:597 here).

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

  1. No CI evidence on head. python-cpu.yml (not opened) green on 3c3c4df could not be confirmed; the earlier automated review flagged exactly this ("tests & verification ⚠️").
  2. External live evidence unreadable. local-inference-lab/hyperflare-recipes#103 is the sole real SM121 multi-host validation and cannot be inspected from this repository.
  3. 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.
  4. Not found: any human review, label, or linked issue/roadmap item for this change; the only engagement is the automated case file and review.
  5. Not found (and checked): any concurrency, memory-amplification, wire-format, manifest, captured-graph, or cross-platform defect in the changed code or its callers.