mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1822] [CLOSED] prefill: gate/up MMQ reads the experts in place (CUDA; patched copy of llama.cpp mmq.cuh) #3699
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3699
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1822
Author: @xrip
Created: 10/10/2026
Status: ❌ Closed
Base:
main← Head:pr/mmq-inplace📝 Commits (1)
9166e5aprefill: gate/up MMQ reads the experts in place (patched llama.cpp mmq.cuh)📊 Changes
4 files changed (+111 additions, -8 deletions)
View changed files
📝
CMakeLists.txt(+38 -2)📝
include/strata/prefill/moe_mmq.hpp(+8 -0)📝
src/prefill/moe_mmq.cu(+30 -3)📝
src/prefill/prefill.cpp(+35 -3)📄 Description
What
CUDA builds, native i-quant packs, prompt path: the gate/up MMQ product reads each expert's weights where they
already are (expert cache slot or stream ring slot) instead of copying them into a group buffer first. Same bytes into
the same kernel, so the same results.
STRATA_MMQ_INPLACE=0turns it off. HIP builds keep the old path.Why
Before MMQ, the prompt path copied every routed expert's gate/up and down rows into a contiguous group buffer,
resident experts included. An expert blob is already "gate rows then up rows", the exact matrix MMQ wants, so the
gate/up copy is only there because MMQ takes one base pointer and a fixed stride.
Change
mmq.cuhinto the build tree with one change in itsthree tile loops: a negative expert stride means
xis a table of expert pointers. The MMQ instance files (and theheaders that include
mmq.cuh) compile against that copy. Configure stops if the patched text is not found exactlythree times (a different llama.cpp). The changed lines are inside kernel templates, so
quantize.cu, which seesthe original header, is unaffected.
m.grp_ptrs, written on thestream by
group_ptrs). The group's ring slots are released after the gate/up MMQ instead of after the gather.the zeroed tail (
MMQ_TAIL), not the next cache slot.Measured
2x CMP 50HX (sm_75), Flash-Next IQ3_XXS,
--layer-split auto, one +4.4K-token prompt at 140K context (nsys):copy16_group_kernel, GPU 0copy16_group_kernel, GPU 1mul_mat_qA coding-agent session from 34K to 190K tokens (36 turns) gave word-for-word the same text as before.
The gain on this box is small because it is PCIe Gen2 and the second GPU waits on PCIe; a card where the copies are
a bigger part of the prompt should gain more, but that was not measured.
Note: measured on a fork based on 0.1.38. The patch applies to current
mainwithout changes; re-measuring on 0.1.41is still to do. Only sm_75 was tested.
How to check
Build (configure must pass the patch check), then compare a prompt's output and read time with
STRATA_MMQ_INPLACE=0and without it: the output should be the same.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.