-
Notifications
You must be signed in to change notification settings - Fork 531
feat: trtrllm-gen global scaled FP8 GEMMs #1829
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @hypdeb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces highly optimized FP8 GEMM kernels tailored for low-latency, memory-bandwidth-bound operations, particularly beneficial for scenarios involving small batch sizes in large language models. The implementation includes a new C++ CUDA runner, a Python interface, and integrates these 'flavored' GEMMs with the existing autotuning framework. The changes aim to significantly improve performance by leveraging specialized weight tensor layouts and efficient kernel selection, with initial benchmarks demonstrating substantial TFLOPs/s and bandwidth utilization. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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
This pull request introduces a new "flavored" GEMM implementation optimized for small batch sizes using FP8, which is a valuable performance enhancement. The changes include a new C++ CUDA runner, a Python interface with autotuning support, and corresponding benchmarks and tests.
The code is well-structured, and the refactoring of the autotuner and utility functions improves code quality. I have a few suggestions to enhance maintainability and clarity:
- Address a
FIXME
comment and code duplication in the C++ runner. - Clarify the data flow of the
workspace_buffer
in the Python interface. - Improve docstrings for better user understanding.
- Avoid shadowing Python built-ins in variable names.
Overall, this is a solid contribution. Addressing these points will make the code even better.
3e3dc6c
to
25abf20
Compare
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.
Another request, can we add gen_trtllm_low_latency_gemm_module
to https://github.com/flashinfer-ai/flashinfer/blob/main/flashinfer/aot.py, so that the pre-built jit-cache will include this module.
35f268f
to
a4e8f34
Compare
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.
Overall LGTM, ping @aleozlx for another review on hardware compatibility.
…m_low_latency_gemm
/bot run |
/bot run |
@hypdeb is not authorized to trigger this CI job. cc: @yzh119, @sricketts, @yongwww |
In low latency context, it is not uncommon to encounter memory bandwidth bound GEMMs with a tiny leading dimension M. These cases are currently not addressed as efficiently as they could by library implementations. To fill this gap, I propose to expose generated GEMM kernels optimized for small batch sizes, which saturate memory bandwidth to a higher degree.
The main challenge in doing so is that these GEMMs expect the weight tensor (second operand) to be pre-processed into a layout more amenable to maximizing memory bandwidth saturation. As such it is not practical to expose them under the same API as the other GEMMs, as they are not interchangeable without changing the caller's implementation. I have tentatively exposed these GEMMs as "flavored" GEMMs, by contrast with the more "vanilla" GEMMs currently available.
Summary of the changes:
csrc/trtllm_flavored_gemm_runner.cu
flashinfer/trtllm_flavored_gemm.py
file containing the Python interface of the new GEMMsfp8_utils.py
as the implementations ofto_fp8
differ between the places I extracted it forNext step:
I will add more kernels for larger batch sizes. This is required because the weight matrix shuffling commits the user to this interface. Therefore, they also need efficient kernels for larger batches, which they will encounter for prefills for example, when not doing disagg.
Benchmarking results on GB200: