Skip to content

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 <[email protected]>
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 <[email protected]>
@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?

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
@mergify mergify bot removed the needs-rebase label Mar 18, 2025
Signed-off-by: Chenyaaang <[email protected]>
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
Collaborator

@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
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
@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!

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

# 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!

robertgshaw2-redhat and others added 3 commits March 24, 2025 21:17
This reverts commit f7bdb02.

Signed-off-by: Chenyaaang <[email protected]>
@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
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
lk-chen pushed a commit to lk-chen/vllm that referenced this pull request Apr 29, 2025
shreyankg pushed a commit to shreyankg/vllm that referenced this pull request May 3, 2025
RichardoMrMu pushed a commit to RichardoMrMu/vllm that referenced this pull request May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? 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