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] get_computed_blocks avoids recompute #10695

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Abatom
Copy link
Contributor

@Abatom Abatom commented Nov 27, 2024

Use self.req_to_blocks[request.request_id] instead of recompute.

Signed-off-by: Abatom <[email protected]>
Signed-off-by: Abatom <[email protected]>
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.

🚀

@comaniac
Copy link
Collaborator

I don't think this is correct. In this way you only share the blocks within a request.

@Abatom
Copy link
Contributor Author

Abatom commented Nov 27, 2024

@comaniac Thank you, I will think about it again.

@Abatom
Copy link
Contributor Author

Abatom commented Nov 27, 2024

@comaniac I have drawn a diagram to illustrate my modifications. I believe that the cache is not fully shared within a request.
kvcache

Signed-off-by: Abatom <[email protected]>
@comaniac
Copy link
Collaborator

What I'm saying is you change makes blocks cannot be shared "across" requests.

@Abatom
Copy link
Contributor Author

Abatom commented Nov 27, 2024

@comaniac
I think the orange blocks in the picture are shared across requests.

The green blocks have already been calculated,so there's no need to calculate them again,this is where the optimization comes in.

@comaniac
Copy link
Collaborator

How do you hit cached blocks for a new request, which hasn't been added to req_to_blocks[request.request_id]?

@comaniac
Copy link
Collaborator

Ok I see what you meant. Yes this saves hash computation, but I'm afraid that this makes the code complicate. Did you have benchmark numbers to show the overhead is negligible so we have to introduce this optimization?

@Abatom
Copy link
Contributor Author

Abatom commented Nov 27, 2024

Alright, I'll think about how to conduct benchmark testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants