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

[Core] Performance optimization for swap_blocks by cuda kernels #11531

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

Conversation

ApostaC
Copy link

@ApostaC ApostaC commented Dec 26, 2024

This PR is part of the big CPU offloading PR #10874 -- this PR contains the new CUDA kernel implementation for swap_blocks.

Performance benchmark

The numbers are collected on A100-40GB-SXM GPUs

# of pages New implementation Old implementation
Swap in 1 page 1.21 GB / second 1.21 GB / second
Swap in 1250 pages 12.6 GB / second 3.11 GB / second
Swap out 1 page 1.22 GB / second 1.21 GB / second
Swap out 1250 pages 12.5 GB / second 3.12 GB / seocond

Notes: CUDA graph compatibility

Currently, it pre-allocates a CPU pin-memory tensor for the blocks_to_swap_in and blocks_to_swap_out. It could support CUDA graphs in the future since the address of the pre-allocated buffer won't change.

I did not include it in the PR currently, and as a next step, I can create a new PR for CUDA graphs.

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.

🚀

Signed-off-by: ApostaC <[email protected]>
@ApostaC ApostaC marked this pull request as ready for review December 26, 2024 23:11
@ApostaC ApostaC changed the title [Draft, core] Performance optimization for swap_blocks by cuda kernels [Core] Performance optimization for swap_blocks by cuda kernels Dec 26, 2024
@KuntaiDu KuntaiDu added the ready ONLY add when PR is ready to merge/full CI is needed label Dec 27, 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