-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
[Kernel] LoRA - Enable CUDAGraphs for V1 #14626
base: main
Are you sure you want to change the base?
[Kernel] LoRA - Enable CUDAGraphs for V1 #14626
Conversation
👋 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 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 🚀 |
Signed-off-by: Varun Sundar Rabindranath <varun@neuralmagic.com>
544b16c
to
f92f3e2
Compare
1, 0) | ||
embeddings_indices = torch.narrow( | ||
self.punica_wrapper._embeddings_indices, 1, 0, x.size(0)) | ||
|
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.
^ changes are to avoid errors such as,
raise ConstraintViolationError(
torch.fx.experimental.symbolic_shapes.ConstraintViolationError: Constraints violated (L['input_ids'].size()[0], L['positions'].size()[0])! For more information, run with TORCH_LOGS="+dynamic".
- Not all values of RelaxedUnspecConstraint(L['input_ids'].size()[0]) are valid because L['input_ids'].size()[0] was inferred to be a constant (8192).
- Not all values of RelaxedUnspecConstraint(L['positions'].size()[0]) are valid because L['positions'].size()[0] was inferred to be a constant (8192).
full_output = self.base_layer.forward( | ||
x.add_(indices * added_tokens_mask)) | ||
full_output = self.base_layer.forward(x + | ||
(indices * added_tokens_mask)) |
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.
x
here is the input_ids. In V1, we don't zero out the cuda graph pad region.
Avoid the in-place update here to prevent accumulating garbage into the input buffer.
vllm_factors.append( | ||
hashlib.md5( | ||
str(self.scheduler_config.max_num_batched_tokens).encode() | ||
).hexdigest()) |
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.
During torch.compile, LoRA static buffers like in
vllm/vllm/lora/punica_wrapper/punica_base.py
Line 133 in 5305673
self._token_lora_indices = torch.empty(max_num_batched_tokens, |
token_lora_mapping = torch.empty(max_num_tokens, |
When max_num_batched_tokens
changes, and when the captured graph is executed, we hit assert_size_stride
asserts on these tensors. As a solution, we simply recompile when max_num_batched_tokens
change.
Enable CUDAGraphs support for V1