Repository navigation
[Refactor] Compare token layouts instead of group sizes when selecting communicator paths - #40869
Merged
Merged
Conversation
Merged
4 of 5 tasks
ch-wan
marked this pull request as ready for review
September 23, 2026 07:28
ch-wan
requested review from
BBuf,
Edwardf0t1,
Fridge003,
HaiShaw,
Ying1123,
ispobock and
merrymercy
as code owners
September 23, 2026 07:28
This was referenced Sep 23, 2026
ch-wan
force-pushed
the
cheng/refactor/communicator-transition-table
branch
from
September 23, 2026 09:32
5d0f183 to
adad6c3
Compare
ch-wan
force-pushed
the
cheng/hot-fix/qwen3-next-last-layer-allreduce
branch
2 times, most recently
from
September 23, 2026 21:40
713aa75 to
2b45b0e
Compare
ch-wan
requested review from
hanming-lu,
hebiao064,
hnyls2002,
yizhang2077 and
yuan-luo
as code owners
September 23, 2026 21:40
Base automatically changed from
cheng/hot-fix/qwen3-next-last-layer-allreduce
to
main
September 23, 2026 21:41
…tor paths CommunicateContext now records, for each ScatterMode, the token axes (attention DP, attention CP, attention-TP scatter) that a rank's rows are sharded over. The base communicator's selection tables use these layouts to decide when a transition is the identity. Group sizes are only products of axis sizes, so different layouts can share a size. The mode-to-function mappings are written as explicit tables. Selections are unchanged for every valid topology. The DSA context-parallel communicator, whose SCATTERED mode shards tokens over CP, keeps its size-based checks.
ch-wan
force-pushed
the
cheng/refactor/communicator-transition-table
branch
from
September 23, 2026 21:41
adad6c3 to
59b5eec
Compare
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.
This PR is part of a stack (oldest at bottom):
Motivation
LayerCommunicatorpicks the collective for each boundary (gather, scatter, all-reduce or nothing) from three tables keyed by the source and targetScatterMode. Whether a transition is the identity was decided by comparing process-group sizes. A group size is only the product of axis sizes, so two different token layouts can have the same size, and the tables hide the mapping from modes to functions inside chains of conditions.Modifications
python/sglang/srt/layers/boundary_layout.py:TokenAxis(ATTN_DP,ATTN_CP,ATTN_TP_SCATTER) andLayout, a frozenmsgspec.Structholding the set of token axes a rank's rows are sharded over.communicator.py:scatter_mode_layouts(...)derives eachScatterMode's layout from the attention DP / CP / TP sizes.CommunicateContext.layoutsis computed from the context's own size fields (its constructor is unchanged), andis_same_layoutcompares two modes' layouts. The base communicator's threeget_fntables use it for the identity check, and the mode-to-function mappings are written as explicit tables.SCATTEREDmode shards tokens over CP, keeps its size-based checks (process_group_sizes/is_same_group_sizestay).test/registered/unit/layers/test_communicator_layout.py(builds contexts fromscatter_mode_layoutsdirectly, without process-wide parallel state).Accuracy Tests
Selection happens at construction time; the runtime path is unchanged. An exhaustive comparison against main covers 27 topologies (attention DP / CP / TP ∈ {1, 2, 4}) ×
SGLANG_USE_AG_AFTER_QLORAon / off and every mode pair of the three tables: 18,144 selections, 0 differences.test/registered/unit/layers+unit/models: every existing case keeps its status; the 6 new cases pass.Speed Tests and Profiling
N/A: the selection runs once per layer at construction.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #35924006362
Latest PR Test (Extra): 🚫 Run #35924005932
Latest PR Test (AMD ROCm 10): ❌ Run #35924006190