Subtraction, Simplicity & Conventions review — PR #635 ("Pass candidate GPUs into filter_world_sizes during planning")
Key findings
- The diff is already lean. No new CLI flag, config key, env var, wrapper, injection point, fallback, or compatibility shim. No logic duplicates an existing repo helper. No structural
AGENTS.mdviolation. Verified at head3c3c4df9(see "Negative findings" below). - Head has moved; the dossier's amendment A5 is superseded. Head is now
3c3c4df9("Pass candidate GPUs into filter_world_sizes during planning", newest commit). The author's claimed edits are all present:supportedis a tuple (ignition/planning.py:566), the architecture check is hoisted above the filter (:573-575),filter_gpusis threaded intocandidates()(:611-613), the docstring is extended (ignition/parameters.py:560-565), and the test reuses_recipe()/_gpu()with an SM90 case (tests/cli/test_planning.py:579-599). A5 must not be cited as an open item; the PR description in the task matches head. - S1 (high) —
filter_gpusis one value spelled at two call sites. Rebindingpre_contextonce removes a variable, duplicates thegpus=argument nowhere, and reverts the wholecandidates()hunk to its pre-PR one-liner: net −2 lines and one fewer touched call site. - S2 (medium) — the new test's
if any(not gpu.supported …): return ()guard is unreachable dead code. The test's own SM90 case asserts the branch is not taken. Deleting two lines changes nothing observable. Keep the SM90 assertion. - S3 (low, no action needed) — the hook contract landed in a docstring, not the docs hook list.
docs/preparation-development.md:32-36was not updated; only real nit is that the docstring documentscontext.world_size is None, a constant at every call site.
1. Subtraction
S1 (high) — collapse filter_gpus into pre_context; the candidates() hunk disappears
At head, ignition/planning.py:576-577:
filter_gpus = chosen if chosen is not None else supported
plan_sizes = params.filter_world_sizes(world_sizes, replace(pre_context, gpus=filter_gpus))
and ignition/planning.py:611-613:
candidate_sizes = candidate_params.filter_world_sizes(
world_sizes, replace(pre_context, root=candidate_params, gpus=filter_gpus)
)
The 3-line wrap at :611-613 exists only because this PR added the extra gpus= argument. Before the diff it was the single line (confirmed in pr_diff for ignition/planning.py):
candidate_sizes = candidate_params.filter_world_sizes(world_sizes, replace(pre_context, root=candidate_params))
Why the collapse is safe. params.validate(pre_context) at :563 is the only use of pre_context before the GPUs are resolved (deliberately kept gpus-free). After :566-575 the only remaining uses in the whole file are :577, :585 and :612 (search_code on pre_context over ignition/ returns exactly those five lines: 556, 563, 576, 577, 585, 612). The later relief_context at :634-642 is a fresh ParameterContext and is unaffected. chosen is None iff selected is None (:567-572), so the two-way choice is a straight rebinding.
Proposed. Replace :576-577 with:
pre_context = replace(pre_context, gpus=chosen if chosen is not None else supported)
plan_sizes = params.filter_world_sizes(world_sizes, pre_context)
and replace :611-613 with the pre-PR one-liner:
candidate_sizes = candidate_params.filter_world_sizes(world_sizes, replace(pre_context, root=candidate_params))
Result: filter_gpus deleted, gpus= not duplicated across two sites, the candidates() hunk leaves the diff entirely (the PR then touches one filter call site, not two), net −2 lines. Semantics identical.
Optional follow-ons (author's call, both cosmetic):
ignition/planning.py:585params.validate(replace(pre_context, gpus=chosen, world_size=len(chosen)))— after the rebindinggpus=chosenis redundant (this line sits insideif chosen is not None:at:581), so it can readreplace(pre_context, world_size=len(chosen)). Keeping it explicit is defensible.ignition/planning.py:567-575nests the bounds check and a 3-linefor/ifarchitecture loop insideif selected is not None:. Flatter guard-clause form, using the walrus already used in this file at:646((larger := automatic(size))):
chosen = None if selected is None else tuple(gpus[index] for index in selected)
if selected is not None and any(index >= len(gpus) for index in selected):
raise UsageError(f"--gpus {format_gpus(selected)} names a GPU this host does not have;"
f" it has {len(gpus)}")
if rejected := next((gpu for gpu in chosen or () if not gpu.supported), None):
raise CapacityError(f"GPU {rejected.index} ({rejected.name}) is not an {SUPPORTED_ARCHITECTURES} device")
This removes one nesting level and the 3-line loop. Optional — the current form is readable.
S2 (medium) — the new test's unsupported-GPU guard is dead code
tests/cli/test_planning.py:569-577:
@dataclass(frozen=True)
class CapabilityAwareParams(RecipeParameters):
def filter_world_sizes(self, world_sizes: tuple[int, ...], context: ParameterContext) -> tuple[int, ...]:
sizes = super().filter_world_sizes(world_sizes, context)
if any(not gpu.supported for gpu in context.gpus):
return ()
if context.gpus and all(gpu.capability == (12, 1) for gpu in context.gpus):
return tuple(size for size in sizes if size in (3, 4))
return tuple(size for size in sizes if size == 4)
The branch at :573-574 is unreachable through planning.plan, the only entry point the test drives:
- Automatic path:
filter_gpus = supported, which atignition/planning.py:566istuple(gpu for gpu in gpus if gpu.supported)— soany(not gpu.supported …)is always False. - Explicit path:
filter_gpus = chosen(:576), but the hoisted check atignition/planning.py:573-575raisesCapacityErrorbeforefilter_world_sizesat:577.
The test's SM90 case, tests/cli/test_planning.py:596-599:
# Explicitly selecting an unsupported GPU raises CapacityError before world-size filtering.
unsupported_gpus = tuple(_gpu(i, capability=(9, 0)) for i in range(4))
with pytest.raises(CapacityError, match="not an SM"):
planning.plan(model, ckpt, unsupported_gpus, selected=(0, 1, 2, 3))
asserts that the CapacityError at :575 fires — i.e. it asserts the guard is not taken. And the fall-through return tuple(size for size in sizes if size == 4) already yields () for a mixed/unsupported set, so removing the guard changes nothing observable.
Proposed: delete tests/cli/test_planning.py:573-574. Keep the SM90 assertion — it pins the PR's deliberate design decision (hardware CapacityError wins over a parameter UsageError); the value is in the assertion, not the guard.
Two tempting but wrong simplifications I rejected (recording so they are not re-raised):
- Extracting a shared fixture/helper is not warranted: the inline subclass follows existing precedent — the inline
BadContextGroup/BadContextParamspair attests/cli/test_planning.py:547-556. - Reusing the module-level
ToyShardingParameters(tests/cli/test_planning.py:62-115) is not viable: itsfilter_world_sizes(:81-85) ignorescontext.gpus, so it cannot express the behavior under test.
Nothing else to subtract (checked)
- No new flag/argparse field/config key/env var:
pr_filesshows the diff confined toignition/parameters.py(+5 −1),ignition/planning.py(+13 −9),tests/cli/test_planning.py(+35 −0). The PR description's "without changingRecipeParameterssignatures" holds —def filter_world_sizes(self, world_sizes, context)atignition/parameters.py:560is byte-identical tomain. - No dead code left behind by the move: the architecture check does not survive in its old position (
pr_diffshows thefor gpu in chosen:block deleted at the:582/:587hunk), so there is no duplicated check to clean up. - No wrapper, injection point, or speculative generality: the only new local is
filter_gpus, genuinely consumed twice (hence S1's dedupe, not a speculative knob).
2. Simplicity & Duplication
S1 above is the only duplication found. Beyond it:
- Existing helpers are reused, not re-rolled.
format_gpus(ignition/planning.py:164-168),_shortfall(:513),SUPPORTED_ARCHITECTURES(:38),SUPPORTED_CAPABILITIES(:37),Gpu.supported(:51-53), anddataclasses.replace.search_code \.supported\bshowsgpu.supportedused in production only atignition/planning.py:566and:574, so the PR is not adding a parallel capability test beside an existing one. - Two production
filter_world_sizescall sites, both inplan()(ignition/planning.py:577,:611) — no third path, no duplicate filtering. The only other implementations in the repo are test doubles (tests/cli/test_planning.py:81,tests/cli/test_commands.py:55), both of which ignorecontext.gpusand so remain source-compatible. - No convoluted implementation worth rewriting beyond the optional guard-clause form in S1.
3. Material repo conventions
AGENTS.md:188-193("Reject unsupported abstractions and churn"): satisfied — no framework, extension point, fallback layer, or config switch; edits are minimal and directly support the requested behavior. No unsolicited rename/reformat/annotation sweep; both suggestions above delete new lines rather than churn old ones.AGENTS.md:176-181(flags/callbacks/optional paths must not bypass boundaries): thefilter_world_sizeshook already existed and is the sanctioned place for recipe policy (docs/preparation-development.md:32-36). The PR keeps model-specific policy out ofignitioncore — no model branch is added — consistent with the charter's "no per-model special cases or flags".AGENTS.md:194-199(meaningful validation, not source-text checks): the new test drives realplanning.planwith syntheticGpudescriptors, so it exercises behavior. The residual gap (CPU-only, synthetic descriptors, single host, no multi-host--ranks/topology_gpu) is a validation-strength note for the correctness lens, not a convention violation.- S3 (low, no action required) — the hook contract went into a docstring while the docs hook list was left alone.
docs/preparation-development.md:32-36still says only:
- `planning.Plan` carries the resolved `parameters` instance directly and
invokes its `validate`, `filter_world_sizes`, `adjust_weights_bytes`, ...
The substantive contract is in ignition/parameters.py:560-565:
def filter_world_sizes(self, world_sizes: tuple[int, ...], context: ParameterContext) -> tuple[int, ...]:
"""Restrict candidate tensor-parallel world sizes during planning.
``context.gpus`` contains the explicitly selected GPUs (when ``--gpus`` is given)
or all supported host GPUs (during automatic planning), and ``context.world_size`` is ``None``.
"""
This is present-state, history-free prose and meets .agents/skills/repo-prose/SKILL.md:26-29 (not opened). The only substantive nit: world_size is None holds at every call site (:577, :611), so the world_size half of the sentence documents a constant a recipe cannot act on (the filter can narrow the set of sizes but cannot reason about a specific size — candidates() returns early at :609-610 for explicit --gpus, never calling the filter). At most add one clause there, or drop the world_size mention. Do not add a new document.
Negative findings — basis for the "already lean" verdict
Checked at head 3c3c4df9 and found nothing to flag: no new CLI flag, argparse field, config key, or env var; no new public API, wrapper, or injection point (the change is entirely inside the existing plan(), ignition/planning.py:543-651); no dead code left behind by the deletion side of the diff; no fallback branch, speculative generality, or compatibility shim; no duplicated helper; no docs-prose or structural AGENTS.md violation.
Open questions / not verifiable here
- Cannot run the test suite or confirm CI on the head (
python-cpu.yml(not opened) was never reported green per the dossier). S2's "unreachable" claim is proven by code reading ofignition/planning.py:566, 573-577, 609-613, not by coverage output. - The only live SM121 / multi-host evidence is
local-inference-lab/hyperflare-recipes#103(DeepSeek V4.1 TP3), named in the bot review; unreadable from this repository. Nothing in this lens depends on it. - Whether the author wants the S1 rebinding or prefers an explicit
filter_gpuslocal for readability is a style call; correctness is identical either way, so this is the one suggestion that could legitimately be declined.
Verdict for this lens: the diff is lean and idiomatic; only S1 and S2 are worth acting on, and both are deletions of lines this PR itself added.