Closed
fix: derive ep_rank from inner_rank / mlp_tp_size instead of inner_rank % ep_size#4756
Conversation
…n mlp_tp_size > 1
Copilot
AI
changed the title
[WIP] Fix code based on review comment
fix: derive ep_rank from inner_rank / mlp_tp_size instead of inner_rank % ep_size
Jul 16, 2026
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.
Motivation
When both
mlp_tp_size > 1andep_size > 1, computingep_rank = inner_rank % ep_sizecollides withmlp_tp_rank = inner_rank % mlp_tp_size— both consume the same modulo space, producing duplicated/incorrect EP ranks. The invariantinner_rank == ep_rank * mlp_tp_size + mlp_tp_rankmust hold.Modification
src/turbomind/turbomind.cc: Fixep_rankderivation toinner_rank / mlp_tp_size; fixmlp_tp_ranktoinner_rank % mlp_tp_size; restore assertion tomlp_tp_size * ep_size == comm_size_; addGetEpRank()implementationsrc/turbomind/turbomind.h: DeclareGetEpRank(int index)src/turbomind/models/llama/llama_params.h: Addint ep_rank = 0toEngineParamsrc/turbomind/engine/engine_config.h: Addep_size(default1) toEngineConfigsrc/turbomind/python/bind.cpp: Exposeep_rankvia Python bindingThe correct decomposition:
BC-breaking (Optional)
No BC-breaking changes.
ep_sizedefaults to1, preserving existing single-EP behavior.Use cases (Optional)
N/A
Checklist