-
Notifications
You must be signed in to change notification settings - Fork 472
Unify and modularize decode and prefill test. #1375
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
Unify and modularize decode and prefill test. #1375
Conversation
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.
Summary of Changes
Hello @weireweire, 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 significantly refactors and expands the testing infrastructure for the trtllm-gen
backend's attention mechanisms. It unifies the batch prefill and decode attention tests into a single, more modular file, improving maintainability and clarity. A key enhancement is the addition of robust testing for various quantization schemes, including FP8 and FP4, ensuring correct handling of associated scaling factors and offsets.
Highlights
- Test Unification and Modularization: Consolidated
trtllm-gen
batch prefill and decode attention tests into a single new file (tests/test_trtllm_gen_attention.py
), extracting common utility functions to improve code organization and reduce redundancy. - Expanded Quantization Testing: Added comprehensive test coverage for
fp8
andnvfp4
(FP4) data types, specifically verifyingqkvo
scales, output scaling factors (o_sf
), ando_sf
offsets in both prefill and decode operations. - Test File Restructuring: Removed the
tests/test_trtllm_gen_context.py
file and significantly refactoredtests/test_trtllm_gen_decode.py
as their functionalities are now covered by the new unified test suite.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
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 or fill out our survey to provide feedback.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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 unifies decode and prefill attention tests for trtllm-gen by extracting common functions and adding support for fp8/fp4 qkvo scale, o_sf, and o_sf offset tests. To improve robustness and clarity, I've suggested ensuring the q
tensor is contiguous before being passed into the decode function.
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.
Would you mind also updating this script (introduced in #1372 )?
It's better to reuse this test for recently added sink support. please consider the conflict. |
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, thank you @weireweire for the refactor.
It's better to reuse this test for recently added sink support. please consider the conflict.
Yes let's leave that for future work.
We'd better merge this soon, more conflict will coming |
54c9a0f
to
9f8d1ff
Compare
rebased and fixed a prefill blocker. please merge soon, @yzh119 |
flashinfer/prefill.py
Outdated
@@ -2096,7 +2096,8 @@ def run( | |||
lse=lse, | |||
) | |||
else: | |||
assert self._plan_info is not None, "plan info is not initialized" | |||
if self._backend == "cudnn": |
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.
This check is not needed for cudnn. See Line 2073. This is already in else part. I added this since run_args has _plan_info and mypy was complaining.
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.
ok, filter out trtllm-gen check then.
…m-attention-test-unify
…m-attention-test-unify
They are tested in https://github.com/flashinfer-ai/flashinfer/blob/main/tests/test_attention_sink.py and https://github.com/flashinfer-ai/flashinfer/blob/main/tests/test_attention_sink_blackwell.py, we can unify them later. |
📌 Description
Unify decode and prefill attention test for trtllm-gen by extract common function. Support fp8/fp4 qkvo scale, o_sf, o_sf offset test.
🔍 Related Issues
🚀 Pull Request Checklist
Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.
✅ Pre-commit Checks
pre-commit
by runningpip install pre-commit
(or used your preferred method).pre-commit install
.pre-commit run --all-files
and fixed any reported issues.🧪 Tests
unittest
, etc.).Reviewer Notes