Repository navigation
cuda: opt-in MoE epilogue fusions (GGML_CUDA_MOE_EP_FUSION) - #423
Merged
Merged
Conversation
Bit 1: fold the per-expert scale gather (REPEAT + GET_ROWS of the down-expert scales by the selected ids) into the weighted reduction kernel, which reads scale_table[ids] directly (same float values) for every expert slot. Bit 2: fuse the router RMS_NORM -> SCALE -> MUL(weight) into one kernel with the same reduction and expression order as the unfused rms_norm kernel, so the result is bit-identical; matched with a subgraph check. GGML_CUDA_MOE_EP_FUSION is a bit mask (1, 2, or 3 for both; default 0: off). GGML_CUDA_MOE_EP_VERIFY=1 compares the bit-1 fusion against the existing fused reduction, =2 against the fully unfused MUL/MUL/VIEW/ADD nodes (default 0: off). The fused router norm kernel follows the reduction path the unfused RMS_NORM takes (scalar, or float4 with one float4 per thread) and is not used for rows wider than that float4 path covers, so it stays bit-identical to the unfused nodes.
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.
What
GGML_CUDA_MOE_EP_FUSION(default 0, off):scale_table[ids]directly;GGML_CUDA_MOE_EP_VERIFY=1|2compares the bit-1 fusion against the existing fused reduction or the fully unfused nodes.Why
How
Testing
GGML_CUDA_MOE_EP_VERIFY1 and 2: 0 mismatches in decode and in 512-token batches.