Case file: PR #695 — Share local tuning across TP ranks in tuning replicas and reconcile serving selections
Pull request: https://github.com/NVIDIA/hyperflare-inference/pull/695 · author lukealonso (COLLABORATOR) · open, ready for review, opened and last updated 2026-12-02 · head ccb9f5b, branched from cc0a49d · base main · 3 files, +526 / −15 (diff confirmed via pr_files: tuning.py +27/−8, tuning_replicas.py +17/−7, new test file +482). Labels: none. Reviews: none. CI on head: passed.
Key findings
- No documentation was updated, and two docs now describe the pre-PR behaviour.
docs/cli-design.md:574-578still says "Corresponding ranks share candidate results while collectives stay within each replica", anddocs/model-preparation.md:203-209says TP ranks divide candidates "Without extra tuning replicas", with the--tuning-gpussection (:252-260) never mentioning cross-replica winner sharing or the wider shard count. This is the clearest friction with charter line 42 ("Check interactions across every supported … parallel layout … and docs"). - The performance claim has no measurement, and the reported repro was not re-run. "Scales local candidate sharding from R-way to R*TP-way" (§Claimed benefit) has no before/after numbers, and the description itself admits "Multi-GPU end-to-end
ignition export --tuning-gpushas not yet been re-run on this commit" — i.e. the exact TP=8 Ergo / 16-GPUBindingMismatchscenario that motivates the PR is unverified after the fix. The precedent is #383, where the same area was held with "The benefit is not measured". - The change removes a gate that was deliberately added two days earlier by the same author.
#647(merged 2026-11-30) introduced theself._replica_coordinator is Noneguard on post-tuningreconcile_selections, and #695 replaces it withtuning_replica.index == 0(ignition/preparation/tuning.py:521-522). #647 also fixedForwardCache._prepare_ranks, the exact function named in the failure. #695 is the local-replica counterpart of that multi-host fix, not a new problem. - The description understates one edit that reaches existing code. It says the reconcile replay does a "temporary reset/restore of
configure_tuning_shard(0,(0,))"; in fact the guard changed fromif self._shardedtoif shard_ranks is not None(tuning.py:525, 534), andshard_ranksis now also assigned in the pre-existing multi-host branch (tuning.py:464-466). Behaviour of that branch is unchanged in effect, but the reset condition is no longer the same predicate. - The homogeneous gate is all-or-nothing, so asymmetric catalogs get no scaling benefit at all.
share_across_ranksrequires the entire pickled(DeviceIdentity, _local_tuning_catalog(requests))tuple to be byte-identical across every replica process (tuning.py:431-441). On the asymmetric case (the rank-0-only-encoder situation #383 was written for) only the reconcile half applies; and becauseagree_selectionsis still gated onself._sharded or spans_hosts(tuning.py:546-549) and_shardedstays False, the fallback path has no cross-replica agreement check — only per-TP-group reconciliation. - Shard width changes, which invalidates partial tuning checkpoints. The shard count goes from
range(replicas)torange(replicas*tp)(tuning.py:446-450), anddocs/model-preparation.md:224-229requires the same tuning shard count to resume partial checkpoints. Completed selection caches survive; per-race partials from an R-way run will re-measure once. Undocumented operator cost. - Zero engagement, and no Autobot intake.
pr_commentsreturns "No comments."; no reviews, no labels, and none of the numeric Autobot case-file/review comments that every sibling PR that week received (#647, #668, #678). All comments on this PR are authored by nobody — the description is the only discussion. - The 482-line test file is the first in-tree CPU coverage of the tuning-replica path.
main'stests/preparation/has notest_tuning_replicas.pyat all (despiterelated_itemscrediting #433 with touching it), andsearch_codeon main finds onlytest_tuning_shards.py:229(not opened) mentioning a tuning replica.
The change, in plain terms
RecordedPreparationSession.tune() in ignition/preparation/tuning.py:409-643:
- Gather more, decide later. Instead of gathering only
self.device.identity, replicas now gather(self.device.identity, _local_tuning_catalog(requests))over the replica Gloo group (tuning.py:431-433;_local_tuning_catalogat tuning.py:35-49 picklesportable_declaration(plan)per request; transport attuning_replicas.py:84-96). - New sharding rule (tuning.py:438-451). If
tensor_parallel > 1and every replica's whole report equals replica 0's, setshare_across_ranks = True, markself._sharded = True, and shard as(replica*tp + rank, range(replicas*tp))— all processes. Otherwise keep the old(replica.index, range(replicas)). - Reconcile now runs on serving replica 0 (tuning.py:521-535): previously skipped whenever
_replica_coordinatorwas set; now gated onlen(coordinator.ranks) > 1andtuning_replica is None or index == 0. - Agreement too (tuning.py:546-549):
agree_selectionslikewise un-gated from "not a tuning replica" to "serving replica 0" (and still_sharded or spans_hosts). - Non-serving replicas still exit via
barrier("tuning_complete", coordinator.ranks)→close()→raise TuningComplete()(tuning.py:636-643), consumed atignition/preparation/rank_group.py:144-150.
ignition/preparation/tuning_replicas.py:
authorization(..., share_across_ranks=False)(tuning_replicas.py:32-70): peers for the local cache exchange and candidate race exchange becomestates(allreplicas*tpprocesses) instead ofstates[rank::tensor_parallel](:34). The_tuning_resultsreduction (:47) then yields one global winner via min by(latency_us, candidate_index)(ignition/preparation/collectives.py:182-193).- Replica-local collectives are unchanged, still sliced to the replica's TP group (
states[replica*tp:(replica+1)*tp], tuning_replicas.py:55-70) — this is the claim a reviewer can check fastest. - Error strings get a second wording per mode (:41-54), and
ReplicaPreparation.__init__acceptsshare_across_ranks(:74, stored at :78) and forwards it toauthorization(:123-125).
Not declared in the description: share_across_ranks is set by attribute assignment after construction (self._replica_coordinator.share_across_ranks = ..., tuning.py:443) rather than through the new constructor keyword — the kwarg exists only for the new Gloo test. Also declared imprecisely: the reset/restore guard change (see Key finding 4).
Declared but wider than stated: the description's "when tensor_parallel > 1 and all processes share identical device identities and local tuning catalogs" is accurate but under-describes the strictness — the comparison is over the entire catalog and a strict DeviceIdentity tuple, so a single differing request (or a Max-Q/Workstation name difference, cf. #150) disables the whole path.
The why
The PR reports (its own description, no issue number, no Fixes #) a TP=8 Amazon-FMR/Ergo export with --gpus 0-7 --tuning-gpus 0-15 — 2 TP=8 replicas on 16 RTX PRO 6000 Blackwell GPUs — in which:
- All 8 ranks inside each replica raced the same candidate half (2-way sharding across 16 GPUs instead of 16-way), and per-rank timing jitter produced different
attention.gqachampions with differentscratch_layoutsizes across ranks 0–7; - Because reconciliation was skipped for tuning replicas, ranks 1–7 then failed AOT forward loading (
ForwardCache._prepare_ranks) withBindingMismatchondecoder.layers[0|3].attention.attention.scratch_layout, after autotuning and compilation had completed.
No user or issue reports the --tuning-gpus variant. The multi-host variant of the same symptom family is well attested: closed #631 (reporter pfn, exact counts 2042/2078/2078 differing selections over three attempts) and still-open #651 ("Multi-host default autotune still fails kernel agreement"), plus independent hardware confirmations from two users (nepenth, Reederey87) on the multi-host fix #668. How long the local-replica variant has existed: since the local-replica sharding was introduced; it was not masked by a workaround, it was masked by the _replica_coordinator is None gate added in #647 two days before.
Related work
- #647 (merged 2026-11-30, lukealonso) — the direct ancestor. It introduced the reconcile gate #695 removes and the singleton-shard replay (
configure_tuning_shard(0,(0,))plusfinallyrestore) that #695 reuses, and it fixedForwardCache._prepare_ranks, the function in #695'sBindingMismatch. Not undone: #695 touches only the local-replica branch. - #668 (open, same author) — the multi-host counterpart of the same repair (reconciles by request name; closes #651). The two PRs split one problem by deployment mode; they do not compete.
--tuning-gpusis rejected together with--ranks(ignition/cli/serve.py:142-143(not opened),:375-376;tuning_replicas.py:181-182;tuning.py:426-427), so the paths cannot interleave. - #678 (open, brandonmmusic-max) — the only other open PR on
ignition/preparation/tuning_replicas.py. Its own Autobot review states the edits are line-disjoint: #695 changesauthorization()/ReplicaPreparation(32-125), #678 changes_replica/prepare_recipe(142-194). Both can land; no textual conflict. - #383 (merged, voipmonitor, "Distribute matching local tuning races across unequal TP catalogs") — closest precedent in intent, opposite granularity: #383 partitions within a job into matched/unmatched batches, whereas #695 demands a globally identical catalog and otherwise falls back wholesale.
- #150 (open, brandonmmusic-max) — loosens device-name identity for tuning (Max-Q/Workstation Edition). Conceptually adjacent because #695's gate compares strict identity; not overlapping code.
- #546 (merged, lukealonso, TP16 collectives + deadlock checks) — the risk surface: #695 changes when
agree_selections,reconcile_selectionsand thetuning_completebarrier are entered per replica, so collective-entry symmetry across replicas matters. An Autobot review of #546 noted a 16-GPU core export cannot demonstrate collective behaviour. - #543 (merged, lukealonso, "Remove joint kernel tuning…") is the upstream removal that left per-mode coordination; #695 does not re-add joint tuning.
- #597 (open, ForwardCache keyed by GPU name) is adjacent to the symptom location (
aot.py(not opened)) but different code; #433 (merged) is credited by tooling with touching the same test file, but that file does not exist onmain. - Judged not relevant: #682 (docs, logind RemoveIPC), #671 (memory budgets), #558 (collective tuning headers during progress polling — the local branch #695 leaves alone), #406, #231, #164, #132, #122, #33, #675.
Recent activity
Git history for the touched files is unreadable at this vantage point (search_history fails with Could not read c513e46… / cannot simplify commit ef38cb93…), so this is reconstructed from PR metadata:
- The orientation packet reports no commits on
mainsincecc0a49dtouching these files — no rebase pressure and nothing pre-empted. - Newest merged work in
ignition/preparation/tuning*.pywithin 180 days is essentially one author's chain: #543 (remove joint tuning) → #647 (multi-host share + reconcile + ForwardCache paths, 2026-11-30) → #668 (multi-host reconcile, open) → #695 (local replicas). Older contributors: voipmonitor (#383, #110, #88), nero- (#433), brandonmmusic-max (#150, #678), original-el8 (#231). - #695 builds on #647's mechanism directly and reverses nothing.
People
- lukealonso is one of three priority contributors named in the charter ("carry extra weight—we never close their PRs out of hand"). 40 merged / 0 closed / 3 open in 180 days; merged areas include helios/src (28), docs (23), ignition/preparation (13), flare-cli/src (10), tests/preparation (9) — the dominant recent author of exactly this subsystem, and the 4th preparation-tuning PR in about a week.
- Other people in the area: voipmonitor, nero-, brandonmmusic-max, original-el8. Review labour sits with yatesdr (two CHANGES_REQUESTED on #383, including the "benefit is not measured" objection) and flare-autobot (intake + review on #647, #668, #678).
- #695 has drawn no engagement at all: no reviewer, no maintainer, no Autobot case file — unusual for this author and area, where intake normally lands within ~90 minutes.
- The PR does give "Discord: lukealonso", satisfying the contact-line convention #383's review enforced.
Community
No comments, no reviews, no reactions, no labels on #695. Interest in the problem lives on the multi-host sibling: #668 has four discussion entries including two independent hardware confirmations (nepenth, Reederey87 on 2× GB10), and #631 was reported with concrete counts by pfn. Nobody besides the author has reported the --tuning-gpus BindingMismatch.
Project fit (charter, roadmap, docs)
Lines up:
- "Solve the right problem in the right place / smallest footprint in shared code" — 44 production lines, all in
ignition/preparation/, no flag, no CLI surface, no per-model branch; no runtime/Helios change ("keep the runtime small and model-agnostic"). - "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)" — the root cause is named exactly (shard width and skipped reconcile), not retried around.
- "PR descriptions: four parts (why, what changed, claimed result, evidence)" — all four present, limitation stated openly. Contrast #383, which was blocked on description quality.
Does not line up:
- "Bring real evidence. Performance PRs need benchmarks … (#210)" — not satisfied for the R-way → R*TP-way scaling claim; no numbers, and the GPU repro was not re-run.
- "Supported matrix & compatibility: Check interactions across every supported model, cache scheme, parallel layout, multi-host setup, and hardware target named in the docs" (charter line 42) — the
--tuning-gpus× TP interaction is changed and the docs that name it are not. - Roadmap: nothing about tuning replicas (roadmap items are the in-process Rust SDK #6, Engram #267, FlashInfer #215) — neither aligned nor opposed.
Claims and evidence
| Claim | What backs it |
|---|---|
| Eliminates cross-rank divergence for homogeneous TP catalogs | Unit tests for authorization() both modes + one real 4-process Gloo ReplicaPreparation.prepare() test with a fake job and scripted latencies (320, 315, 318, 302.5), winner = process 3. No b12x, no GPU. |
| Fixes asymmetric catalogs / warm retries via serving-replica reconcile | One mocked session test asserting shard_calls == [(0,(0,1)), (0,(0,)), (0,(0,1))] and that replica 0 replays with selected_configs. |
| R-way → R*TP-way sharding scaling | Nothing. No measurement; the sharding is only asserted as a configured shard tuple. |
167 passed (targeted), 1,170 passed / 74 skipped (full CPU tests/preparation/) with 3 declared-unrelated failures |
Self-reported; the three failures (test_inspect_forward_kernels, test_runtime_static_triton, test_source_identity) are attributed to a sibling hyperflare-recipes venv's flare_heliopause build — the same excuse pattern as #543's report. CI on ccb9f5b passed per the orientation packet; the PR cites no CI link. |
| Limitation admitted | "Multi-GPU end-to-end ignition export --tuning-gpus has not yet been re-run on this commit." |
What the new 482 lines actually test (all in the new tests/preparation/test_tuning_replicas.py): six tests — two pure authorization() unit tests (including the mismatched-race-key RuntimeError), one spawned 4-process Gloo test using dist.FileStore + ProcessGroupGloo but a _FakeJob/_FakeSession scripting latencies, and three RecordedPreparationSession.tune() tests that bypass __init__ via object.__new__, hand-assign ~30 attributes, monkeypatch dist.get_rank and torch.cuda.get_device_properties, and swap in _FakeReplicaPreparation/_FakeCoordinator(ranks=(0,1), spans_hosts=False). They verify scheduling decisions and event order, not b12x, CUDA, or AOT loading. Nothing in the diff touches aot.py (not opened) or ForwardCache._prepare_ranks, so the BindingMismatch itself is never exercised.
Reach
- Affected: operators running
--tuning-gpusspanning more than one complete TP replica with--gpusof size >1 (TP≥2 and R≥2), autotune on. The TP1 documented example (--gpus 0 --tuning-gpus 0-3,docs/cli-design.md:566,docs/model-preparation.md:254) is untouched by thetensor_parallel > 1guard (tuning.py:440). - Not affected: multi-host runs (rejected at
serve.py:142-143(not opened),serve.py:375-376(not opened);tuning.py:426-427;tuning_replicas.py:181-182),--autotune-effort offruns (block is insideif self.autotune:), exported core formats, caches, manifests, ABI, dependencies, CLI surface, defaults. - Side effects: kernel selection for homogeneous replica runs changes from per-rank winners to one global winner — different
scratch_layout, so forwards recompile; and the wider shard count invalidates partial tuning checkpoints (docs/model-preparation.md:224-229; completed selection caches remain usable). Baseline checkpoint/selection-cache keying isconfigure_tuning_shardat tuning.py:451, 466, 526, 535 and 260/264. - Entry points reaching this code:
ignition export(ignition/cli/serve.py:300-312(not opened)),ignition debug-serve(:453-456),ignition bench(ignition/cli/bench.py:245 (not opened), 290), all viaprepare_recipe(tuning_replicas.py:177-217). - Test infrastructure: first CPU multi-process (Gloo) test for
ReplicaPreparation; 4 spawned processes withjoin(timeout=30)— new load and a potential flake source in the CPU CI leg (.github/workflows/python-cpu.yml(not opened)). - Documentation: no doc file in the diff; three passages are now stale (see Key finding 1).
Process
Open, marked ready for review, <1 day old at time of writing, no labels, no reviews, no comments, CI green on head. No rebase needed (no main commits touching these files since branch point). Signed-off trailers (Design-Signed-Off-By, docs/design-review.md:298 (not opened)) could not be verified from this vantage point — #383 was blocked on exactly those; treat as unverified, not as failing.
Open questions / what could not be found
- No result for the actual repro. Whether the TP=8 Ergo / 16-GPU
BindingMismatchis gone is unverified; the author says so explicitly. - No measurement of the sharding-scaling claim — the highest-probability review objection, matching #383's block.
- No issue reference. The failure was reported only in the PR description; no user-visible bug report for the
--tuning-gpusvariant exists to attach. - Whether the missing cross-replica agreement on the fallback path is intended. With
share_across_ranks=False,_shardedstays False, soagree_selectionsis skipped (tuning.py:546-549) and only per-TP-groupreconcile_selectionsruns (tuning.py:521-535) — meaning the description's "for asymmetric TP catalogs … via serving-replica reconcile_selections" holds within each replica's TP group, not across replicas. - Whether the
tuning_completebarrier is symmetric when replica-N ranks (not members of the serving group) executebarrier("tuning_complete", coordinator.ranks)(tuning.py:640-641); the new test only asserts the call tuple against a fake coordinator. - Commit trailers (sign-off / design review) unverified.
- No
main-branch history for these files was readable (git object graph error) and no Autobot intake exists on #695, so no prior review commentary is available.