-
Notifications
You must be signed in to change notification settings - Fork 5.6k
[NVIDIA] [GDN] Add FlashInfer prefill support for SM100+ (Blackwell) #22921
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
Open
kaixih
wants to merge
3
commits into
sgl-project:main
Choose a base branch
from
kaixih:add_flashinfer_gdn_prefill
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
test/registered/4-gpu-models/test_qwen35_fp4_flashinfer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import unittest | ||
|
|
||
| import torch | ||
|
|
||
| from sglang.test.accuracy_test_runner import AccuracyTestParams | ||
| from sglang.test.ci.ci_register import register_cuda_ci | ||
| from sglang.test.run_combined_tests import run_combined_tests | ||
| from sglang.test.test_utils import ( | ||
| CustomTestCase, | ||
| ModelLaunchSettings, | ||
| ) | ||
|
|
||
| register_cuda_ci(est_time=720, suite="stage-c-test-4-gpu-b200") | ||
|
|
||
| QWEN35_FP4_MODEL = "nvidia/Qwen3.5-397B-A17B-NVFP4" | ||
| ACC_THRESHOLDS = {QWEN35_FP4_MODEL: {"gsm8k": 0.95}} | ||
|
|
||
| _is_sm100_cuda13 = ( | ||
| torch.cuda.is_available() | ||
| and torch.cuda.get_device_capability()[0] >= 10 | ||
| and int(torch.version.cuda.split(".")[0]) >= 13 | ||
| ) | ||
|
|
||
|
|
||
| @unittest.skipUnless(_is_sm100_cuda13, "requires SM100+ GPU and CUDA 13+") | ||
| class TestQwen35FP4FlashInfer(CustomTestCase): | ||
| def test_gsm8k(self): | ||
| base_args = [ | ||
| "--tp-size", | ||
| "4", | ||
| "--chunked-prefill-size", | ||
| "2048", | ||
| "--mamba-scheduler-strategy", | ||
| "extra_buffer", | ||
| "--mamba-track-interval", | ||
| "128", | ||
| "--mamba-ssm-dtype", | ||
| "bfloat16", | ||
| "--max-running-requests", | ||
| "128", | ||
| "--reasoning-parser", | ||
| "qwen3", | ||
| "--attention-backend", | ||
| "trtllm_mha", | ||
| "--quantization", | ||
| "modelopt_fp4", | ||
| "--model-loader-extra-config", | ||
| '{"enable_multithread_load": true,"num_threads": 64}', | ||
| "--linear-attn-decode-backend", | ||
| "flashinfer", | ||
| "--linear-attn-prefill-backend", | ||
| "flashinfer", | ||
| ] | ||
|
|
||
| variants = [ | ||
| ModelLaunchSettings( | ||
| QWEN35_FP4_MODEL, | ||
| extra_args=base_args, | ||
| variant="FlashInfer", | ||
| ), | ||
| ] | ||
|
|
||
| run_combined_tests( | ||
| models=variants, | ||
| test_name="Qwen3.5-397B-A17B-NVFP4", | ||
| accuracy_params=AccuracyTestParams( | ||
| dataset="gsm8k", | ||
| baseline_accuracy=ACC_THRESHOLDS[QWEN35_FP4_MODEL]["gsm8k"], | ||
| num_examples=200, | ||
| num_threads=128, | ||
| max_tokens=16000, | ||
| thinking_mode="qwen3", | ||
| temperature=0.6, | ||
| top_p=0.95, | ||
| top_k=20, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
We'd better add bf16 state dtype validation for SM100+ FlashInfer prefill backend, just like how SM100+ FlashInfer decode backend does:
Otherwise, the user can then run SM100+ FlashInfer prefill with float32 state, which is unsupported (the module docstring states "SM100+: decode and prefill with bf16 state"), likely causing kernel errors or incorrect results at runtime.
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.
the flashinfer prefill kernel actually supports the fp32. so the current status from flashinfer:
Note, here I am talking about the "fast" kernels that we recommended for the blackwell (there are some "legacy" kernels that are not the focus of this PR).
So, the below is what is going to happen with the current code: