Skip to content
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

Add fused top-K softmax kernel for MoE #2769

Merged
merged 42 commits into from
Feb 6, 2024
Merged

Add fused top-K softmax kernel for MoE #2769

merged 42 commits into from
Feb 6, 2024

Conversation

WoosukKwon
Copy link
Collaborator

@WoosukKwon WoosukKwon commented Feb 5, 2024

This PR ports a fused topk-softmax kernel from TensorRT-LLM v0.7.1.

TODO:

  1. Port more MoE-related kernels
  2. Use CUTLASS-based grouped GEMM kernels with appropriate tuning (if they perform better than the current Triton kernel).

@WoosukKwon
Copy link
Collaborator Author

@Yard1 @cadedaniel @pcmoritz Can any one of you review the PR?

@pcmoritz
Copy link
Collaborator

pcmoritz commented Feb 5, 2024

Yes, happy to review! Thanks a lot for writing this :)

@WoosukKwon
Copy link
Collaborator Author

@pcmoritz Thanks!

@pcmoritz
Copy link
Collaborator

pcmoritz commented Feb 5, 2024

Btw, I did a little bit of benchmarking on this PR and without touching any of the system parameters in the PR I'm already seeing a 1.5% - 3.5% end-to-end latency improvement. It is higher in the low latency regime. Concretely I tested on TP2 on H100 with 1000 input and 50 output tokens on Mixtral. So it seems worth merging this even though the low-level kernel code is not easy to follow -- most people can probably just treat it as a black box so it shouldn't have a big impact on maintainability.

Copy link
Collaborator

@pcmoritz pcmoritz left a comment

Choose a reason for hiding this comment

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

I will spend some more time trying to understand the implementation in topk_softmax_kernels.cu but no need to block on that since that's mostly the upstream code from https://github.com/NVIDIA/TensorRT-LLM/blob/v0.7.1/cpp/tensorrt_llm/kernels/mixtureOfExperts/moe_kernels.cu and in any case we should probably keep it close to that and not change it :)

tests/kernels/test_moe.py Outdated Show resolved Hide resolved
@WoosukKwon
Copy link
Collaborator Author

@pcmoritz Thanks again for you review! Yes, I think we don't have to worry too much about the implementation details, at least at the moment, as I only made a minor change to the kernel.

@pcmoritz
Copy link
Collaborator

pcmoritz commented Feb 6, 2024

Sounds good, the PR looks great :)

@WoosukKwon WoosukKwon merged commit f0d4e14 into main Feb 6, 2024
17 checks passed
@WoosukKwon WoosukKwon deleted the topk-softmax branch February 6, 2024 01:38
hongxiayang pushed a commit to hongxiayang/vllm that referenced this pull request Feb 13, 2024
alexm-neuralmagic pushed a commit to neuralmagic/nm-vllm that referenced this pull request Feb 13, 2024
jvmncs pushed a commit to jvmncs/vllm that referenced this pull request Feb 14, 2024
xjpang pushed a commit to xjpang/vllm that referenced this pull request Feb 20, 2024
xjpang pushed a commit to xjpang/vllm that referenced this pull request Feb 22, 2024
xjpang pushed a commit to xjpang/vllm that referenced this pull request Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants