-
Notifications
You must be signed in to change notification settings - Fork 188
Add max_anchors and max_context_window support to P-EAGLE #590
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
orestis-z
wants to merge
5
commits into
vllm-project:main
from
orestis-z:peagle-max-anchors-context-window
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1cd3be9
Add max_anchors and max_context_window support to P-EAGLE
orestis-z 1230c69
Restore DFlash max_anchors default to 3072
orestis-z 3f8b6e7
Fix max-anchors help text to reflect 3072 DFlash default
orestis-z abd87c1
Address review feedback: fix max_anchors/max_context_window edge cases
orestis-z 2a19d62
Add unit tests for max_context_window bypass bug
orestis-z 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
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,59 @@ | ||
| """Unit tests for P-EAGLE COD sampling logic.""" | ||
|
|
||
| import torch | ||
|
|
||
| from speculators.models.peagle.data import generate_cod_sample_indices | ||
|
|
||
|
|
||
| class TestMaxContextWindow: | ||
| def test_applied_when_anchors_within_limit(self): | ||
| """max_context_window caps the window even when anchors <= max_anchors.""" | ||
| seq_length = 256 | ||
| loss_mask = torch.zeros(1, seq_length) | ||
| # Place 4 valid positions spread far apart (indices 10, 80, 160, 240) | ||
| valid_positions = [10, 80, 160, 240] | ||
| for pos in valid_positions: | ||
| loss_mask[0, pos] = 1 | ||
|
|
||
| anchor_pos, depth = generate_cod_sample_indices( | ||
| seq_length=seq_length, | ||
| loss_mask=loss_mask, | ||
| max_anchors=8, | ||
| max_context_window=64, | ||
| ) | ||
|
|
||
| depth_0_mask = depth == 0 | ||
| depth_0_positions = anchor_pos[depth_0_mask] | ||
| window_size = depth_0_positions.shape[0] | ||
| assert window_size <= 64 | ||
|
|
||
| def test_applied_when_anchors_exceed_limit(self): | ||
| """max_context_window caps the window when anchors > max_anchors.""" | ||
| seq_length = 512 | ||
| loss_mask = torch.ones(1, seq_length) | ||
|
|
||
| anchor_pos, depth = generate_cod_sample_indices( | ||
| seq_length=seq_length, | ||
| loss_mask=loss_mask, | ||
| max_anchors=16, | ||
| max_context_window=32, | ||
| ) | ||
|
|
||
| depth_0_mask = depth == 0 | ||
| depth_0_positions = anchor_pos[depth_0_mask] | ||
| window_size = depth_0_positions.shape[0] | ||
| assert window_size <= 32 | ||
|
|
||
| def test_no_windowing_without_max_anchors(self): | ||
| """Without max_anchors, full sequence is used.""" | ||
| seq_length = 128 | ||
| loss_mask = torch.ones(1, seq_length) | ||
|
|
||
| anchor_pos, depth = generate_cod_sample_indices( | ||
| seq_length=seq_length, | ||
| loss_mask=loss_mask, | ||
| max_anchors=None, | ||
| ) | ||
|
|
||
| depth_0_mask = depth == 0 | ||
| assert anchor_pos[depth_0_mask].shape[0] == seq_length |
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.
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.
I'm a little bit worried that this bit causing more graph breaks but otherwise this diff looks great!