Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions vllm_ascend/torchair/models/torchair_deepseek_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,13 @@ def forward(
output_parallel = self.quant_method.apply(self,
input_parallel,
bias=bias_)
forward_context = get_forward_context()
if self.reduce_results and self.tp_size > 1:
num_tokens = output_parallel.shape[0]
if is_force_scatter and num_tokens % self.tp_size:
output_parallel = nn.functional.pad(
output_parallel, (0, 0, 0, -num_tokens % self.tp_size))
if is_force_scatter or (not is_prefill
if is_force_scatter or (not forward_context.with_prefill
and output_parallel.shape[0] % self.tp_size
== 0):
Comment on lines +169 to 171
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using forward_context.with_prefill makes the is_prefill parameter of this forward method unused. This is misleading and can lead to future bugs if other developers rely on this parameter, expecting it to have an effect.

To improve maintainability and prevent potential issues, the is_prefill parameter should be removed from the function signature of TorchairDeepseekV2RowParallelLinearReplaceAllreduce.forward. This will require updating the call site in vllm_ascend/attention/mla_v1.py to no longer pass this argument.

output = tensor_model_parallel_reduce_scatter(output_parallel,
Expand Down Expand Up @@ -726,7 +727,8 @@ def forward(
replace_allreduce: bool = False,
) -> torch.Tensor:
# Self Attention
if attn_metadata is not None and attn_metadata.num_decodes > 0:
forward_context = get_forward_context()
if attn_metadata is not None and not forward_context.with_prefill:
mla_moe_communication = self.mla_moe_communication and replace_allreduce
else:
mla_moe_communication = False
Expand Down
Loading