-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Feature] Optimize forward metadata collection across dp ranks #1593
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b30878a
feat: optimize forward metadata collection across dp ranks
jianzs e160939
refactor: remove unused imports from model_runner_v1.py
jianzs dc9a0de
fix: correct handling the num_tokens for dummy run
jianzs 91b49e3
chore: lint
jianzs ad1e341
fix: improve handling of max_num_tokens
jianzs 83b9dca
fix: update dummy run batch size handling
jianzs 41f905e
fix: add assertion for num_tokens_across_dp in NPUModelRunner
jianzs 82c53b2
fix: change assertion to exception for dummy batch execution in NPUWo…
jianzs bc3b360
chore: lint
jianzs d35cbf3
Update vllm_ascend/worker/model_runner_v1.py
jianzs 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -294,16 +294,30 @@ def pin_lora(self, lora_id: int) -> bool: | |
|
|
||
| def execute_dummy_batch(self) -> None: | ||
| runner = self.model_runner | ||
| max_num_tokens = 1 | ||
| with_prefill = False | ||
| if runner.dp_size > 1: | ||
| max_num_tokens, with_prefill = runner._get_forward_metadata_across_dp( | ||
| max_num_tokens, with_prefill) | ||
| if runner.dp_size <= 1: | ||
| raise ValueError( | ||
| "Dummy batch execution should only be " | ||
| "performed with data parallelism enabled, but got " | ||
| f"dp_size={runner.dp_size}.") | ||
|
|
||
| # If torchair graph is enabled, notify the other DP ranks that this is a | ||
| # dummy run by using '-1' as a flag for num_tokens. This will be | ||
| # replaced with the final determined graph size before the forward pass. | ||
| num_tokens_across_dp, with_prefill = \ | ||
| runner._get_forward_metadata_across_dp(-1, False) | ||
|
jianzs marked this conversation as resolved.
|
||
|
|
||
| if runner.torchair_graph_enabled and not with_prefill: | ||
| max_num_tokens = runner.select_torchair_padded_batch_size( | ||
| max_num_tokens = int(num_tokens_across_dp.max().item()) | ||
| num_tokens = runner.select_torchair_padded_batch_size( | ||
| max_num_tokens) | ||
| runner._dummy_run(max_num_tokens, | ||
| else: | ||
| num_tokens = 1 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is it 1?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If graph mode is off, a dummy run only needs to be executed; computational requirements are not a factor. |
||
|
|
||
| num_tokens_across_dp.masked_fill_(num_tokens_across_dp == -1, | ||
| num_tokens) | ||
| runner._dummy_run(num_tokens, | ||
| is_compile=False, | ||
| num_tokens_across_dp=num_tokens_across_dp, | ||
| with_prefill=with_prefill) | ||
|
|
||
| def _init_worker_distributed_environment(self) -> None: | ||
|
|
||
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.