mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #392] [MERGED] GLM prompt on a split: cut a one-chunk read into chunks so the parts pipeline it, opt-in (MAYA_GLM_PREFILL_MIN_CHUNKS) #509
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#509
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/392
Author: @somnergy
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @mw00
Base:
main← Head:pr/glm-prefill-min-chunks📝 Commits (4)
7e860cfGLM several conversations: read a new prompt in pieces between decode steps, opt-in (MAYA_GLM_PREFILL_INTERLEAVE)ca030ccGLM several conversations: decode gaps at a prompt read's chunk boundaries, opt-in (MAYA_GLM_PREFILL_GAPS)833778bGLM prompt on a split: cut a one-chunk read into chunks so the parts pipeline it, opt-in (MAYA_GLM_PREFILL_MIN_CHUNKS)a27cb3bMerge main into pr/glm-prefill-min-chunks (the PRs merged before it, side by side: test lists, settings rows, includes, the prompt read's loop)📊 Changes
11 files changed (+1016 additions, -26 deletions)
View changed files
📝
CMakeLists.txt(+3 -1)📝
docs/SETTINGS.md(+3 -0)📝
include/strata/core/glm_model.hpp(+21 -0)➕
include/strata/core/prefill_chunks.hpp(+57 -0)➕
include/strata/core/prefill_gaps.hpp(+77 -0)➕
include/strata/core/prefill_pieces.hpp(+57 -0)📝
serve/fake_multi_engine.py(+35 -4)📝
serve/test_multi.py(+80 -0)📝
src/core/glm_prefill.cu(+101 -5)📝
src/program/generate.cpp(+342 -16)➕
tests/core/prefill_pieces_test.cpp(+240 -0)📄 Description
Depends on #386 (decode gaps / interleave): this branch is built on it and uses its per-call chunk floor, so the diff here includes #386's commits until it merges; the commit of this PR is the last one.
Summary
A prompt-path call that fits in one chunk runs on a split's GPUs one after the other, each idle half the time.
MAYA_GLM_PREFILL_MIN_CHUNKS=<n>[,<min tokens>](off by default) cuts every call on a split into at least<n>chunks (1-8), none shorter than<min tokens>(512), so the parts pipeline it: each works n / (n + parts - 1) of the call instead of 1 / parts. Reads under 2 x<min tokens>stay whole; long reads keep as many chunks as they need; one GPU: no effect. It shares one computation with #386's interleaved pieces (strata/core/prefill_chunks.hpp), and with #386's gaps a boundary's gap now waits until the budget earned is at least half a decode round (STRATA_GLM_PREFILL_GAP_CREDIT=0: a gap at every boundary).Why
Measured under several concurrent Claude Code sessions (agentic coding: long multi-turn conversations, subagents, tool calls) through the Anthropic Messages API with
--parallel 8:Measured
Hardware: 2x NVIDIA RTX PRO 5000 Blackwell 72 GB, each on PCIe 5.0 x8 from its own CPU root port (no fast P2P); Intel Core Ultra 9 285K (8 P + 16 E cores); 96 GB DDR5; driver 615.71.09, CUDA 13.4. Model: GLM-5.3-Flash EXL3 sc 3.10 bpw, every expert in VRAM;
--parallel 8, split rows 4. A turn of N new tokens on a restored conversation, read time (ms), alone and with 3 requests decoding (MAYA_GLM_PREFILL_GAPS=20):44First token 200-490 ms sooner at 1-4K; the others' decode unchanged (51.4 vs 51.6 tok/s); GPU SM use during a 2K read 31/29% -> 69/57%.
2is close behind; 8 chunks did not beat 4.Maya-L (IQ3_S / IQ4_XS experts, ~85% in VRAM, the rest in RAM; same box), from the engine's stage lines of 208 live reads: every chunk stages nearly every expert not in VRAM over PCIe whatever its length - a ~591-token chunk took 583 / 636 ms a GPU, of it 395 / 481 ms copies (~900-1150 experts) - so more chunks cost more there.
Recommendation
With every expert in VRAM on a 2-GPU split, set
MAYA_GLM_PREFILL_MIN_CHUNKS=4: short reads 16-22% faster. With experts partly in RAM (or streamed from RAM), leave it off: each extra chunk re-stages the experts not in VRAM, and a fit to the live reads predicts 1-4K reads 20-35% slower with it (predicted, not A/B-measured). On one GPU it does nothing; more than two GPUs were not measured. For EXL3 packs, #388 makes the short chunks themselves cheaper.Exactness
Not bit-exact: the chunk length changes the prompt's arithmetic, as
--prefill Ndoes. With identical chunking the greedy tokens were identical across engines; wherever the chunking differed, 48 greedy tokens diverged after 1-30 tokens. The gap credit rule changes when a gap runs, not what is computed (it never had to skip a gap in these runs).How it was verified
tests/core/prefill_pieces_test(CPU): the chunks as before when off (against the old formula), exactly the floor's count for 2-4 chunks, multiples of 64, never past the largest chunk or under the minimum, the parse, the gap-due rule.prefill_pieces_testpasses on the box above; the serve tests pass;tools/check_hip_compat.pyis clean.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.