-
Notifications
You must be signed in to change notification settings - Fork 392
R3 PR: Rollout Routing Replay #1273
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
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
a802773
previous code
erictang000 21b44de
lint
erictang000 23fdc45
make opus take a pass at test + plumbing fully thru generator
erictang000 8daac59
updated test utils and file to support rollout replay indices
devpatelio 647426f
add helper functions for router visibility and megatron testing, succ…
devpatelio d4b753f
linter
devpatelio f1b9c53
worked w opus to get forward pass logprob diff lower with replay + ru…
erictang000 8a8fa70
add test for forward backward and fix behavior
erictang000 410995a
working for qwen but not moonlight... debugging moonlight
erictang000 93eee65
x
erictang000 9c716a1
fixed test for moonlight by enforcing fused attn
devpatelio 097d2ad
Merge branch 'r3' of https://github.com/NovaSky-AI/SkyRL into HEAD
devpatelio 6de7d5c
x
devpatelio 591af9b
x
devpatelio acb35ec
clean up
erictang000 5ad9426
rename var and clean up
erictang000 909f5ad
Merge branch 'main' of https://github.com/erictang000/SkyRL into HEAD
erictang000 d2cd56a
Merge branch 'main' of https://github.com/erictang000/SkyRL into HEAD
erictang000 4a60d4c
cleaning up
erictang000 205da19
lint
erictang000 f78dc75
cleaning up
erictang000 43297f0
x
erictang000 0468c37
x
erictang000 0dfed8d
Merge branch 'main' of https://github.com/erictang000/SkyRL into r3
erictang000 4878ed7
x
erictang000 a5babb4
fix bug not propagating router indices to fwd pass
erictang000 7c11d73
x
erictang000 ac1fb79
add supported settings to cfg validation
erictang000 38b15a1
add docs'
erictang000 465ec77
docs
erictang000 e6af1a0
remove legacy
erictang000 951bc24
x
erictang000 2f6c778
x
erictang000 e3c965c
ur right devin
erictang000 7681a33
Merge branch 'main' of https://github.com/erictang000/SkyRL into r3
erictang000 bd69614
add dapo moonlight with r3
erictang000 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
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,62 @@ | ||
| """ | ||
| Utility functions for MoE Router Replay. | ||
| """ | ||
|
|
||
| import torch | ||
| from typing import Optional, List | ||
| from skyrl.backends.skyrl_train.training_batch import TrainingInputBatch | ||
|
|
||
| def _split_replay_indices(rollout_inference_indices: torch.Tensor) -> List[torch.Tensor]: | ||
| if rollout_inference_indices is None: | ||
| return None | ||
| if rollout_inference_indices.dim() != 4: | ||
| raise ValueError(f"Expected 4D replay indices, got shape {rollout_inference_indices.shape}") | ||
| per_layer = rollout_inference_indices.permute(2, 0, 1, 3).contiguous() | ||
| return [per_layer[i] for i in range(per_layer.shape[0])] | ||
|
|
||
| def setup_router_replay_forward(data: TrainingInputBatch, enable_router_replay: bool) -> bool: | ||
| """ | ||
| Set up router replay for forward pass (ref/policy inference). | ||
| """ | ||
| if not enable_router_replay: | ||
| return False | ||
|
|
||
| rollout_inference_indices = data.get("rollout_inference_indices") | ||
| if rollout_inference_indices is None: | ||
| return False | ||
|
|
||
| from megatron.core.transformer.moe.router_replay import RouterReplay, RouterReplayAction | ||
|
|
||
| RouterReplay.set_replay_data(_split_replay_indices(rollout_inference_indices)) | ||
| RouterReplay.set_global_router_replay_action(RouterReplayAction.REPLAY_FORWARD) | ||
|
|
||
| return True | ||
|
|
||
|
|
||
| def setup_router_replay_backward(data: TrainingInputBatch, enable_router_replay: bool) -> bool: | ||
| """ | ||
| Set up router replay for training forward/backward pass. | ||
| """ | ||
| if not enable_router_replay: | ||
| return False | ||
|
|
||
| rollout_inference_indices = data.get("rollout_inference_indices") | ||
| if rollout_inference_indices is None: | ||
| return False | ||
|
|
||
| from megatron.core.transformer.moe.router_replay import RouterReplay, RouterReplayAction | ||
|
|
||
| RouterReplay.set_replay_data(_split_replay_indices(rollout_inference_indices)) | ||
| # Use REPLAY_FORWARD - Megatron handles REPLAY_BACKWARD automatically | ||
| RouterReplay.set_global_router_replay_action(RouterReplayAction.REPLAY_FORWARD) | ||
|
|
||
| return True | ||
|
|
||
|
|
||
| def clear_router_replay(): | ||
| """Clear all router replay state.""" | ||
| from megatron.core.transformer.moe.router_replay import RouterReplay | ||
|
|
||
| RouterReplay.clear_global_indices() | ||
| RouterReplay.clear_global_router_replay_action() | ||
| RouterReplay.clear_global_router_replay_instances() |
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
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
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.