Repository navigation
cuda : add grouped experts top-k fusion - #29181
Conversation
|
Seems like a pretty massive change for a not so popular model? is it used elsewhere? Otherwise I would consider this low priority |
Yes, this is used in pretty much all DeepSeek (and derivative) models. |
|
I only used BailingMoE2 because it was what I had handy. Basically any model that defines |
|
Is this used in deepseek4? I remember top-k moe firing for that model |
No, I think they stopped using this in DS4, however top-k moe will fire regardless on all models, this just expands the fusion to incorporate the grouping. |
|
Apart from older deepseek models I see only the Ling models using this |
And all models derived from those, so includes (but not limited to) f.ex. |
|
Yeah those are very 2025, I'll get around to this in a while |
No worries, we've lived with this for almost a year anyway. :) |
I distinctly remember when support for expert grouping was first added and I asked whether it would cause us to lose the speed benefits of fused top-k MoE. Those models are no longer present on my SSD lol. |
A 15% speedup for GLM Air? :) |
Did we have top-k fusion yet at that point? Anyway, fusion was requested. :) #16691 (comment)
Not everyone can be into LLM archaeology. :) |
Unfortunately not, they use |
bc4b088 to
4ffcbaf
Compare
|
@am17an Looks like Reflection's new model is using this. Edit: config.json |
|
Ok, but this code can simplified greatly. Should not required +600 lines |
|
Here is something my agent wrote, can you check if this works for you? |
Works great, with added speedup bonus (updated OP), applied! |
|
Ah, HIP didn't like |
|
@IMbackK |
|
@IMbackK / @thelittlefireman Any concerns for HIP? |
IMbackK
left a comment
There was a problem hiding this comment.
Its fine functionally. Not ideal on warp 64, as usual.
…d instances (has_groups template flag) ggml-org#29181 put the group mask behind a runtime config.n_groups test, so every topk_moe_cuda instance carried it: +30-70 % registers (256 experts 38 -> 56, a 64-byte stack frame with bias) and -2.4 % qwen36 / -1.2 % gemma4 decode on sm_60 in gate R24, with no grouped model running. Assisted-by: Claude Opus 5.5 (Claude Code)
Overview
Add CUDA top-k MoE fusion for grouped experts.
Additional information
This reclaims most of the performance lost by grouping experts.
Requirements