-
Notifications
You must be signed in to change notification settings - Fork 542
Support multistream of MLA vector operations #1135
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,7 +71,8 @@ | |
| from vllm_ascend.ops.fused_moe import AscendFusedMoE | ||
| from vllm_ascend.quantization.quant_config import AscendLinearMethod | ||
| from vllm_ascend.quantization.w8a8_dynamic import AscendW8A8DynamicLinearMethod | ||
| from vllm_ascend.utils import dispose_tensor | ||
| from vllm_ascend.utils import (dispose_tensor, npu_stream_switch, | ||
| npu_wait_tensor) | ||
|
|
||
| VLLM_ENABLE_MC2: bool = envs_ascend.VLLM_ENABLE_MC2 | ||
|
|
||
|
|
@@ -496,6 +497,8 @@ def __init__( | |
|
|
||
| ascend_config = get_ascend_config() | ||
| self.torchair_graph_enabled = ascend_config.torchair_graph_config.enabled | ||
| self.enable_multistream_mla = \ | ||
| ascend_config.torchair_graph_config.enable_multistream_mla | ||
|
|
||
| def forward( | ||
| self, | ||
|
|
@@ -505,7 +508,14 @@ def forward( | |
| attn_metadata: Optional[AttentionMetadata] = None) -> torch.Tensor: | ||
| if self.q_lora_rank is not None: | ||
| ckq = self.q_a_proj(hidden_states)[0] | ||
| hidden_states_or_q_c = self.q_a_layernorm(ckq) | ||
| use_multistream_mla = (self.enable_multistream_mla | ||
| and attn_metadata is not None | ||
| and attn_metadata.num_decodes > 0) | ||
|
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. So, multistream mla will not be triggered if there are only prefill requests? 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. Yes, current multistream utilities only support graph mode, i.e. |
||
| npu_wait_tensor(hidden_states, ckq, enabled=use_multistream_mla) | ||
| with npu_stream_switch("mla_secondary", | ||
| 0, | ||
| enabled=use_multistream_mla): | ||
| hidden_states_or_q_c = self.q_a_layernorm(ckq) | ||
| else: | ||
| hidden_states_or_q_c = hidden_states | ||
| if self.torchair_graph_enabled: | ||
|
|
||
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.
So, this
npu_stream_switchcan be used inside the torchair right? if that's so, can we further optimize the dbo path of deepseek to gain more performance boost.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.
Discussed with torchair colleagues, the
with torch.npu.stream(...):scheme is not supported by torchair graph mode whilenpu_stream_switchonly works under graph mode, so I recommend leaving this to later PRs:npu_stream_switchencapsulating both cases, as well as,