-
Notifications
You must be signed in to change notification settings - Fork 5.2k
DeepSeek-V3/R1 MoE load balance deployment and inference using EPLB #5270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e6d040e
Added Permuted EP MoE implementation.
feliang-git f83da1e
Implemented expert loading and forward part of load balance.
feliang-git 44f4b1a
Implement EPLB weight loading. Modify in EP_MOE class
feliang-git e60b895
Clean-up the code.
feliang-git 98bec86
Merge remote-tracking branch 'upstream/main' into ep_moe_lb
feliang-git bfa0a55
Resolved conflicts.
feliang-git cc412d0
Pre-commit check.
feliang-git File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # python3 ./sglang_rebalance/python/sglang/srt/epmoe_permute_tensor.py | ||
| import torch | ||
| # Set a seed for reproducibility | ||
| torch.manual_seed(42) | ||
|
|
||
| # Create a global tensor variable for testing | ||
| # 61 rows, each row has a random permutation of integers from 0 to 255 | ||
| EP_PERMUTE_TENSOR = torch.stack([ | ||
| torch.randperm(256) | ||
| for _ in range(61) | ||
| ], dim=0) | ||
|
|
||
| EP_BACK_MAPPING_TENSOR = torch.zeros((61, 256), dtype=torch.long) | ||
| for layer_idx in range(61): | ||
| for expert_idx, permuted_expert_id in enumerate(EP_PERMUTE_TENSOR[layer_idx]): | ||
| EP_BACK_MAPPING_TENSOR[layer_idx, permuted_expert_id] = expert_idx | ||
|
|
||
| # # Save the tensors to a text file | ||
| # with open("ep_permute_tensors.txt", "w") as f: | ||
| # f.write("EP_PERMUTE_TENSOR:\n") | ||
| # # Save the full tensor without truncation | ||
| # torch.set_printoptions(threshold=float('inf')) | ||
| # f.write(str(EP_PERMUTE_TENSOR)) | ||
| # f.write("\n\nEP_BACK_MAPPING_TENSOR:\n") | ||
| # f.write(str(EP_BACK_MAPPING_TENSOR)) | ||
| # # Reset print options to default | ||
| # torch.set_printoptions(threshold=1000) | ||
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
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better pass the num_layers info as well as num_experts.