PR #695: Share local tuning across TP ranks in tuning replicas and reconcile serving selections

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/7a4d0035-697e-4dd6-8f7b-ec1c9e28bef2

Opened by a workflow run, Dec 2, 2026 6:05 PM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: lukealonso (COLLABORATOR; charter-named priority contributor, dominant recent author of ignition/preparation — 13 merged PRs there in 180 days; Discord: lukealonso) Motivation: Exporting a tensor-parallel model with local tuning replicas (--tuning-gpus spanning several TP replicas) sharded tuning only across corresponding ranks, so all 8 ranks in each replica raced the same candidates, picked different winners by timing jitter, and then crashed when AOT forwards failed to bind the mismatched scratch_layout because post-tuning reconciliation was skipped for replicas. Scale: +526 / −15 lines in 3 files (tuning.py +27/−8, tuning_replicas.py +17/−7, new 482-line test file) Proposal:

Full report · Notes

Classify intake

Selected: bug, performance, area:preparation

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +bug, +performance, +area:preparation

Value Proposition

Value Proposition — PR #695 (Share local tuning across TP ranks in tuning replicas and reconcile serving selections)

Charter alignment — strong, with two gaps

The change is 44 production lines, entirely inside ignition/preparation/, with no CLI surface, no new flag, no per-model branch, and no Helios/runtime change. That is exactly the "smallest footprint in shared code" the charter asks for, and it respects the runtime/recipes split. The fix names a concrete root cause (shard width range(replicas), plus the skipped post-tuning reconcile_selections) rather than retrying around an unexplained BindingMismatch, satisfying the #397 rule. The four-part description convention (why / what changed / claimed result / evidence) is met, including an openly stated limitation.

Two frictions:

  1. No measurement for the "R-way → R*TP-way" sharding-scaling claim, which is the same objection (#210, "The benefit is not measured") that blocked the closest precedent, #383.
  2. The --tuning-gpus × TP parallel layout is changed while its docs are not: docs/cli-design.md:574-578 still says corresponding ranks share candidate results, and docs/model-preparation.md:203-209, 252-260 never mentions cross-replica winner sharing or the wider shard count — the charter's supported-matrix/docs check.

Novelty & status — genuinely additive

Value vs maintenance cost

Beneficiaries: operators running --tuning-gpus spanning ≥2 complete TP replicas with TP≥2 and autotune on; the documented TP1 example is untouched by the tensor_parallel > 1 guard. Evidence is scheduling-level only — fake jobs, scripted latencies, mocked sessions — the BindingMismatch is never exercised, and the author admits the TP=8 Ergo / 16-GPU repro "has not yet been re-run on this commit." Nobody besides the author has reported the --tuning-gpus variant, though the sibling multi-host bug (#631, #651, #668 confirmations) is well attested. Cost is modest: one boolean threaded through authorization, plus a 4-process Gloo test that adds mild CI load/flake surface. The author is a priority contributor and the dominant recent owner of this subsystem, so the charter's extra weight applies.

What's needed before merge

  1. Re-run the motivating GPU export and show the BindingMismatch is gone (the admitted missing evidence).
  2. Before/after numbers for the sharding-scaling claim.
  3. Update the two stale doc passages; note that the wider shard count invalidates partial tuning checkpoints (docs/model-preparation.md:224-229).
  4. State whether the fallback (share_across_ranks=False) path is intentionally left without cross-replica agree_selections, and correct the under-described reset-guard change (if self._sharded → if shard_ranks is not None).

Verdict: Worth it with changes.

Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.

Subtraction and simplicity

Subtraction/Simplicity review of PR #695. The production diff is lean (44 lines, no new flags or knobs), but four concrete simplifications exist, plus one lower-value duplication question and one item of dead code.

  1. Dead constructor keyword: share_across_ranks=False in ReplicaPreparation.__init__ (ignition/preparation/tuning_replicas.py:74, stored :78) is never passed in production — tuning.py:430 omits it and production assigns the attribute afterwards at tuning.py:443. The kwarg exists only for tests/preparation/test_tuning_replicas.py:150.
  2. Two duplicated error-message ternaries at tuning_replicas.py:42-46 and :50-54 can revert to the one-line pre-PR wording (the original string stays true in share mode, since peers = states at :34 is a superset of the corresponding ranks). Saves ~8 lines and removes the flag from both error paths. Keep the exact string matched at test_tuning_replicas.py:129.
  3. One sharding decision is stored four ways and branch-tested a fourth time at tuning.py:439-451; assigning self._replica_coordinator.share_across_ranks = self._sharded = share and computing the (shard_rank, shard_ranks) pair once removes 3-4 statements and leaves shard_ranks is not None (:525, :534) as the single "a shard was configured" predicate.
  4. ~130 lines of test duplication: test_tuning_replicas.py:159-225 writes the same 6-field SimpleNamespace seven times, and :366-395 re-hand-assigns ~28 session attributes already written in tests/preparation/test_tuning_shards.py:225-253 (plus a second _FakeCoordinator vs :179-211). Repo precedent for a shared helper exists (tests/preparation/payload_fixture.py).
  5. Lower value: _local_tuning_catalog (tuning.py:35-49) is a fourth dependency-graph traversal alongside tuning_shards.local_components (:29-53) and component_key (:56-58); a question, not a defect, because the strict byte-identical gate needs its collective-producing-request inclusion.

Checked clean: no speculative config knobs, only the one documented #383 fallback, replica-local collective slice (tuning_replicas.py:55-70) untouched, no dead code on touched paths. Doc staleness (docs/cli-design.md:574-578, docs/model-preparation.md:203-209, :252-260) belongs to the correctness/docs lens.

Open: whether the kwarg or the post-construction write should survive; whether self._sharded is still needed in the replica branch; whether _local_tuning_catalog should converge with component_key; where a shared session double should live, since tests/preparation/ has no conftest.py (not opened).

Full report · Notes

Correctness and contracts

Correctness/contracts review of PR #695 (tuning replicas: cross-rank tuning sharing + serving-replica reconciliation).

What I verified as sound: shard arithmetic replica*tp+rank matches the Gloo member index (tuning.py:446 vs tuning_replicas.py:81); replica-local collectives stay sliced to the TP group (tuning_replicas.py:55); TuningComplete barrier is symmetric per replica and replica groups are independent (tuning.py:637-643); shard_ranks is not None is equivalent to the old self._sharded in the multi-host branch (no behaviour change, no stale state); TP=1 and --autotune-effort off are untouched; --tuning-gpus + multi-host is still rejected twice.

Findings, highest first:

Open: whether the repro has a multi-rank coordinator; whether the missing fallback-path agreement is intended; whether a homogeneous run's selections from replicas>0 are ever cross-checked; commit trailers unverified.

Full report · Notes

Final review

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

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Update stale --tuning-gpus documentation (docs/cli-design.md:574-578, docs/model-preparation.md:203-209, 252-260)

    • docs/cli-design.md:574-576 currently states: "For TP2, --gpus 0,1 --tuning-gpus 0-5 creates 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 all replicas * tensor_parallel GPUs 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-204 still scopes cross-rank candidate sharing to "Without extra tuning replicas...", and --tuning-gpus LIST (:252-260) does not mention cross-rank sharing (R * TP shard width, which invalidates prior R-shard partial checkpoints per :224-227) or serving-replica reconciliation.
    • Fix: Update both passages to reflect global R * TP local-race sharing on homogeneous replicas, corresponding-rank fallback with serving-replica reconciliation when devices or catalogs differ, and the partial-checkpoint shard-count implication.
  2. Substantiate or qualify the end-to-end GPU fix and R -> R*TP scaling claim (docs/design-review.md Principles 12 & 16; Charter #210)

    • The new CPU tests (tests/preparation/test_tuning_replicas.py) stub b12x sessions/jobs/coordinators with scripted latencies and never exercise ForwardCache._prepare_ranks or real sharded races; the PR explicitly notes that multi-GPU ignition export --tuning-gpus has not yet been re-run on ccb9f5b, and no before/after tuning wall-clock numbers back the R-way → (R * TP)-way scaling claim (the same gap that held #383).
    • Fix: Re-run the motivating multi-GPU TP>1 ignition export --tuning-gpus on ccb9f5b and report that BindingMismatch no longer occurs alongside before/after tuning wall-clock time; or, if hardware access is unavailable before merge, clearly label the BindingMismatch resolution and scaling speedup as expected rather than measured results in the PR description (docs/design-review.md Principle 16) so a maintainer can explicitly sign off on CPU-only verification.

Subtract / Simplify

  1. Drop the production-unused share_across_ranks parameter on ReplicaPreparation.__init__ (ignition/preparation/tuning_replicas.py:74, 78; ignition/preparation/tuning.py:430, 443)

    • Production must construct ReplicaPreparation before calling gather() to inspect catalogs (tuning.py:430-433), so tuning.py:443 always mutates self._replica_coordinator.share_across_ranks after construction; the constructor kwarg is only passed by the Gloo test (tests/preparation/test_tuning_replicas.py:150).
    • Fix: Initialize self.share_across_ranks = False without an unused __init__ kwarg (or pass share_across_ranks into prepare(..., share_across_ranks=False)), and have the Gloo test follow the same production contract.
  2. 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 unified share_across_ranks=True wordings ("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 keeps share_across_ranks scoped solely to peer selection (:34).
  3. Trim mechanical repetition in tests/preparation/test_tuning_replicas.py:159-225, 282-396

    • _FakeJob.advance (:162-224) repeats the same 6-field SimpleNamespace literal 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-attribute object.__new__(RecordedPreparationSession) setup from tests/preparation/test_tuning_shards.py:179-253; extracting a shared helper prevents silent test drift when RecordedPreparationSession.__init__ gains attributes.

Nits

Dropped on verification

Full report

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

Applied: +triage:review