Recommendation: Changes Requested
The 44-line production change in ignition/preparation/{tuning,tuning_replicas}.py is technically sound, deadlock-free, and cleanly scoped with zero blockers: shard-rank indexing matches the Gloo group layout, replica-local collectives remain isolated per replica, serving-replica reconciliation resets/restores shard state properly on both homogeneous and fallback paths, and non-serving replicas still exit cleanly via TuningComplete. However, two non-trivial pre-merge gaps remain: two documentation passages (docs/cli-design.md:574-578, docs/model-preparation.md:203-209, 252-260) now directly contradict the new default TP>1 --tuning-gpus behavior, and both headline claims (eliminating the 16-GPU TP=8 BindingMismatch and R -> R*TP scaling) lack end-to-end GPU confirmation or before/after measurements on ccb9f5b.
Merge Risk
Level: Low
- Narrow, preparation-only blast radius: Only 44 changed production lines across
ignition/preparation/tuning.pyandignition/preparation/tuning_replicas.py; zero Helios/runtime, Protobuf, model-core, CLI, or CUDA-kernel changes. Single-rank (tensor_parallel == 1),--autotune-effort off, and multi-host (--ranks, mutually exclusive with--tuning-gpus) paths are unaffected. - Verified coordination & failure-isolation invariants: Cross-rank
ready_cache/ready_tuningsynchronization matchesProcessGroupGloomember order (replica * tp + rank), replica-local collectives stay sliced to[replica * tp : (replica + 1) * tp]and still advance while another replica waits on a local race, and non-serving replicas (index > 0) skip reconciliation and exit cleanly via their own TP-grouptuning_completebarrier. - Minor operational side effect: On homogeneous TP>1
--tuning-gpusruns, tuning shard count widens fromRtoR * TP, which invalidates in-progress partial tuning checkpoints from priorR-way runs (docs/model-preparation.md:224-227); completed selection caches remain valid.
Walkthrough
ignition/preparation/tuning_replicas.py:32-70, 73-82, 123-125: Addsshare_across_ranks: bool = Falsetoauthorization()andReplicaPreparation. WhenTrue,ready_cacheandready_tuningsynchronize across allreplicas * tensor_parallelprocesses (peers = states) so_tuning_resultsselects one global winner across every rank, whileready_collectivesandready_collective_tuningremain scoped tostates[replica * tp : (replica + 1) * tp].ignition/preparation/tuning.py:421, 431-451, 465-466: Gathers(self.device.identity, _local_tuning_catalog(requests))across all replica processes (preserving the corresponding-rank geometry check). Whenself.autotune,tensor_parallel > 1, and all reports matchreports[0], setsshare_across_ranks = True,self._sharded = True, andconfigure_tuning_shard(index * tp + rank, range(processes)); otherwise falls back to corresponding-rank sharding(index, range(replicas)). Also tracksshard_ranksexplicitly across both replica and non-replica branches.ignition/preparation/tuning.py:521-535, 546-549: Replaces theself._replica_coordinator is Nonegate withself.tuning_replica is None or self.tuning_replica.index == 0so serving replica 0 runs post-tuningreconcile_selections(andagree_selectionswhenself._sharded), while non-serving replicas skip both and exit viaTuningComplete. Changes the replay shard reset/restore guard fromif self._shardedtoif shard_ranks is not Noneso fallback replica runs (_sharded == False,shard_ranks == range(replicas)) also reset to(0, (0,))duringself._coordinator.preparereplay.tests/preparation/test_tuning_replicas.py:1-483: Adds the first CPU test suite for tuning replicas—unit tests forauthorization()in both modes (including mixed local/collective progress and mismatched race keys), a 4-process (2 × TP2) GlooReplicaPreparation.prepare()test, and three mockedRecordedPreparationSession.tune()tests covering homogeneous cross-rank sharding, unequal-catalog fallback with serving-replica reconciliation, and non-serving replicaTuningCompleteexit.
Pre-merge Checks
- [PASS] Security / malicious screen: No credential exposure, shell execution, or untrusted input paths; the
picklepayload uses the existing localTemporaryDirectoryGlooFileStorebetween parent and spawned local replica workers (tuning_replicas.py:84-96, 186-201). - [WARN] Charter & value fit: Clean root-cause fix in the right layer with minimal footprint and no flags or per-model branches, with
Discord: lukealonsoand a four-part PR description; however, the--tuning-gpus× TP docs are now stale (charter supported-matrix/docs check) and the sharding-scaling claim lacks measurements (charter #210,docs/design-review.mdPrinciple 12). - [PASS] Related / duplicate / conflict check: Cleanly complements merged #647 and open multi-host counterpart #668 (
--tuning-gpusand--ranksare mutually exclusive attuning_replicas.py:181-182andtuning.py:426-427), and is line-disjoint from open #678 (tuning_replicas.py:32-125vs:142-194). Nomaincommits since branch point touch these files. - [WARN] Tests & verification evidence: CPU CI is green on
ccb9f5band the new CPU tests verify scheduling and Gloo coordination cleanly, but the motivating multi-GPU TP=8--tuning-gpusexport has not been re-run onccb9f5band no before/after tuning timing or liveForwardCache._prepare_ranksrun is reported.
Blockers
None.
Should Fix
-
Update stale
--tuning-gpusdocumentation (docs/cli-design.md:574-578,docs/model-preparation.md:203-209, 252-260)docs/cli-design.md:574-576currently states: "For TP2,--gpus 0,1 --tuning-gpus 0-5creates three independent TP2 groups. Corresponding ranks share candidate results while collectives stay within each replica." After this PR, homogeneous TP>1 replicas share local candidate results across allreplicas * tensor_parallelGPUs and adopt one global winner; corresponding-rank sharing is now only the fallback when GPUs or local catalogs differ across TP ranks.docs/model-preparation.md:203-204still scopes cross-rank candidate sharing to "Without extra tuning replicas...", and--tuning-gpus LIST(:252-260) does not mention cross-rank sharing (R * TPshard width, which invalidates priorR-shard partial checkpoints per:224-227) or serving-replica reconciliation.- Fix: Update both passages to reflect global
R * TPlocal-race sharing on homogeneous replicas, corresponding-rank fallback with serving-replica reconciliation when devices or catalogs differ, and the partial-checkpoint shard-count implication.
-
Substantiate or qualify the end-to-end GPU fix and
R -> R*TPscaling claim (docs/design-review.mdPrinciples 12 & 16; Charter #210)- The new CPU tests (
tests/preparation/test_tuning_replicas.py) stubb12xsessions/jobs/coordinators with scripted latencies and never exerciseForwardCache._prepare_ranksor real sharded races; the PR explicitly notes that multi-GPUignition export --tuning-gpushas not yet been re-run onccb9f5b, and no before/after tuning wall-clock numbers back theR-way →(R * TP)-way scaling claim (the same gap that held #383). - Fix: Re-run the motivating multi-GPU TP>1
ignition export --tuning-gpusonccb9f5band report thatBindingMismatchno longer occurs alongside before/after tuning wall-clock time; or, if hardware access is unavailable before merge, clearly label theBindingMismatchresolution and scaling speedup as expected rather than measured results in the PR description (docs/design-review.mdPrinciple 16) so a maintainer can explicitly sign off on CPU-only verification.
- The new CPU tests (
Subtract / Simplify
-
Drop the production-unused
share_across_ranksparameter onReplicaPreparation.__init__(ignition/preparation/tuning_replicas.py:74, 78;ignition/preparation/tuning.py:430, 443)- Production must construct
ReplicaPreparationbefore callinggather()to inspect catalogs (tuning.py:430-433), sotuning.py:443always mutatesself._replica_coordinator.share_across_ranksafter construction; the constructor kwarg is only passed by the Gloo test (tests/preparation/test_tuning_replicas.py:150). - Fix: Initialize
self.share_across_ranks = Falsewithout an unused__init__kwarg (or passshare_across_ranksintoprepare(..., share_across_ranks=False)), and have the Gloo test follow the same production contract.
- Production must construct
-
Remove the two mode-conditioned error-message ternaries in
authorization()(ignition/preparation/tuning_replicas.py:42-46, 50-54)- Both 5-line ternaries branch only on prose between
"tuning ranks ..."/"corresponding tuning ranks ..."and"a tuning rank finished before its peers"/"a tuning replica finished before its corresponding rank". The unifiedshare_across_ranks=Truewordings ("tuning ranks declared different candidate races"and"a tuning rank finished before its peers") are accurate in both modes (whereas the pre-PR"corresponding rank"wording would be misleading in cross-rank mode). Removing both ternaries saves 8 lines and keepsshare_across_ranksscoped solely to peer selection (:34).
- Both 5-line ternaries branch only on prose between
-
Trim mechanical repetition in
tests/preparation/test_tuning_replicas.py:159-225, 282-396_FakeJob.advance(:162-224) repeats the same 6-fieldSimpleNamespaceliteral 7 times; a 2-line_step(...)helper cuts ~40 lines and makes the scripted state transitions immediately readable._make_replica_session/_FakeCoordinator(:282-396) duplicates the ~28-attributeobject.__new__(RecordedPreparationSession)setup fromtests/preparation/test_tuning_shards.py:179-253; extracting a shared helper prevents silent test drift whenRecordedPreparationSession.__init__gains attributes.
Nits
- Reap spawned Gloo workers on failure (
tests/preparation/test_tuning_replicas.py:254-259): Wrap thejoin(timeout=30)and assertions in atry/finallythat terminates/kills/joins any still-alive child process (matchingignition/preparation/tuning_replicas.py:209-216) so a deadlocked worker does not leak live Gloo sockets into the rest of the pytest session. - Gather catalog digest instead of full pickled catalog (
ignition/preparation/tuning.py:431-433, 441):reports[i][1]is only ever compared for equality (item == reports[0]). Hashing_local_tuning_catalog(requests)(e.g. SHA-256 digest) avoids transiently materializingprocesses × catalog_bytesinReplicaPreparation.gather()(tuning_replicas.py:87-96) on large catalogs.
Dropped on verification
- Correctness F1a ("asymmetric fallback path has no cross-replica agreement, contradicting PR claim; warm retries can still diverge"): Dropped—verified false. On the fallback path (
share_across_ranks=False), corresponding ranks across replicas still synchronize viastates[rank::tensor_parallel](tuning_replicas.py:34), non-serving replicas (index > 0) exit immediately viaTuningCompletewithout compiling or loading forwards (tuning.py:637-643,tuning_replicas.py:169-174), serving replica 0 runsreconcile_selectionsacross its TP group on every run including warm retries (tuning.py:521-535), skippingagree_selectionswhen_sharded is False and not spans_hostsmatches existing single-host non-replica behavior (tuning.py:456, 548), and the PR description accurately scopes the agreement check to homogeneous catalogs andreconcile_selectionsto asymmetric catalogs/warm retries. - Correctness F1b ("reconciliation depends on non-None multi-rank
_coordinator; needs confirmation on 16-GPU repro"): Dropped—verified false viaignition/preparation/rank_group.py:278-363andtuning.py:428-429._coordinatorisNoneonly whenTP == 1(single serving rank, nothing to reconcile); everyTP > 1serving replica spawns arank_groupwith aCollectivePreparationwhoselen(ranks) == TP > 1. - Correctness F1c suggested fixes ("construct
ReplicaPreparationafter catalog comparison; raise inauthorization()on mode disagreement"): Dropped—constructingReplicaPreparationafter the comparison is impossible becauseReplicaPreparation.gather()(tuning.py:431) performs the catalog comparison, and every process derivesshare_across_ranksdeterministically from the identical allgatheredreportslist (tuning.py:441), so processes cannot disagree on the mode. (The narrower unused-kwarg API cleanup is retained underSubtract / Simplify#1.) - Correctness F2a ("wider
R*TPrendezvous creates head-of-line coupling"): Dropped—this is the inherent, intended synchronization required for globalR * TP-way candidate sharding and winner selection, identical to existingTP-way sharding without replicas. - Correctness F4b ("PR description omits
if self._sharded→if shard_ranks is not Nonepredicate change"): Dropped—low-signal; the PR description accurately summarizes the temporary(0, (0,))reset/restore around reconciliation replay, and widening the guard toshard_ranks is not Noneis the exact implementation needed to make that reset/restore work on the fallback replica path as well. - Subtraction 2's proposed replacement string (
"a tuning replica finished before its corresponding rank"): Corrected—that pre-PR string would be misleading when two ranks inside the same replica disagree undershare_across_ranks=True; replaced inSubtract / Simplify#2 with the accurate unified strings. - Subtraction 3 ("collapse
share_across_ranks/self._sharded/shard_rank/shard_ranksinto chained assignment intuning.py:438-451"): Dropped—low-signal style preference; the existing 13-line block is clearer than a chained attribute assignment. - Subtraction 5 ("unify
_local_tuning_catalogwithtuning_shards.local_components/component_key"): Dropped—_local_tuning_catalog(tuning.py:35-49) is pre-existing untouched code with intentionally different semantics (it retains collective producers of local dependencies and theircollective.ranks, whereaslocal_componentsexcludes any component touching a collective).