Skip to content

[core] add bucket padding to tpu_model_runner #14995

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No 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? No Sign in to your account

Merged
merged 23 commits into from
Mar 25, 2025

Conversation

Chenyaaang
Copy link
Contributor

@Chenyaaang Chenyaaang commented Mar 18, 2025

Add bucket padding to tpu, instead of padding to the power of 2, if num_token < bucket_padding_gap, pad to the nearest power of 2, if num_token > bucket_padding_gap, the padding size is increased by bucket_padding_gap.
For example, bucket_padding_gap = 64, max_num_batch_tokens = 512, then the paddings will be 16, 32, 64, 128, 192, 256, 320, 384, 448, 512. This helps reduce the computation cost for large num_tokens, e.g. num_tokens = 300, instead of padding to 512, now pad to 320.

FIX #14581

Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

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 either: Add ready label to the PR or enable auto-merge.

🚀

Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
@yaochengji
Copy link
Collaborator

@Chenyaaang Thanks for your contribution, left some comments above!

@robertgshaw2-redhat I know there's another configuration option cudagraph_capture_sizes, which is similar to bucket_padding_gap in this PR, do you think we should merge them into one, and has default value for different platform?

Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
Copy link

mergify bot commented Mar 18, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @Chenyaaang.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Mar 18, 2025
Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
@mergify mergify bot removed the needs-rebase label Mar 18, 2025
Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
Copy link
Collaborator

@alexm-redhat alexm-redhat left a comment

Choose a reason for hiding this comment

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

Good idea!

@alexm-redhat alexm-redhat enabled auto-merge (squash) March 19, 2025 21:09
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Mar 19, 2025
@DarkLight1337
Copy link
Member

Please fix the merge conflict

Copy link
Contributor

@NickLucche NickLucche left a comment

Choose a reason for hiding this comment

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

looks good! Also in favor of unifying with cudagraph_capture_sizes

Copy link

mergify bot commented Mar 20, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @Chenyaaang.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Mar 20, 2025
Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
auto-merge was automatically disabled March 20, 2025 17:22

Head branch was pushed to by a user without write access

@mergify mergify bot removed the needs-rebase label Mar 20, 2025
@Chenyaaang
Copy link
Contributor Author

Do you think that we should allow the user to specify this? I would think that we should try to keep this internal unless there is a strong reason why someone would toggle this?

I think the param is useful for online serving, by exposing this parameter, users can adjust the gap based on the model size. My understanding is for example the gap is small then it will lead to a long pre-compile time, that's something customer can adjust.

@robertgshaw2-redhat
Copy link
Collaborator

This PR seems to have broken CUDA

@alexm-redhat
Copy link
Collaborator

@Chenyaaang thanks for reducing the padding gap, this is useful. Could you please address @robertgshaw2-redhat comment and fix the build (so we can merge it). Thanks!

Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
@Chenyaaang
Copy link
Contributor Author

@Chenyaaang thanks for reducing the padding gap, this is useful. Could you please address @robertgshaw2-redhat comment and fix the build (so we can merge it). Thanks!

I've fixed the build and replied to @robertgshaw2-redhat's comment.

Chenyaaang and others added 5 commits March 24, 2025 11:01
Signed-off-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
Signed-off-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
Signed-off-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
# Check we have 4 compiled codes
assert len(compiled_codes) == 4
# Check we have 3 compiled codes
assert len(compiled_codes) == 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Chenyaaang Thanks for looking into this! Could we branch out for v0 and v1? In v0 it should be 4 compiled code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks!

Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
robertgshaw2-redhat and others added 3 commits March 24, 2025 21:17
Signed-off-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
This reverts commit 7d92244.

Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
This reverts commit f7bdb02.

Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
@robertgshaw2-redhat robertgshaw2-redhat enabled auto-merge (squash) March 25, 2025 21:25
@robertgshaw2-redhat robertgshaw2-redhat merged commit ac3cd6e into vllm-project:main Mar 25, 2025
33 checks passed
wrmedford pushed a commit to wrmedford/vllm that referenced this pull request Mar 26, 2025
Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
Signed-off-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
Co-authored-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
Signed-off-by: Wes Medford <wryanmedford@gmail.com>
lengrongfu pushed a commit to lengrongfu/vllm that referenced this pull request Apr 2, 2025
Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
Signed-off-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
Co-authored-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
Signed-off-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
Co-authored-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
Signed-off-by: Louis Ulmer <ulmerlouis@gmail.com>
nishith-fujitsu pushed a commit to nishith-fujitsu/vllm that referenced this pull request Apr 9, 2025
Signed-off-by: Chenyaaang <llccyy1212@gmail.com>
Signed-off-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
Co-authored-by: rshaw@neuralmagic.com <robertgshaw2@gmail.com>
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
ci/build ready ONLY add when PR is ready to merge/full CI is needed v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature][Hardware][TPU]: Improve the token_num padding logic
8 participants