-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
[Attention][DCP] Support DCP with query length > 1 (MTP) with FA3 #25049
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
11 commits
Select commit
Hold shift + click to select a range
8cdbd20
[Attention][DCP] Support DCP with query len > 1 with FA3
minosfuture 45bb7e8
fix num_heads
minosfuture 9c0176b
keep reorder_batch_threshold check for other backends; also fix max_s…
minosfuture 4cc05c6
pass cp_tot_seqused_k
minosfuture a6efa96
fix pre-commit check
minosfuture ed6dcdd
make cp_seq_lens cuda graph compatible
minosfuture efaf7fa
update flash-attn commit hash to pick up cp-related changes
minosfuture 036357e
Merge remote-tracking branch 'origin/main' into dcp_mtp_merge
minosfuture 19a7f8c
change cp_ prefix to dcp_
minosfuture 3a5dcb2
Merge branch 'main' into dcp_mtp
minosfuture 56478b6
Merge branch 'main' into dcp_mtp
minosfuture 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 |
|---|---|---|
|
|
@@ -398,6 +398,10 @@ def __init__( | |
| self.max_num_reqs + 1, dtype=torch.int32 | ||
| ) | ||
| self.seq_lens = self._make_buffer(self.max_num_reqs, dtype=torch.int32) | ||
| if self.dcp_world_size > 1: | ||
| self.dcp_local_seq_lens = self._make_buffer( | ||
| self.max_num_reqs, dtype=torch.int32 | ||
| ) | ||
| # Because inputs_embeds may be bfloat16 and we don't need a numpy | ||
| # version of this tensor, avoid a RuntimeError by not creating a | ||
| # numpy buffer. | ||
|
|
@@ -581,7 +585,10 @@ def _may_reorder_batch(self, scheduler_output: "SchedulerOutput") -> None: | |
| # NOTE(lucas): currently no backend supports the custom masking | ||
| # required for DCP with q_len > 1, so we assert here. Remove this | ||
| # assert once the custom mask is support is added to FA3. | ||
| if self.dcp_world_size > 1: | ||
| if ( | ||
| self.dcp_world_size > 1 | ||
| and envs.VLLM_ATTENTION_BACKEND != "FLASH_ATTN_MLA" | ||
| ): | ||
| assert self.reorder_batch_threshold == 1, ( | ||
| "DCP not support reorder_batch_threshold > 1 now." | ||
|
Contributor
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. since only flash_attn_mla support custom mask, we can't just remove this assert right now?
Contributor
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. make sense. I'll make a whitelist here for FA3 MLA |
||
| ) | ||
|
|
@@ -1335,6 +1342,9 @@ def _prepare_inputs( | |
| num_logits_indices=logits_indices.size(0), | ||
| causal=True, | ||
| encoder_seq_lens=encoder_seq_lens, | ||
| dcp_local_seq_lens=self.dcp_local_seq_lens.gpu[:num_reqs] | ||
| if self.dcp_world_size > 1 | ||
| else None, | ||
| ) | ||
|
|
||
| if self.speculative_config and spec_decode_common_attn_metadata is None: | ||
|
|
@@ -3309,6 +3319,9 @@ def _dummy_run( | |
| kv_cache_group_id | ||
| ].slot_mapping.gpu[:num_tokens], | ||
| causal=True, | ||
| dcp_local_seq_lens=self.dcp_local_seq_lens.gpu[:num_reqs] | ||
| if self.dcp_world_size > 1 | ||
| else None, | ||
| ) | ||
| for attn_group in self.attn_groups[kv_cache_group_id]: | ||
| if ubatch_slices is not None: | ||
|
|
||
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.