mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #242] [CLOSED] glm prefill: the prompt path's MMQ scratch rides in the loan (a 16 MB size-class slab) - the 16k-chunk out-of-memory that killed every prompt is gone #418
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#418
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/mw00/project-maya/pull/242
Author: @gopinath87607
Created: 10/17/2026
Status: ❌ Closed
Base:
main← Head:pr/mmq-slab📝 Commits (1)
9825ca0glm prefill: the prompt path's MMQ scratch rides in the loan (mmq::pool_slab + size classes), and the pool is sized knowing it - the abort that killed every prompt at a 16k chunk ("ggml-cuda (strata mmq): out of memory", CUDA1, mid-prompt) is gone📊 Changes
8 files changed (+265 additions, -21 deletions)
View changed files
📝
docs/SETTINGS.md(+1 -0)📝
include/strata/core/glm_model.hpp(+1 -0)📝
include/strata/prefill/moe_mmq.hpp(+6 -0)📝
src/core/glm_fast_path.cu(+28 -0)📝
src/core/glm_fast_state.hpp(+3 -0)📝
src/core/glm_prefill.cu(+135 -12)📝
src/prefill/ggml_cuda_host.cu(+87 -9)📝
src/prefill/moe_mmq.cu(+4 -0)📄 Description
What this changes
The prompt path's MMQ kernels (llama.cpp's
mmq.cuh) allocate their stream-k fixup tiles lazily throughggml_cuda_pool, which this build'sggml_cuda_host.cubacks with aCachingPoolthatcudaMallocs on demand - on whatever VRAM is free at that moment, which by the time a chunk runs is the card's leftovers. At a 16,384-token chunk that was 3.4 MB free of 7,707.7 MB on CUDA1, and the fixup buffer it wanted (1.2 MB) did not fit:ggml_cuda_erroraborted the engine, so every prompt died mid-run and took the server's engine with it.Three changes, all in that path:
Jrange on a 30-SM card) and hands back the class size, and the reuse scan is restored.mmq.cuhpicks a differentJper launch; keyed on the exact size, the pool held one buffer perJ- 32 buffers, 31.5 MB measured within one 579-token chunk, and the same at 16k, sinceJdoes not grow withT. A class is what a caching allocator is for, and it bounds the pool to a few MB whateverJwins.prefill_lendraises the lending limit bykMmqSlab(16 MB, a bound - the fixup buffer is at mostnsm * J * I * 4= ~2 MB, independent of the chunk size) and hands[need, need + 16 MB)of the freed tail to the pool (mmq::pool_slab, called per chunk since the layout's need moves withT, and cleared whenprefill_returngives the region back). Every byte lies in a slot whose start is below the limit, so it is provably lent; it costs a few more experts per part (measured: 42 CUDA0, 44 CUDA1, 46 CUDA2, 47 CUDA3, printed once per part) and no change to the chunk arithmetic.F->lend_end, recorded bylend_tail, marks where the loan ends.fast_setupsizes the expert pool from free VRAM and did not know the prompt path keeps a scratch pool, soSTRATA_GLM_MMQ_RESERVE_MB(default 0: the slab covers it) is subtracted by bothfast_setupandprefill_setup, so the pool it sizes is the pool it gets. Separate from the slab, cuBLAS loads its kernels lazily and was failing every GEMM of a chunk withCUBLAS_STATUS_EXECUTION_FAILEDand no CUDA error behind it when it first ran on a card the pool had filled; one small warm-up GEMM of each kind atprefill_setupnow runs while the pool does not exist yet (measured: CUDA0 at 4.53 GB of 7.53 GB, 110 MB free, failed every GEMM before and runs them after).This branch is rebased onto current
main(a4e1ff0), whose pool sizing is the newerPoolBudget/part_budgetcode: the slab is built on top of it, and the checkout commit's comma-separatedSTRATA_GLM_RESERVE_MBlist is not included becausemainsuperseded it withSTRATA_GLM_RESERVE_LATER_MB.What it leaves alone
The chunk arithmetic and the equal-chunk path are untouched.
STRATA_GLM_MMQ_RESERVE_MBdefaults to 0. The slab is bounded at 16 MB and is used only by the prompt path; a build without the prompt path is unchanged.Measurements
ggml_cuda_erroraborted the engine and every prompt died mid-run.nsm * J * I * 4= ~2 MB at most (Jfrom its 8..128 step-8 search), independent of the chunk size; the pool held 32 buffers / 31.5 MB within one 579-token chunk.Checks
src/core/glm_prefill.cu,src/core/glm_fast_path.cu,src/prefill/ggml_cuda_host.cuandsrc/prefill/moe_mmq.cucompile clean with the build's own flags (nvcc 13.2, compute_86 + compute_120).python3 tools/check_hip_compat.pypasses.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.