Skip to content

Conversation

@momo609
Copy link
Collaborator

@momo609 momo609 commented Nov 24, 2025

What this PR does / why we need it?

prefillnocache branch use fia op.

Does this PR introduce any user-facing change?

How was this patch tested?

Signed-off-by: wangxiaoxin-sherie <[email protected]>
@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the prefill-no-cache attention mechanism to use the npu_fused_infer_attention_score operator. This is a positive change, likely for performance or feature alignment. However, the refactoring has left behind some dead code and unused function parameters in _forward_prefill_no_cache, which I've commented on. The related change in model_runner_v1.py to update the attention mask generation is consistent with this new operator.

Comment on lines +358 to +374
output, _ = torch_npu.npu_fused_infer_attention_score.out(
query=query,
key=key,
value=value,
atten_mask=attn_metadata.attn_mask,
block_table=None,
input_layout="TND",
block_size=128,
actual_seq_lengths=attn_metadata.actual_seq_lengths_q,
actual_seq_lengths_kv=attn_metadata.seq_lens_list,
num_key_value_heads=self.num_kv_heads,
num_heads=self.num_heads,
scale=self.scale,
sparse_mode=3,
)
assert output is not None
return output[:num_tokens, :, :]
return output
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The switch to npu_fused_infer_attention_score has left some surrounding code in an inconsistent state, which impacts maintainability.

Specifically:

  • The _forward_prefill_no_cache function's parameters output and num_tokens are now unused.
  • The preceding if is_310p(): block (lines 347-356) contains dead code:
    • The output tensor is aligned, but then the output variable is immediately reassigned, making the alignment useless.
    • The mask variable is computed, but the new operator call uses attn_metadata.attn_mask instead.

This unused code and parameters should be removed to avoid confusion and improve code clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant