-
Notifications
You must be signed in to change notification settings - Fork 546
fix(eagle3): isolate draft grad clipping #3323
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4790015
fix: keep eagle3 spec decode clear of the max_model_len boundary
yuekaizhang 3286df3
fix: clip draft-model grads in a separate grad-norm group
yuekaizhang 65078a1
fix: forward draft_grad_norm from policy worker to logged metrics
yuekaizhang 4dd259f
feat(megatron): independent LR + train/draft_lr logging for eagle3 draft
yuekaizhang 03f9e04
revert: independent LR + train/draft_lr logging for eagle3 draft
yuekaizhang 5b82d1f
nit: remove redundant .detach() on teacher_logits in DraftCrossEntrop…
yuekaizhang b9dfa51
Merge branch 'main' into spec
yuekaizhang a8317ca
style: apply ruff-format to fix CI lint failure
yuekaizhang bbdb04c
test(eagle3): add unit tests for spec-decode clamp and draft grad-nor…
yuekaizhang 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
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
38 changes: 38 additions & 0 deletions
38
tests/unit/models/generation/test_vllm_spec_decode_clamp.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,38 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import pytest | ||
|
|
||
| from nemo_rl.models.generation.vllm.vllm_worker import BaseVllmGenerationWorker | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("base_max_tokens", "input_len", "max_model_len", "spec_lookahead", "expected"), | ||
| [ | ||
| (256, 100, 1024, 5, 256), # clamp inactive: base wins | ||
| (256, 900, 1024, 5, 118), # clamp active: 1024 - 900 - 6 | ||
| (256, 1018, 1024, 5, 1), # at boundary: floor at 1 | ||
| (256, 1050, 1024, 5, 1), # past boundary: floor at 1 | ||
| (8, 100, 1024, 5, 8), # base < headroom: base wins | ||
| ], | ||
| ) | ||
| def test_spec_decode_max_tokens_clamp( | ||
| base_max_tokens, input_len, max_model_len, spec_lookahead, expected | ||
| ): | ||
| assert ( | ||
| BaseVllmGenerationWorker._spec_decode_max_tokens( | ||
| base_max_tokens, input_len, max_model_len, spec_lookahead | ||
| ) | ||
| == expected | ||
| ) |
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,36 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| @pytest.mark.mcore | ||
| def test_register_draft_grad_norm_group_is_idempotent_and_preserves_existing(): | ||
| from megatron.core.optimizer import optimizer as mcore_opt | ||
|
|
||
| from nemo_rl.models.megatron.draft.utils import ( | ||
| DRAFT_GRAD_NORM_GROUP, | ||
| register_draft_grad_norm_group, | ||
| ) | ||
|
|
||
| original = mcore_opt.SEPARATE_GRAD_NORM_GROUPS | ||
| try: | ||
| register_draft_grad_norm_group() | ||
| after_first = mcore_opt.SEPARATE_GRAD_NORM_GROUPS | ||
| assert DRAFT_GRAD_NORM_GROUP in after_first | ||
| assert "mtp" in after_first # not overwritten | ||
| register_draft_grad_norm_group() | ||
| assert mcore_opt.SEPARATE_GRAD_NORM_GROUPS == after_first # no-op | ||
| finally: | ||
| mcore_opt.SEPARATE_GRAD_NORM_GROUPS = original |
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.