feat(turbomind): Derive composable TurboMind parallel configurations - #4769
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a constraint-based derivation mechanism for TurboMind’s per-module parallel layout (attention TP/DP/CP, MLP TP, outer DP) from user-facing dp/tp/ep/cp, and wires that derivation into the TurboMind engine configuration path. It also updates the TurboMind smoke-test script to accept and report tp/cp/ep/dp consistently (plus communicator selection).
Changes:
- Add
lmdeploy/turbomind/parallel_config.pyto derive a valid parallel layout (and optionally device count) fromdp/tp/ep/cpconstraints. - Route
update_parallel_config()through the new derivation logic and ensure partial explicit per-module configs includeattn_cp_size. - Extend
scripts/test_turbomind_model.pyCLI to support--ep,--dp, and--communicator, with defaults of 1 for parallelism args.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/test_turbomind_model.py | Adds CLI/reporting for ep, dp, and communicator; makes parallelism args default to 1. |
| lmdeploy/turbomind/turbomind.py | Integrates the new constraint-based derivation into TurboMind config completion. |
| lmdeploy/turbomind/parallel_config.py | New stdlib-only parallel layout derivation/validation module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+88
to
+93
| if device_num is not None: | ||
| assert isinstance(device_num, int) and device_num >= 1, \ | ||
| f'device_num must be a positive integer, got {device_num!r}' | ||
| assert total % device_num == 0, (f'config requires {total} devices; ' | ||
| f'device_num={device_num} is not a divisor') | ||
| return [device_num] |
Comment on lines
+94
to
+95
| cap = min(total, available_devices) if available_devices is not None else total | ||
| return [dev for dev in range(cap, 0, -1) if total % dev == 0] |
irexyc
approved these changes
Jul 23, 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.
Summary
This PR replaces TurboMind's ad hoc parallelism calculations with a constraint-based derivation system for TP, CP, EP, and DP.
The new system supports configurations where expert parallelism and MLP tensor parallelism are both greater than 1. For example:
Parallel layout derivation
The new
parallel_config.pyderives per-module parallel sizes using these invariants:The solver:
dp * tp * gcd(cp, ep)as the device-count upper bound.device_num, or scans valid divisors within the available GPU count.dpto deriveouter_dp, attention DP/TP, and MLP TP.This keeps the derivation independent of CUDA and compiled extensions, making it easier to test and reason about.
Integration changes
attn_cp_sizewhen completing partial explicit configurations.mlp_tp_size > 1together withep > 1.Compatibility
Legacy configurations such as
tp=1, ep=Nno longer describe a valid layout. They must specify the global tensor-parallel width explicitly, for example:This ensures the requested global parallelism is consistent with every derived attention and MLP parallel group.