-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
[Bugfix] Allocate less memory in non-batched CUTLASS MoE #21121
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
[Bugfix] Allocate less memory in non-batched CUTLASS MoE #21121
Conversation
Signed-off-by: ElizaWszola <ewszola@redhat.com>
👋 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 🚀 |
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.
Code Review
The pull request reduces memory allocation in non-batched CUTLASS MoE by optimizing the calculation of N
in _moe_problem_size()
, leading to smaller workspace sizes. No specific issues were identified requiring immediate attention based on the provided changes and review criteria.
workspace1 = (M * topk, max(2 * N, K)) | ||
workspace2 = (M * topk, N) | ||
workspace1 = (M * topk, max(N, K)) | ||
workspace2 = (M * topk, N // 2) |
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.
Is there a reason why this is the inverse of TritonExperts?
vllm/vllm/model_executor/layers/fused_moe/fused_moe.py
Lines 1623 to 1624 in 9fb2d22
workspace1 = (M, topk, max(N // 2, K)) | |
workspace2 = (M, topk, max(N, K)) |
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.
Looks like the variables are just flipped.
In Triton (workspace13
is the same tensor as workspace1
):
https://github.com/vllm-project/vllm/blob/9fb2d22032cee577a189f8c4cddd88a3c190cb0c/vllm/model_executor/layers/fused_moe/fused_moe.py#L1702C1-L1707C72
The CUTLASS names seem to make more sense given what we assign the resized workspace tensors to
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.
LGTM, thanks Eliza!
Signed-off-by: ElizaWszola <ewszola@redhat.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com> Signed-off-by: WorldExplored <srreyansh.sethi@gmail.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com> Signed-off-by: WorldExplored <srreyansh.sethi@gmail.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com> Signed-off-by: Himanshu Jaju <hj@mistral.ai>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com> Signed-off-by: avigny <47987522+avigny@users.noreply.github.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com> Signed-off-by: x22x22 <wadeking@qq.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com> Signed-off-by: Jinzhen Lin <linjinzhen@hotmail.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com> Signed-off-by: Paul Pak <paulpak58@gmail.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com> Signed-off-by: Diego-Castan <diego.castan@ibm.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com>
…t#21121) Signed-off-by: ElizaWszola <ewszola@redhat.com>
The way we obtain
N
from_moe_problem_size()
caused the function to allocate up to twice as much memory incutlass_moe
'sworkspace_shapes()
as needed. The fix brings down the size of workspaces to what actually reflects the size needed to storecutlass_moe
's intermediate tensors.Testing
Tested for correctness with offline inference for
nm-testing/DeepSeek-Coder-V2-Lite-Instruct-FP8
and