Skip to content

[bugfix] ascend schedule encountered an incorrect req block length in… #2429

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion vllm_ascend/core/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def _check_watermark_for_prefill(self,
self.block_size)
req_blocks = self.kv_cache_manager.coordinator.get_blocks(
request.request_id)
num_new_blocks = (num_required_blocks - len(req_blocks) -
num_new_blocks = (num_required_blocks - len(req_blocks[0]) -
len(computed_blocks))
Comment on lines 418 to 421
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The change from len(req_blocks) to len(req_blocks[0]) is conceptually correct for getting the number of allocated blocks. However, the current implementation is not robust and can lead to runtime errors:

  1. self.kv_cache_manager.coordinator.get_blocks(request.request_id) will raise a KeyError if a request has no blocks allocated yet, which is the case for new requests from the waiting queue.
  2. If get_blocks were to return an empty list for a new request, req_blocks[0] would then raise an IndexError.

This can cause the scheduler to crash. The implementation should be updated to handle these cases gracefully.

        req_blocks = self.kv_cache_manager.coordinator.req_to_blocks.get(
            request.request_id, [])
        num_allocated_blocks = len(req_blocks[0]) if req_blocks else 0
        num_new_blocks = (num_required_blocks - num_allocated_blocks -
                          len(computed_blocks))

num_evictable_computed_blocks = sum(1 for blk in computed_blocks
if blk.ref_cnt == 0)
Expand Down
Loading