Skip to content
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

[WIP] Prototyping re-arch #9166

Closed
wants to merge 31 commits into from
Closed

[WIP] Prototyping re-arch #9166

wants to merge 31 commits into from

Conversation

WoosukKwon
Copy link
Collaborator

No description provided.

Copy link

github-actions bot commented Oct 8, 2024

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

Copy link
Member

@zhuohan123 zhuohan123 left a comment

Choose a reason for hiding this comment

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

First part of review: scheduler and KV cache manager.

High-level notes on the new scheduler and KV cache manager:

  • Assuming chunked prefill always on.
    • I still have some confusion on how does the new scheduler works for decoding requests. See comment below.
  • No sequence group (which is the goal of the re-arch)
  • No CPU swapping (swapping will be in KV cache manager)
  • All sharing via prefix caching
    • However, still requires a prefix caching enabled KV cache manager.

Comment on lines +28 to +29
# Reserve block id 0 for padding.
self.free_block_ids = list(range(num_gpu_blocks))
Copy link
Member

Choose a reason for hiding this comment

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

Is block 0 actually reserved?

Comment on lines +81 to +82
num_tokens = request.num_tokens - request.num_computed_tokens
num_tokens = min(num_tokens, token_budget)
Copy link
Member

@zhuohan123 zhuohan123 Oct 11, 2024

Choose a reason for hiding this comment

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

Here we assume we always do chunked prefill right? How does the num_tokens computation here work for decoding phase requests? Will request.num_tokens - request.num_computed_tokens always be 1 in that case?

Comment on lines +117 to +118
if preempted_reqs:
break
Copy link
Member

Choose a reason for hiding this comment

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

Nit: this should be outside of the while loop.

Comment on lines +147 to +150
if request.status == RequestStatus.WAITING:
scheduled_new_reqs.append(request)
elif request.status == RequestStatus.PREEMPTED:
scheduled_resumed_reqs.append(request)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to distinguish these two? Is it for delta update optimization?

Comment on lines +193 to +194
finished_req_ids=self.finished_req_ids,
aborted_req_ids=self.aborted_req_ids,
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Maybe add a comment to distinguish these two fields with other fields.

Suggested change
finished_req_ids=self.finished_req_ids,
aborted_req_ids=self.aborted_req_ids,
# These two fields are existing states in the scheduler instead of newly scheduled in this step.
finished_req_ids=self.finished_req_ids,
aborted_req_ids=self.aborted_req_ids,

Comment on lines +234 to +255
def abort_requests(self, request_ids: Union[str, Iterable[str]]) -> None:
if isinstance(request_ids, str):
request_ids = (request_ids, )
request_ids = set(request_ids)

# TODO: Optimize this.
for queue in [self.waiting, self.running]:
aborted_reqs: List[Request] = []
for request in queue:
if not request_ids:
break
if request.request_id in request_ids:
request.status = RequestStatus.FINISHED_ABORTED
aborted_reqs.append(request)
request_ids.remove(request.request_id)

for request in aborted_reqs:
queue.remove(request)
self.aborted_req_ids.add(request.request_id)
self._free_request(request)

def stop_requests(self, request_ids: Union[str, Iterable[str]]) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

What are the differences between stop and abort? Can we merge the two functions?

logger = init_logger(__name__)


class KVCacheManager:
Copy link
Member

Choose a reason for hiding this comment

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

Is this the new interface for the block manager? Should we implement prefix caching/hierarchical cache in this class?

@WoosukKwon WoosukKwon closed this Nov 12, 2024
@mergify mergify bot added the frontend label Nov 12, 2024
@WoosukKwon WoosukKwon deleted the re-arch-seq-group branch November 13, 2024 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants