Repository navigation
[Perf] qwen3: Fuse SiLU*mul with the NVFP4 quantization of down_proj in Qwen2MLP #44491
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
Merged
BBuf
merged 4 commits into
sgl-project:main
from
gkswns0531:perf/qwen3-silu-fp4-quant-fusion
Nov 5, 2026
+205
−63
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
644c16f
[Model] Fuse SiLU*mul with the NVFP4 quantization of down_proj in Qwe…
gkswns0531 f5c2129
[Model] Keep the SiLU+FP4 fusion off on the Marlin FP4 backend
gkswns0531 47dcb3e
[Model] Keep the SiLU+FP4 fusion off when K is not a multiple of 64
gkswns0531 8b51234
[Model] Read the SiLU+FP4 fusion kill switch through envs
gkswns0531 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
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
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
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.
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.
[BBuf Review Agent] Qwen3 NVFP4 with
--fp4-gemm-backend marlinnow sends an FP4 tuple toapply_fp4_marlin_linear, which requires a floating-point tensor, so the first forward crashes. Could we exclude Marlin in the shared enabling check and cover this MLP handoff?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.
@BBuf
Thanks!
On SM80-SM90
autoalso picks Marlin, so this would have broken the default path there. f5c2129 keeps the fusion off on the Marlin backend. Qwen3.5's dense MLP uses the same check, so it's covered too, andtest_stays_off_for_the_marlin_backendfails without the change.Checked with Qwen3-Reranker NVFP4 checkpoints:
autopicks Marlin): the previous head failed on the first forward. Greedy outputs and logprobs now match main exactly (0.6B and 4B).--fp4-gemm-backend marlin: the previous head failed with'tuple' object has no attribute 'dtype'. It now serves normally.While re-checking the handoff I found one more case. When down_proj's K is not a multiple of 64, the FP4 scales are padded, and the fused kernel leaves the padding unwritten (fp4_quantize zeroes it). In a kernel test with K = 1376 and 608, a NaN byte left there turned the whole GEMM output into NaN. 47dcb3e keeps the fusion off for such K; every Qwen3 size at TP <= 8 is a multiple of 64. 8b51234 moves the kill switch into
Envsand logs the enable message once.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.
[BBuf Review Agent] The shared guard now excludes Marlin for both Qwen3 and Qwen3.5, and the regression test covers that check. This addresses the tuple handoff crash.