-
Notifications
You must be signed in to change notification settings - Fork 331
feat(multi-lora): enable and validate MoE expert adapters #1794
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
Open
yushengsu-thu
wants to merge
9
commits into
main
Choose a base branch
from
radixark/multilora-moe-experts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
eecb246
feat(multi-lora): enable and validate MoE expert adapters
yushengsu-thu 5f8ca7b
docs: trim multi-LoRA comments to 1-2 lines per review
yushengsu-thu 658e134
docs: reduce bridge_lora_helpers comments and assert messages to one …
yushengsu-thu fc9c521
style: apply black to bridge_lora_helpers.py
yushengsu-thu dfa65cd
Merge branch 'main' into radixark/multilora-moe-experts
Zhichenzzz 7d907ac
refactor: address review — top-level import/global, current_rank rena…
yushengsu-thu 8176f5d
docs: squash remaining multi-LoRA comments per review
yushengsu-thu d5b20e4
Merge branch 'main' into radixark/multilora-moe-experts
yushengsu-thu da6f281
Merge branch 'main' into radixark/multilora-moe-experts
yushengsu-thu 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
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
46 changes: 46 additions & 0 deletions
46
tests/fast/backends/megatron_utils/test_multi_lora_checkpoint_naming.py
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,46 @@ | ||
| """Adapter shards are keyed by (tp, pp, ep): EP ranks hold different local experts, and | ||
| the realized coordinates are not the tp x pp x ep cross product when ETP < TP.""" | ||
|
|
||
| from miles.backends.megatron_utils.multi_lora_utils import all_megatron_checkpoints_exist, megatron_shard_name | ||
|
|
||
|
|
||
| def _names(coords, ep_size): | ||
| return {megatron_shard_name(*coord, ep_size) for coord in coords} | ||
|
|
||
|
|
||
| def test_shard_name_omits_ep_suffix_without_expert_parallelism(): | ||
| # Checkpoints written before expert adapters existed must stay loadable. | ||
| assert megatron_shard_name(0, 0, 0, ep_size=1) == "adapter_megatron_tp0_pp0.pt" | ||
| assert megatron_shard_name(1, 2, 0, ep_size=1) == "adapter_megatron_tp1_pp2.pt" | ||
|
|
||
|
|
||
| def test_shard_name_is_unique_per_expert_parallel_rank(): | ||
| names = {megatron_shard_name(0, 0, ep, ep_size=4) for ep in range(4)} | ||
| assert len(names) == 4 | ||
| assert megatron_shard_name(0, 0, 2, ep_size=4) == "adapter_megatron_tp0_pp0_ep2.pt" | ||
|
|
||
|
|
||
| def test_completeness_check_requires_every_realized_shard(tmp_path): | ||
| coords = [(0, 0, 0), (0, 0, 1), (0, 0, 2)] | ||
| for coord in coords[:2]: | ||
| (tmp_path / megatron_shard_name(*coord, 3)).touch() | ||
|
|
||
| assert not all_megatron_checkpoints_exist(tmp_path, _names(coords, 3)) | ||
|
|
||
| (tmp_path / megatron_shard_name(*coords[2], 3)).touch() | ||
| assert all_megatron_checkpoints_exist(tmp_path, _names(coords, 3)) | ||
|
|
||
|
|
||
| def test_completeness_ignores_unrealized_coordinates(tmp_path): | ||
| # TP=2, EP=2, ETP=1: only (0,0,0) and (1,0,1) exist; a cross-product check | ||
| # would demand four shards and never resume. | ||
| coords = [(0, 0, 0), (1, 0, 1)] | ||
| for coord in coords: | ||
| (tmp_path / megatron_shard_name(*coord, 2)).touch() | ||
|
|
||
| assert all_megatron_checkpoints_exist(tmp_path, _names(coords, 2)) | ||
|
|
||
|
|
||
| def test_completeness_check_with_single_shard(tmp_path): | ||
| (tmp_path / "adapter_megatron_tp0_pp0.pt").touch() | ||
| assert all_megatron_checkpoints_exist(tmp_path, _names([(0, 0, 0)], 1)) |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.