Skip to content

Conversation

fan2956
Copy link
Contributor

@fan2956 fan2956 commented Sep 25, 2025

What this PR does / why we need it?

Running multimodal model with ascend scheduler may cause assert error 【assert (request.num_tokens - request.num_computed_tokens) == 1】

Does this PR introduce any user-facing change?

No

How was this patch tested?

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 provides a critical fix for an assertion error that occurs when running multimodal models with the Ascend scheduler. The change correctly prevents partial prefilling of multimodal requests when their encoder inputs cannot be scheduled, which was the root cause of the issue. The fix is well-targeted and effectively ensures the stability of the scheduler for multimodal workloads. The change is correct and I approve of it.

new_encoder_budget) = self._try_schedule_encoder_inputs(
request, num_computed_tokens, num_new_tokens,
encoder_budget)
if num_new_tokens == 0 or len(encoder_inputs_to_schedule) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This change is critical to prevent a crash when scheduling multimodal requests. Previously, if encoder inputs couldn't be scheduled due to budget constraints, the scheduler would still attempt to prefill the text tokens. This partial prefilling would lead to an inconsistent request state, causing an assertion failure later in the decoding phase. By adding the len(encoder_inputs_to_schedule) == 0 check, you ensure that the request is deferred until all its necessary components can be scheduled, which correctly resolves the issue.

Signed-off-by: fan2956 <[email protected]>
Signed-off-by: fan2956 <[email protected]>
@wangxiyuan wangxiyuan added ready read for review ready-for-test start test by label for PR labels Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready read for review ready-for-test start test by label for PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants