#1 [high] Research summary
Subtraction/Simplicity review of PR #695 (files read: ignition/preparation/tuning.py, tuning_replicas.py, tests/preparation/test_tuning_replicas.py, plus tuning_shards.py, collectives.py, tests/preparation/test_tuning_shards.py, AGENTS.md, docs/cli-design.md, docs/model-preparation.md).
The production diff is small (44 lines) and mostly idiomatic; the real subtraction value is in four places:
- Duplicated error-message ternaries in
authorization()— tuning_replicas.py:42-46 and :50-54 inflate two messages into six lines each branch pair, for a distinction that is cosmetic (corresponding ranks are a subset of all ranks, so the same wording is true in both modes). Collapse to the two existing one-lineraise RuntimeError(...)statements; saves ~8 lines. share_across_ranksconstructor keyword is dead in production — tuning_replicas.py:74/78 adds a kwarg that the only production call site (tuning.py:430) never passes; the PR instead assigns the attribute after construction (tuning.py:443), and the kwarg is used only by the new test (test_tuning_replicas.py:150). Either pass it (impossible without restructuring, since the value is computed from the gather) or delete it:share_across_ranks = Falseas a class attribute plusself.share_across_ranks = share_across_ranksremoved.- One decision encoded in four variables — tuning.py:443-450/446/447 mirror the single boolean into
self._replica_coordinator.share_across_ranks,self._sharded,shard_rankandshard_ranks. Those six statements collapse to ~4 by deriving the shard pair from the one local boolean, which also makes theshard_ranks is not Noneguard at :525/:534 read directly as "a shard was configured" rather than as a second, independently assigned piece of state alongside_sharded. - Test-side duplication — the new test repeats the same 11-line
SimpleNamespace(...)advance payload five times inside_FakeJob(test_tuning_replicas.py:159-225, ~96 lines for a 4-step script; a small_advance(...)helper would roughly halve it), and_make_replica_session(:268-396) re-hand-assigns ~28object.__new__attributes, near line-for-line the block already in tests/preparation/test_tuning_shards.py:225-253, with a duplicated_FakeCoordinator(:282-317 vs :179-211). Extracting a shared session fixture (precedent: tests/preparation/payload_fixture.py) removes ~40 duplicated lines and, more importantly, stops the two copies drifting whenRecordedPreparationSession.__init__gains an attribute.
Lower value, flagged for the author: the new _local_tuning_catalog (tuning.py:35-49) adds a fourth dialect of "what this rank declares" beside tuning_shards.component_key (:56-58), local_components (:29-53) and the collective coordinator's describe() (tuning.py:232-235); its dependency walk is a subset of local_components and only its treatment of collective producers differs. Worth asking whether that difference can be a parameter rather than a new traversal.
No AGENTS.md structural violations found beyond the dossier's existing doc-staleness note; no speculative config knobs, no fallback layers beyond the one documented asymmetric-catalog branch, no dead code left behind in the touched paths.
#2 [high] PR #695 Subtraction/Simplicity findings (final)
PR #695, subtraction/simplicity lens. Files read: ignition/preparation/tuning.py, ignition/preparation/tuning_replicas.py, tests/preparation/test_tuning_replicas.py, ignition/preparation/tuning_shards.py, ignition/preparation/collectives.py, tests/preparation/test_tuning_shards.py, AGENTS.md, docs/cli-design.md:565-585, docs/model-preparation.md:195-265.
Verdict: production diff is lean (44 lines) and idiomatic; four real subtraction items, one lower-value.
- DUPLICATED ERROR-MESSAGE TERNARIES — ignition/preparation/tuning_replicas.py:42-46 and :50-54. Verbatim (:42-46):
raise RuntimeError(
"tuning ranks declared different candidate races"
if share_across_ranks
else "corresponding tuning ranks declared different candidate races"
)
Verbatim (:50-54):
raise RuntimeError(
"a tuning rank finished before its peers"
if share_across_ranks
else "a tuning replica finished before its corresponding rank"
)
Fix: replace each with the single-line pre-PR form: raise RuntimeError("corresponding tuning ranks declared different candidate races") and raise RuntimeError("a tuning replica finished before its corresponding rank"). Rationale: in share mode the peer set is a superset of the corresponding ranks, so the original wording remains literally true; the distinction is cosmetic prose, not behaviour. Saves ~8 lines and removes the only reason share_across_ranks appears in the error paths. (Note: test at tests/preparation/test_tuning_replicas.py:129 matches "tuning ranks declared different candidate races", so keep that exact string.)
- DEAD CONSTRUCTOR KEYWORD — tuning_replicas.py:74 and :78. Verbatim (:74, :78):
def __init__(self, role, rank, *, ranks, share_across_ranks=False):
...
self.share_across_ranks = share_across_ranks
Only production call site is ignition/preparation/tuning.py:430 ReplicaPreparation(self.tuning_replica, rank, ranks=ranks) — never passes it; the PR instead assigns the attribute after construction at tuning.py:443 (self._replica_coordinator.share_across_ranks = share_across_ranks). The kwarg exists only for the new test (tests/preparation/test_tuning_replicas.py:150). Fix: drop the kwarg; keep either a class attribute default (share_across_ranks = False) or leave the post-construction assignment, and let the test set the attribute. Alternatively pass it through, but that requires restructuring because the value derives from the gather.
- ONE DECISION SPLIT ACROSS FOUR VARIABLES — ignition/preparation/tuning.py:439-451. Verbatim:
share_across_ranks = (
self.tuning_replica.tensor_parallel > 1
and all(item == reports[0] for item in reports[1:])
)
self._replica_coordinator.share_across_ranks = share_across_ranks
if share_across_ranks:
self._sharded = True
shard_rank = self.tuning_replica.index * self.tuning_replica.tensor_parallel + rank
shard_ranks = tuple(range(self.tuning_replica.processes))
else:
shard_rank = self.tuning_replica.index
shard_ranks = tuple(range(self.tuning_replica.replicas))
self.configure_tuning_shard(shard_rank, shard_ranks)
Fix: set the attribute once and derive the pair, e.g.
share = tp > 1 and all(...); self._replica_coordinator.share_across_ranks = self._sharded = share; shard_rank, shard_ranks = ((index*tp + rank, tuple(range(processes))) if share else (index, tuple(range(replicas)))); then one configure_tuning_shard. Removes 3-4 statements and makes the later shard_ranks is not None guard (tuning.py:525, :534) the single "was a shard configured" predicate instead of sitting beside a separately-assigned self._sharded (init :129, read at :224, :463, :548).
-
TEST DUPLICATION (largest single saving, ~130 lines) — tests/preparation/test_tuning_replicas.py. (a) :159-225
_FakeJob.advancerepeats the same 11-lineSimpleNamespace(done=..., ready_collectives=..., ready_cache=..., ready_tuning=..., ready_collective_tuning=...)payload five times, with ~96 lines to script four steps. Fix: one localdef _advance(done=False, cache=None, tuning=(), collectives=(), collective_tuning=None)returning the namespace, then each step is 1-3 lines. (b)_make_replica_session:268-396 hand-assigns ~28 attributes onobject.__new__(RecordedPreparationSession)(:366-395) and defines_FakeCoordinator(:282-317) — near line-for-line the existing block in tests/preparation/test_tuning_shards.py:225-253 and its_FakeCoordinator(:179-211). Fix: extract a shared session-fixture helper (repo precedent for a shared test helper module: tests/preparation/payload_fixture.py) parameterised by tuning_replica/shared reports; removes ~40 duplicated lines and prevents the two copies drifting asRecordedPreparationSession.__init__gains attributes. -
LOWER VALUE — FOURTH "WHAT THIS RANK DECLARES" DIALECT. New
_local_tuning_catalog(ignition/preparation/tuning.py:35-49) picks(r.name, portable_declaration(r.plan), r.dependencies, collective ranks); tuning_shards.py already offerscomponent_key(:56-58) andlocal_components(:29-53, same union-find over dependencies + declaration aliases), and the session hasdescribe()for the collective coordinator (tuning.py:232-235)._local_tuning_catalog's dependency walk is a strict subset oflocal_components; only its exclusion of collective-produced requests differs. Worth asking the author whether that difference can be a parameter of the existing helper instead of a new traversal (note: the byte-identical gate needs the strict form, so this is a question, not a defect).
Checked and found clean: no speculative config knobs or env switches (AGENTS.md "Configuration"); no fallback layers beyond the single documented asymmetric-catalog branch; the replica-local collective slice (tuning_replicas.py:55-70) is unchanged by the PR; no dead code left on the touched paths; AGENTS.md structure/doc-naming conventions otherwise respected (doc staleness is the other lens's finding: docs/cli-design.md:574-578, docs/model-preparation.md:203-209 and :252-260).