Repository navigation
Share local tuning across TP ranks in tuning replicas and reconcile serving selections - #695
Merged
Merged
Conversation
…reconcile serving selections
When exporting a tensor-parallel model with local tuning replicas
(--tuning-gpus covering multiple complete TP replicas), each TP rank previously
sharded local candidate races only across its corresponding ranks in other
replicas (states[rank::tensor_parallel]) with configure_tuning_shard(replica,
range(replicas)), and RecordedPreparationSession.tune skipped post-tuning
reconcile_selections and agree_selections whenever _replica_coordinator was
active. On TP=8 with 2 replicas (16 GPUs), all 8 ranks in each replica
redundantly benchmarked the same candidate half, could pick different winners
due to measurement jitter (such as attention.gqa plans with distinct scratch
layouts), and then failed rank-local AOT forward binding with BindingMismatch
after compilation.
Changes:
- ignition/preparation/tuning_replicas.py: added share_across_ranks to
authorization() and ReplicaPreparation so local cache (ready_cache) and
candidate-race (ready_tuning) exchanges span all replica*tensor_parallel
processes when homogeneous, while keeping collective exchanges
(ready_collectives and ready_collective_tuning) scoped to each replica's
local TP group.
- ignition/preparation/tuning.py:
- RecordedPreparationSession.tune gathers (device.identity,
_local_tuning_catalog(requests)) across all tuning-replica processes. When
tensor_parallel > 1 and all processes report identical device identities
and local tuning catalogs, it enables share_across_ranks, sets _sharded,
and shards local candidates across all replica*tensor_parallel processes
(shard rank replica * tensor_parallel + rank). Otherwise it retains
corresponding-rank sharding across replicas.
- Post-tuning reconcile_selections and agree_selections now run on serving
replica 0 (self.tuning_replica is None or self.tuning_replica.index == 0)
instead of being skipped whenever _replica_coordinator is set; any
reconciliation replay temporarily resets configure_tuning_shard(0, (0,))
and restores the configured shard afterward. Non-serving replicas
(index > 0) skip reconciliation and exit via TuningComplete as before.
- tests/preparation/test_tuning_replicas.py: added CPU unit tests for
authorization() (shared and corresponding-rank modes, mixed local/collective
interleaving, mismatched race rejection), a 4-process (2 replicas x TP2)
Gloo spawn test of ReplicaPreparation.prepare(), and
RecordedPreparationSession.tune() tests covering homogeneous cross-rank
sharding, unequal-catalog fallback with serving-replica reconciliation, and
non-serving replica exit.
Expected benefit:
Prevents cross-rank kernel selection divergence (BindingMismatch during AOT
forward loading) when using --tuning-gpus on TP models, and scales local
candidate sharding from R-way to (R * TP)-way when all tuning GPUs and local
catalogs match (eliminating TP-way duplicate local races).
Evidence:
- pytest tests/preparation/test_tuning_replicas.py
tests/preparation/test_tuning_shards.py tests/preparation/test_tuning_jobs.py
tests/preparation/test_dcp_selection_groups.py tests/cli/ -q: 167 passed.
- Full tests/preparation/ run under the sibling recipes venv: 1,170 passed,
74 skipped (GPU-gated), 3 unrelated environment failures
(test_inspect_forward_kernels, test_runtime_static_triton,
test_source_identity due to mismatched workspace/venv heliopause build).
- Limitations: multi-GPU end-to-end --tuning-gpus export has not yet been
re-run on this commit.
Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
Collaborator
|
A case file has been opened for 695. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Collaborator
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe 44-line production change in
Walkthrough
Merge Risk: Low · up to
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
When exporting a tensor-parallel model with local tuning replicas (
--tuning-gpusspanning multiple complete TP replicas),RecordedPreparationSession.tunepreviously sharded local candidate races only across corresponding ranks (configure_tuning_shard(replica, range(replicas))withpeers = states[rank::tensor_parallel]inignition/preparation/tuning_replicas.py), and explicitly skipped post-tuningreconcile_selections(and self._replica_coordinator is None) andagree_selections.During a TP=8
Amazon-FMR/Ergoexport with--gpus 0-7 --tuning-gpus 0-15(2 TP=8 replicas on 16 RTX PRO 6000 Blackwell GPUs), this caused two concrete failures:attention.gqachampions with differentscratch_layoutsizes across ranks 0–7.ForwardCache._prepare_ranks) withBindingMismatchondecoder.layers[0|3].attention.attention.scratch_layoutafter completing both autotuning and compilation.What changed
ignition/preparation/tuning_replicas.py:authorization()always exchangedready_cacheandready_tuningonly across corresponding ranksstates[rank::tensor_parallel].share_across_ranks: bool = Falsetoauthorization()andReplicaPreparation. WhenTrue,ready_cacheandready_tuningsynchronize across allreplicas * tensor_parallelprocesses so_tuning_resultsselects one global winner for every rank, whileready_collectivesandready_collective_tuningremain scoped to each replica's local TP group (states[replica * tp : (replica + 1) * tp]).ignition/preparation/tuning.py:RecordedPreparationSession.tune()gathered onlyself.device.identity, configured(replica_index, range(replicas))sharding unconditionally, and skippedreconcile_selectionsandagree_selectionswhenever_replica_coordinatorwas set.(self.device.identity, _local_tuning_catalog(requests))across all replica processes. Whentensor_parallel > 1and all processes share identical device identities and local tuning catalogs, setsshare_across_ranks=True, setsself._sharded=True, and configures(replica * tensor_parallel + rank, range(processes))sharding. Otherwise falls back to corresponding-rank sharding(replica, range(replicas)). Post-tuningreconcile_selections(with temporary reset/restore ofconfigure_tuning_shard(0, (0,))around replay) andagree_selectionsnow run on serving replica 0 (self.tuning_replica is None or self.tuning_replica.index == 0), while non-serving replicas (index > 0) skip reconciliation and exit viaTuningComplete.tests/preparation/test_tuning_replicas.py: Added unit tests forauthorization()(both modes, mixed local/collective interleaving, mismatched race keys), a 4-process (2 replicas × TP=2) Gloo spawn test ofReplicaPreparation.prepare(), andRecordedPreparationSession.tune()tests covering homogeneous cross-rank sharding, unequal-catalog fallback with serving-replica reconciliation, and non-serving replica exit.Claimed benefit
BindingMismatchduring AOT forward loading) on TP exports using--tuning-gpus, both for homogeneous TP catalogs (via unified cross-rank candidate exchange + agreement check) and for asymmetric TP catalogs or warm retries (via serving-replicareconcile_selections).R-way to(R * TP)-way when all tuning GPUs and local catalogs match, avoidingTP-way redundant local races.Supporting evidence
pytest tests/preparation/test_tuning_replicas.py tests/preparation/test_tuning_shards.py tests/preparation/test_tuning_jobs.py tests/preparation/test_dcp_selection_groups.py tests/cli/ -q: 167 passed (including the 4-process GlooReplicaPreparationtest).tests/preparation/CPU run (invoked from the siblinghyperflare-recipesvenv): 1,170 passed, 74 skipped (GPU-gated), with 3 unrelated environment failures (test_inspect_forward_kernels,test_runtime_static_triton,test_source_identitydue to running against the sibling venv'sflare_heliopausebuild rather than a worktree-local build).ignition export --tuning-gpushas not yet been re-run on this commit.Discord: lukealonso