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

[v1] Refactor KVCacheManager for more hash input than token ids #10507

Merged
merged 8 commits into from
Nov 22, 2024

Conversation

rickyyx
Copy link
Contributor

@rickyyx rickyyx commented Nov 21, 2024

This PR refactors the KVCacheManager such that:

  1. It will be easier to pass in more metadata for hashing (e.g. lora id, mm_hash and etc)
  2. Remove the needed of tracking token ids inside a block (which was used for hash calculation, but no longer needed since hash is assigned to a block).

Benchmarking

Running the below on main and the PR shows no diff on performance.

VLLM_USE_V1=1 python3 benchmarks/benchmark_prefix_caching.py \
--model meta-llama/Meta-Llama-3-8B-Instruct  \
--num-prompts 50 \
--input-length-range 500:500  \
--prefix-len 250     --seed 0 --output-len 500

Copy link

👋 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.

🚀

tests/v1/core/test_prefix_caching.py Show resolved Hide resolved
vllm/v1/core/kv_cache_manager.py Outdated Show resolved Hide resolved
@rickyyx rickyyx marked this pull request as draft November 21, 2024 01:21
vllm/v1/core/kv_cache_manager.py Outdated Show resolved Hide resolved
vllm/v1/core/kv_cache_manager.py Outdated Show resolved Hide resolved
vllm/v1/core/kv_cache_manager.py Outdated Show resolved Hide resolved
tests/v1/core/test_prefix_caching.py Show resolved Hide resolved
@rickyyx rickyyx marked this pull request as ready for review November 21, 2024 23:22
@rickyyx rickyyx changed the title [WIP][v1] Refactor KVCacheManager for more hash input than token ids [v1] Refactor KVCacheManager for more hash input than token ids Nov 21, 2024
vllm/v1/core/kv_cache_manager.py Outdated Show resolved Hide resolved
vllm/v1/core/kv_cache_manager.py Outdated Show resolved Hide resolved
vllm/v1/core/kv_cache_manager.py Outdated Show resolved Hide resolved
@comaniac comaniac added the ready ONLY add when PR is ready to merge/full CI is needed label Nov 22, 2024
@comaniac comaniac force-pushed the pr-v1-prefix-hash-cal branch from c2bfbd5 to 2986dab Compare November 22, 2024 18:07
Copy link
Collaborator

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

LGTM. Great job!

vllm/v1/core/kv_cache_manager.py Outdated Show resolved Hide resolved
@comaniac comaniac enabled auto-merge (squash) November 22, 2024 18:37
rickyyx and others added 8 commits November 22, 2024 20:26
Signed-off-by: rickyx <[email protected]>
Signed-off-by: rickyx <[email protected]>
Signed-off-by: rickyx <[email protected]>
Signed-off-by: rickyx <[email protected]>
Signed-off-by: rickyx <[email protected]>
Signed-off-by: rickyx <[email protected]>
Signed-off-by: rickyx <[email protected]>
Signed-off-by: Cody Yu <[email protected]>
@comaniac comaniac force-pushed the pr-v1-prefix-hash-cal branch from 2986dab to dcae02e Compare November 22, 2024 20:26
@comaniac comaniac merged commit 97814fb into vllm-project:main Nov 22, 2024
47 checks passed
tlrmchlsmth pushed a commit to neuralmagic/vllm that referenced this pull request Nov 23, 2024
…-project#10507)

Signed-off-by: rickyx <[email protected]>
Signed-off-by: Cody Yu <[email protected]>
Co-authored-by: Cody Yu <[email protected]>
Signed-off-by: Tyler Michael Smith <[email protected]>
mfournioux pushed a commit to mfournioux/vllm that referenced this pull request Nov 28, 2024
…-project#10507)

Signed-off-by: rickyx <[email protected]>
Signed-off-by: Cody Yu <[email protected]>
Co-authored-by: Cody Yu <[email protected]>
Signed-off-by: Maxime Fournioux <[email protected]>
sleepwalker2017 pushed a commit to sleepwalker2017/vllm that referenced this pull request Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants