[Bugfix] Fix the attn_metadata is None (#5038)

### What this PR does / why we need it?
Fix the bug " TypeError: 'NoneType' object is not iterable' " in
vllm_ascend/compilation/acl_graph.py
The reason of that is the attn_metadata is none in the dummy_run of MTP.

- vLLM version: v0.12.0
- vLLM main:
ad32e3e19c

Signed-off-by: chenmenglong <chenmenglong1@huawei.com>
This commit is contained in:
MengLong Chen
2025-12-16 09:14:05 +08:00
committed by GitHub
parent d43cabc2b1
commit 5e0ada5395
6 changed files with 8 additions and 10 deletions

View File

@@ -223,7 +223,7 @@ class MtpProposer(Proposer):
def dummy_run(self,
num_tokens: int,
with_prefill: bool = False,
skip_attn: bool = False,
in_graph_capturing: bool = False,
num_reqs: int = 0,
num_tokens_across_dp=None,
aclgraph_runtime_mode: CUDAGraphMode = CUDAGraphMode.NONE,
@@ -247,9 +247,7 @@ class MtpProposer(Proposer):
moe_comm_type = (MoECommType.ALLTOALL if moe_comm_type
== MoECommType.FUSED_ALLTOALL else moe_comm_type)
if skip_attn:
attn_metadata = None
elif aclgraph_runtime_mode == CUDAGraphMode.FULL:
if aclgraph_runtime_mode == CUDAGraphMode.FULL:
if len(self.runner.attn_groups) > 0:
num_computed_tokens_cpu = (
self.runner.input_batch.
@@ -294,7 +292,7 @@ class MtpProposer(Proposer):
positions = self.positions[:num_tokens]
previous_hidden_states = self.hidden_states[:num_tokens]
for i in range(self.num_speculative_tokens):
if i > 0 and not skip_attn and aclgraph_runtime_mode == CUDAGraphMode.FULL:
if i > 0 and not in_graph_capturing and aclgraph_runtime_mode == CUDAGraphMode.FULL:
aclgraph_runtime_mode = CUDAGraphMode.NONE
with set_ascend_forward_context(
attn_metadata,