-
Notifications
You must be signed in to change notification settings - Fork 241
[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
Open
jianzs
wants to merge
11
commits into
main
Choose a base branch
from
feat/dp-comm-opt
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.
+60
−32
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d8e3159
feat: optimize forward metadata collection across dp ranks
jianzs fe1f5c0
fix: change num_tokens_across_dp type from int to torch.Tensor
jianzs 7f1da12
refactor: remove unused imports from model_runner_v1.py
jianzs 1cffb52
fix: correct handling the num_tokens for dummy run
jianzs b9c7f30
chore: lint
jianzs e7064e0
fix: improve handling of max_num_tokens
jianzs d425f5b
fix: update dummy run batch size handling
jianzs d0b8fd3
fix: add assertion for num_tokens_across_dp in NPUModelRunner
jianzs 05d8b6a
fix: change assertion to exception for dummy batch execution in NPUWo…
jianzs e3a9cd5
chore: lint
jianzs 7726146
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 |
---|---|---|
|
@@ -277,16 +277,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) | ||
|
||
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 | ||
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? 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.