-
Notifications
You must be signed in to change notification settings - Fork 752
feat: KVBM improved external block matching #1714
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,19 +117,22 @@ def get_offloaded_computed_blocks( | |
|
|
||
| sequence_hashes = self._create_slot(request) | ||
|
|
||
| host_owned_blocks, disk_owned_blocks = self.cache_manager.get_offloaded_computed_blocks(sequence_hashes) | ||
| remaining_sequence_hashes = sequence_hashes[num_computed_tokens // self.block_size:] | ||
|
|
||
| host_owned_blocks, disk_owned_blocks = self.cache_manager.get_offloaded_computed_blocks(remaining_sequence_hashes) | ||
| host_block_count = host_owned_blocks.block_count() | ||
| disk_block_count = disk_owned_blocks.block_count() | ||
|
|
||
| num_host_computed_tokens = host_block_count * self.block_size | ||
| num_disk_computed_tokens = disk_block_count * self.block_size | ||
|
|
||
| num_external_hit_tokens = max(num_disk_computed_tokens, num_host_computed_tokens) | ||
| num_external_hit_tokens = num_host_computed_tokens + num_disk_computed_tokens | ||
|
|
||
| need_to_allocate = num_external_hit_tokens | ||
|
|
||
| need_to_allocate = num_external_hit_tokens - num_computed_tokens | ||
|
|
||
| # In a full-prompt-hit case, we need to recompute the last token | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just curious: Why do we need to recompute the last token if a full-prompt is hit?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I learned from https://github.com/LMCache/LMCache/blob/dev/lmcache/integration/vllm/vllm_v1_adapter.py#L832 essentially, to generate the next token, we need not only the kv cache, but logits. so we need to let vllm re-computes the last token
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation. Would you mind adding your explanation as part of the comment? |
||
| if num_external_hit_tokens == request.num_tokens: | ||
| if num_computed_tokens + num_external_hit_tokens == request.num_tokens: | ||
| need_to_allocate -= 1 | ||
|
|
||
| # TODO: add stats for offloaded computed tokens | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am new to the team, do you know why my dynamo workspace doesn't have lib/bindings/python/src/dynamo/llm/vllm_integration/kv_cache_manager.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you on the right branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is because kvbm related python bindings like you pointed is not in main/release branch yet. only exist in our private branch. we will merge to main once ready
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.