mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2835] [CLOSED] prefill: the prompt path's MMQ scratch rides in the loan (opt-in, STRATA_MMQ_SLAB) #4292
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#4292
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/2835
Author: @gopinath87607
Created: 10/17/2026
Status: ❌ Closed
Base:
main← Head:mmq-slab-loan-tail📝 Commits (1)
a177944prefill: the prompt path's MMQ scratch rides in the loan (opt-in, STRATA_MMQ_SLAB)📊 Changes
5 files changed (+170 additions, -9 deletions)
View changed files
📝
docs/DETAILS.md(+18 -0)📝
include/strata/prefill/moe_mmq.hpp(+7 -0)📝
src/prefill/ggml_cuda_host.cu(+88 -9)📝
src/prefill/moe_mmq.cu(+5 -0)📝
src/prefill/prefill.cpp(+52 -0)📄 Description
What this changes
STRATA_MMQ_SLAB=1(opt-in; unset is off): the prompt path's MMQ scratch — its stream-k fixup tiles — comes out ofthe loan's unused tail instead of free VRAM.
llama.cpp's
mmq.cuhallocates those tiles lazily throughggml_cuda_pool, which this build backs with acudaMallocon whatever is free at that moment — a few MB on a card the expert cache has filled, at the one moment a prompt is
running, and a malloc that fails there aborts the engine mid-read instead of failing the request. A layout does not
use the whole loan: the carve is a bump, so everything from its stop to the loan's end is the prompt's own memory,
provably (a loan is whole cache slots and the top one is only partly needed).
The pool takes the tiles from there in size classes (a power of two, 128 KiB floor). The classes are load-bearing:
MMQ's J search picks a different J per launch, so a cache keyed on the exact size holds one buffer per J — 32 buffers,
31.5 MiB on a 579-token chunk in the Maya checkout's measurement — where a class bounds the pool to a few MB.
Three guards make it safe, all load-bearing: it is published per layout keyed on the tail's address (a request
whose chunk moves
usedmoves the tail and the pool drops the old buffers);Prefill::rundrops it once the prompt isread, before the caller refills the borrowed slots; and the loan is the participant's own expert cache
cudaMallocedon this device, so the tail is this card's memory to write. A tail that is empty (the layout used the whole loan, or
spilled into owned buffers) publishes nothing, and the pool allocates as it always did.
From the Maya checkout (
project-maya), local commitbf844d5.What it leaves alone
Unset (the default), the pool stays on free VRAM exactly as before:
lend_mmq_scratchpublishes nothing andmmq::pool_slabis not given a slab. The size classes are part of the slab path only (they bound the slab's pool);with the knob off there is no slab to bound. Default path unchanged by construction.
Measurements
the slab costing 42–47 more lent experts per part and no change to the chunk arithmetic, on its live split
(5060/5060/3060/3060).
Checks
v != nullptr && std::atoi(v) != 0).src/prefill/prefill.cppcompiles clean with the build's own flags (-fsyntax-only);src/prefill/ggml_cuda_host.cuandsrc/prefill/moe_moe.cucompile clean with the build's nvcc flags (CUDA 13.2,compute_86andcompute_120). The development branch that also carries the change built fully with ninja.target's; the slab plumbing in
prefill.cpphas no per-backend branch.strata prefill mmq: CUDA%d the scratch pool takes a new N MiB bufferprints for a buffer of 4 MiBor more; with
STRATA_MMQ_SLAB=1and a loan that has a tail it should not appear at all, and a prompt should readto completion as before.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.