-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Avoid unnecessary multi-modal input data copy when len(batch) == 1 #12722
Avoid unnecessary multi-modal input data copy when len(batch) == 1 #12722
Conversation
Signed-off-by: imkero <[email protected]>
👋 Hi! Thank you for contributing to the vLLM project. 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:
🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for optimizing this! Can you leave a code comment explaining why we need separate logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the optimization!
Sure! I will update it soon. |
Signed-off-by: imkero <[email protected]>
…llm-project#12722) Signed-off-by: imkero <[email protected]> Signed-off-by: Felix Marty <[email protected]>
…llm-project#12722) Signed-off-by: imkero <[email protected]>
…llm-project#12722) Signed-off-by: imkero <[email protected]>
…llm-project#12722) Signed-off-by: imkero <[email protected]>
…llm-project#12722) Signed-off-by: imkero <[email protected]> Signed-off-by: Linkun Chen <[email protected]>
A len=1 multi-modal data batch (
List[torch.Tensor]
) can avoid a copy operation by creating view of original tensor data if possible.len(batch) == 1
thentorch.stack(batch)
->batch[0].unsqueeze(0).contiguous()
torch.concat(batch)
->batch[0].contiguous()
Example code: