#1 [high] PR #635 Subtraction/Simplicity review findings
PR #635 (nero-), head c2ef797, files: ignition/planning.py (+9/-5), tests/cli/test_planning.py (+32/-0).
S1 (main): three spellings of one value, two of them conversions the PR itself added.
- ignition/planning.py:566
supported = [gpu for gpu in gpus if gpu.supported](list) - :573
filter_gpus = chosen if chosen is not None else tuple(supported)(tuple conversion #1) - :611-613
candidate_sizes = candidate_params.filter_world_sizes(world_sizes, replace(pre_context, root=candidate_params, gpus=tuple(supported)))(tuple conversion #2) Fix: make 566 a tuple generatorsupported = tuple(gpu for gpu in gpus if gpu.supported); then :574 usesgpus=filter_gpusand :612 reusesgpus=filter_gpus. Equivalence at 612 is guaranteed because candidates() returns early at 609-610 whenchosen is not None, so at 611filter_gpus == tuple(supported)and onlyrootdiffers. All other uses ofsupported(602 list-comp, 604 sorted/[:n], 614/646 len) work on a tuple. Removes two conversions and one duplicated expression; no behaviour change.
S2: new test re-implements the module's own fixtures. tests/cli/test_planning.py:577-588 hand-builds Checkpoint+Recipe+Gpu tuples although _recipe() (:118) and _gpu() (:154) already do exactly that, and every other test in the file uses them (20+ sites). Quote 577-588. Replacement: _recipe("toy", device_gib=..., ranks=(3, 4), parameters=CapabilityAwareParams(max_concurrency=4, prefill_chunk=512)) (ranks (3,4) exactly matches), tuple(_gpu(i) for i in range(4)), tuple(_gpu(i, capability=(12, 1)) for i in range(3)); drops ~10 lines and the odd free==total==140 GiB GPUs used nowhere else.
S3: reserve_bytes=0 at :591, :593, :595, :596 is a no-op — RecipeParameters.reserve_bytes default is 0 (ignition/parameters.py:1405 reserve_bytes: int = param(0, cli=False, ...)), and plan() only overrides it when the argument is not None (_normalize_parameters, planning.py:440-444). Delete the four kwargs (or keep them if the fixture sets reserve).
Optional (pre-existing, both call sites touched by the PR): params.filter_world_sizes is evaluated twice on the automatic path — :574 with root=params/gpus=filter_gpus and :611 with root=params (candidate_params defaults to params) /gpus=tuple(supported) — the second is identical work. Could pass plan_sizes into candidates() when candidate_params is params. Not introduced by this PR (main has the same double call at planning.py:566 and :609), so lower priority.
Not findings: no new flags/config knobs/manifest fields/dead code; the if chosen is not None: split at 578 is forced by moving the filter after GPU resolution; no new abstraction or wrapper added; in-repo filter_world_sizes overrides (tests/cli/test_planning.py:81, tests/cli/test_commands.py:55) need no change. Overall diff is lean.
#3 [high] Research summary
Subtraction/Simplicity lens complete for PR #635 (ignition/planning.py +9/−5, tests/cli/test_planning.py +32/−0). No new flags, knobs, wrappers, manifest fields or dead code are introduced — the diff brings the hook's context up to what fit() already passes — so the diff is broadly lean. Three concrete subtractions found, all cited with verbatim quotes in the scratchpad:
-
ignition/planning.py:566, 573, 611-613 — one value spelled three ways; the PR itself added two
tuple()conversions of the same list. Makesupporteda tuple at :566 and reuse the existingfilter_gpuslocal at :612 (gpus=filter_gpusinstead ofgpus=tuple(supported)); legal becausecandidates()returns at :609-610 wheneverchosen is not None, so at :611 onlyrootdiffers. Every other use ofsupported(:590, :602, :604, :614, :646) is tuple-compatible. -
tests/cli/test_planning.py:577-588 — the new test hand-builds a Checkpoint, a Recipe and two Gpu tuples that the module's own
_recipe()(:118) and_gpu()(:154) fixtures already build, used by every other test in the file._recipe("toy", ranks=(3, 4), parameters=CapabilityAwareParams(...))plus_gpu()tuples preserves all four assertions and drops ~10 lines, including the one-off 140 GiB free==total GPUs. -
tests/cli/test_planning.py:591, 593, 595, 596 —
reserve_bytes=0is a no-op:RecipeParameters.reserve_bytesdefaults to 0 (ignition/parameters.py:1405) and_normalize_parametersonly overrides it for a non-None argument (planning.py:440-444). Delete the four kwargs.
Two caveats recorded: do not collapse :573 into chosen or tuple(supported) (an empty selected yields a falsy chosen), and the pre-existing double filter_world_sizes evaluation (:574 then :611, unchanged in kind by this PR) is an observation only, not a suggestion.
#4 [high] #635 verbatim code blocks for the three suggestions
Verbatim blocks (PR head c2ef797) for the Subtraction/Simplicity report on PR #635. Combine with entries 1 and 2.
--- S1: ignition/planning.py:565-574 (the three spellings of supported) ---
world_sizes = recipe.checkpoint_tensor_parallel(checkpoint)
supported = [gpu for gpu in gpus if gpu.supported]
chosen = None
if selected is not None:
if 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)}")
chosen = tuple(gpus[index] for index in selected)
filter_gpus = chosen if chosen is not None else tuple(supported)
plan_sizes = params.filter_world_sizes(world_sizes, replace(pre_context, gpus=filter_gpus))
--- S1 continued: ignition/planning.py:611-614 (second tuple() of the same list) --- candidate_sizes = candidate_params.filter_world_sizes( world_sizes, replace(pre_context, root=candidate_params, gpus=tuple(supported)) ) return [automatic(size, candidate_params, flags=flags) for size in candidate_sizes if size <= len(supported)]
Replace with: line 566 → supported = tuple(gpu for gpu in gpus if gpu.supported); line 574 unchanged (gpus=filter_gpus); lines 611-613 → candidate_sizes = candidate_params.filter_world_sizes(world_sizes, replace(pre_context, root=candidate_params, gpus=filter_gpus)). Net: deletes tuple(supported) twice and the second copy of the "which GPUs" expression. Tuple-compatible other uses: :590 len(supported), :602 list-comp, :604 sorted(supported, ...)[:world_size], :614 and :646 len(supported).
Guard note: at :611 filter_gpus == tuple(supported) because candidates() returns at :609-610 first when chosen is not None.
--- S2: tests/cli/test_planning.py:577-588 (fixtures rebuilt instead of reused) --- ckpt = Checkpoint("toy", "lab/toy", "a" * 40, "ToyLM", stored_bytes=200 * GIB, device_bytes=200 * GIB, mapped_host_bytes=0) model = Recipe( name="toy", served_model_name="Toy", checkpoints=(ckpt,), context=8192, page_tokens=64, sampling_defaults=SamplingDefaults(temperature=1.0, top_p=1.0, top_k=-1), parameters=CapabilityAwareParams(max_concurrency=4, prefill_chunk=512), prepare=None, usage=None, ranks=MappingProxyType({s: RankCosts(100 * MIB, 2 * MIB, 4 * GIB) for s in (3, 4)}), ) sm120_gpus = tuple(planning.Gpu(i, "SM120", f"GPU-{i}", 140 * GIB, 140 * GIB, (12, 0)) for i in range(4)) sm121_gpus = tuple(planning.Gpu(i, "SM121", f"GPU-{i}", 140 * GIB, 140 * GIB, (12, 1)) for i in range(3))
Existing helpers in the same file:
- tests/cli/test_planning.py:118
def _recipe(name="fixture", *, device_gib=60, ranks=(1, 2, 4), parameters=None):— builds the Checkpoint and Recipe (page_tokens=64, ranks from RankCosts). - tests/cli/test_planning.py:154-156
def _gpu(index, free_gib=95, capability=(12, 0)):
return planning.Gpu(index, "NVIDIA RTX PRO 6000 Blackwell", f"GPU-{index:04d}",
96 * GIB, int(free_gib * GIB), capability)
Replacement (keeps all four assertions):
model = _recipe("toy", device_gib=60, ranks=(3, 4), parameters=CapabilityAwareParams(max_concurrency=4, prefill_chunk=512))
ckpt = model.checkpoints[0]
sm120_gpus = tuple(_gpu(i) for i in range(4))
sm121_gpus = tuple(_gpu(i, capability=(12, 1)) for i in range(3))
Precedent for capability-varying
_gpu: :219_gpu(0, 95, (10, 3)).
--- S3: tests/cli/test_planning.py:590-596 (no-op reserve_bytes=0) --- # Automatic planning on 4x SM120 selects TP4, not TP3. assert planning.plan(model, ckpt, sm120_gpus, reserve_bytes=0).world_size == 4 with pytest.raises(CapacityError, match="needs 4"): planning.plan(model, ckpt, sm120_gpus[:3], selected=(0, 1, 2), reserve_bytes=0) # Explicit and automatic planning on 3x SM121 allow TP3. assert planning.plan(model, ckpt, sm121_gpus, selected=(0, 1, 2), reserve_bytes=0).world_size == 3 assert planning.plan(model, ckpt, sm121_gpus, reserve_bytes=0).world_size == 3
Why no-op: ignition/parameters.py:1405 reserve_bytes: int = param(0, cli=False, value_type=int, scope=ParameterScope.DEPLOYMENT, in_dict=False) and ignition/planning.py:440-444 _normalize_parameters only replaces it if reserve_bytes is not None. No fixture in the file sets a non-zero reserve.
#2 [medium] Verification notes for #635 simplification suggestions
Verification of S2 (test fixture reuse): _recipe() (tests/cli/test_planning.py:118-151) builds Checkpoint(alias=f"{name}-alias", device_gibGIB, draft_bytes=0 if speculation is None) + Recipe(page_tokens=64, ranks=MappingProxyType({size: RankCosts(100MIB//size, 2MIB//size, 4GIB)}), plain_ranks={} when no speculation). The new test's own ranks mapping is {s: RankCosts(100*MIB, 2*MIB, 4*GIB) for s in (3,4)} (:585) — differs only in dividing by size; both are arbitrary per-rank costs, and the new test's assertions are memory-independent (capability decides the allowed sizes: 4-only for SM120, {3,4} for SM121). _recipe("toy", device_gib=60, ranks=(3,4), parameters=CapabilityAwareParams(...)) plus _gpu() tuples preserves all four assertions. Precedent for capability-varying _gpu: tests/cli/test_planning.py:219 _gpu(0, 95, (10, 3)).
_gpu() (:154-156) defaults to 96 GiB total / 95 GiB free, capability (12,0) — SM120 automatic TP4 and SM121 TP3 both fit comfortably, and the :592-593 CapacityError still says "needs 4" because CapabilityAwareParams only returns (4,) for non-SM121.
Caution: do NOT collapse S1 further into gpus=chosen or tuple(supported) — selected can be an empty tuple, making chosen == () falsy and silently falling back to supported. Keep the explicit chosen is not None test (currently :573).
Optional item (pre-existing, not introduced): filter_world_sizes now runs up to 3x on the failure path — :574, :611 (via attempt at :619), and again :611 via candidates(params, ...) at :626. On main it was 2x (:566, :609). Could pass plan_sizes into candidates() when candidate_params is params, but that adds a branch, so report as observation only.