Repository navigation
CUDA: fuse ffn_gate + glu into the mul_mat_q epilogue - #27341
Closed
akaanupkumar wants to merge 1 commit into
Closed
akaanupkumar wants to merge 1 commit into
akaanupkumar wants to merge 1 commit into
Conversation
lexasub
reviewed
Aug 19, 2026
|
|
||
| dst[j*stride_col_dst + i] += sum[j0/nwarps]; | ||
| const int idx = j*stride_col_dst + i; | ||
| if (glu_up_tile) { |
There was a problem hiding this comment.
may be additionaly constexpr has_fusion (for filter in compile time)
Contributor
|
#28702 PR will take care of this fusion |
4 tasks done
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
Fuse the FFN gate + SwiGLU/GEGLU into the mul_mat_q write-back epilogue. llama.cpp already fuses this pattern for decode (mul_mat_vec_q). This closes that gap for MMQ. The gate matmul keeps its result in registers and applies silu/gelu(gate) * up in the epilogue, so the gate tensor avoids round-trips through DRAM.
The scope of this PR is currently limited to Q4_K, NVIDIA MMA (Turing+), FFN, prefill, SWIGLU/GEGLU.
Additional information
Performance data with RTX 5090 (Blackwell) ( CUDA 13.3, -ngl 999 -fa 1 -r 10, clocks locked 2227/14001 MHz )
llama.cpp defaults (n_batch 2048, n_ubatch 512)
Microbatch 4096(-b 4096 -ub 4096)
Requirements