[PR #386] [CLOSED] GLM several conversations: decode during a prompt read, opt-in (PREFILL_INTERLEAVE, _GAPS) #505

Closed
opened 2026-10-29 21:26:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/386
Author: @somnergy
Created: 10/22/2026
Status: ❌ Closed

Base: main ← Head: pr/glm-prefill-gaps


📝 Commits (2)

  • 7e860cf GLM several conversations: read a new prompt in pieces between decode steps, opt-in (MAYA_GLM_PREFILL_INTERLEAVE)
  • ca030cc GLM several conversations: decode gaps at a prompt read's chunk boundaries, opt-in (MAYA_GLM_PREFILL_GAPS)

📊 Changes

10 files changed (+862 additions, -25 deletions)

View changed files

📝 CMakeLists.txt (+3 -2)
📝 docs/SETTINGS.md (+2 -0)
📝 include/strata/core/glm_model.hpp (+18 -0)
➕ include/strata/core/prefill_gaps.hpp (+68 -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 (+87 -4)
📝 src/program/generate.cpp (+330 -15)
➕ tests/core/prefill_pieces_test.cpp (+182 -0)

📄 Description

Summary

With --parallel, admitting a request drains every running request and reads the whole new prompt in one go, so a long read stops every other conversation for all of it. Two opt-in ways to keep them decoding during a read:

  • MAYA_GLM_PREFILL_GAPS=<percent>[,<max gap ms>] (a split with MAYA_GLM_SPLIT_ROWS): the read stays one pipelined call; at its chunk boundaries (every part idle, the pipeline and the expert pool's loan kept) the running requests decode for about <percent>% of the time, at least one round, at most <max gap ms> (4000) a gap, plus one gap before each read. A gap that overruns the cap ends the gaps of that read.
  • MAYA_GLM_PREFILL_INTERLEAVE=<tokens>[,<rounds>[,cut]]: the read in pieces with decode rounds between them; for where gaps cannot run (one GPU, no split rows). By default the pieces keep the uncut read's chunk boundaries.

STOP, PAUSE and engine errors during a read are handled for both the reader and the decoders (a PAUSE inside a gap keeps its state, taken once the read is over). Unset, the scheduler and the prompt path run as before.

Why

Measured under several concurrent Claude Code sessions (agentic coding: long multi-turn conversations, subagents, tool calls, auto-mode safety checks) through the Anthropic Messages API with --parallel 8:

  • Before this and the related PRs, prompt reads took ~56% of the wall time, one at a time, and every other conversation waited through each one; requests queued (8 running and ~9 waiting at the busiest).
  • Reads are mostly short, but a cold read of a long conversation (a client restart, a compaction, a long tool result) takes tens of seconds to minutes, and every other session's main loop and subagents stall for all of it.

Measured

Hardware:

  • [A] 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, no AVX-512); 96 GB DDR5; driver 615.71.09, CUDA 13.4.
  • [B] 2x NVIDIA RTX PRO 5000 Blackwell 72 GB, each on PCIe 5.0 x16; AMD EPYC 9734 (the engine on 8 CPUs); 125 GB RAM; driver 595.91.07, CUDA 13.4.
  • [C] 2x NVIDIA RTX 5090 32 GB, each on PCIe 5.0 x8; Intel Core Ultra 7 270K Plus; 93 GB RAM for the engine; driver 595.99.02, CUDA 13.4.

Models: GLM-5.3-Flash EXL3 sc 3.10 bpw (every expert in VRAM on [A] and [B]; ~56% on [C], the rest from a 48 GB RAM tier and the SSD) and Maya-L (IQ3_S / IQ4_XS experts, ~85% in VRAM on [A]).

hardware read setting read time the others' tokens during the read
[B], all in VRAM (an earlier release) 90K tokens, 4 greedy requests decoding off 32.6 s 0
gaps 20 39.9 s (+22%) 914 (22.9 tok/s)
gaps 30 44.7 s (+37%) 1,499 (33.5 tok/s)
[A], all in VRAM a 1K / 4K / 8K turn on a restored conversation, 3 decoding no gaps 1.13 / 3.12 / 5.90 s 40 tok/s
gaps 20 1.35 / 3.59 / 6.77 s (+15-19%) 51 tok/s
[C], streamed from RAM (these commits on v1.1.20) 90K tokens, 4 decoding off 74.6 s 0
gaps 20 97.7 s (+31%) 44-57 each
interleave (8192-token pieces) 102.3 s (+37%) 11-21 each
  • Longest stall of a decoding stream on a read-heavy test load ([B], 30-120K-token prompts, 4-8 clients): 69-86 s off, 6.0 s with gaps 20 and the gap before each read.
  • Maya-L live on [A], 5-8 running: one gap per short read, 10-18% of its time, the others decoding at 82-110 tok/s in it, no gap over its cap.
  • Live on [A], EXL3: gaps 20 for ~9 h with up to 8 running, 0 engine errors.

Recommendation

On a split with several conversations, set MAYA_GLM_PREFILL_GAPS=20: a read takes ~20% longer and nobody waits a whole read. 30 gives the others more for a longer read. With experts streamed from RAM it works but costs more (+31% on a 90K read), and the cap keeps a slow gap from stretching the read. On one GPU, gaps are off; interleave is the option there (not measured). Leave both off with one conversation at a time, or where only a read's own latency matters.

Exactness

Neither is bit-exact. The chunk boundaries are the uncut read's, but a gap's decode (or the steps between interleave pieces) can move experts in and out of VRAM, so a later chunk can find other experts resident, staged or on the CPU lane and sum their outputs in another order. Observed ([B]): with 4 greedy decoders during a 90K read, the long request's answer differed from the setting off while the decoders and a queued request matched; flags off matched the unmodified release.

How it was verified

  • On v1.1.23 (this branch), [A]: prefill_pieces_test (piece cuts; the gap gate with a threaded pipeline of 2-3 parts, 1-7 chunks: every part idle in a gap, every chunk read once in order, no deadlock) and split_groups_test pass; both commits build; the serve tests pass (345, with the new interleave cases on fake_multi_engine.py); tools/check_hip_compat.py is clean.
  • [C]: the rows above, with a decoder's client killed during the read, a long prompt killed during its own read and a request queued behind it; with fair slices (MAYA_FAIR_SLICE_S=3, 8 decoders) a PAUSE during the read was deferred and its 89,801-token state kept (the log holds a single ~90K read); 0 errors.
  • Not run: one GPU (interleave), gaps with MAYA_GLM_PREFILL_KEEP lowered, an A/B against off with experts partly in RAM.

Together with #385 (multi-request MTP), running both settings needs one small follow-up commit; it is ready and goes in after the second of the two.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/386 **Author:** [@somnergy](https://github.com/somnergy) **Created:** 10/22/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/glm-prefill-gaps` --- ### 📝 Commits (2) - [`7e860cf`](https://github.com/mw00/project-maya/commit/7e860cff772f492db855164cf0f58c3f2e7598e8) GLM several conversations: read a new prompt in pieces between decode steps, opt-in (MAYA_GLM_PREFILL_INTERLEAVE) - [`ca030cc`](https://github.com/mw00/project-maya/commit/ca030ccfabdab928420e89b82d8a838592a00806) GLM several conversations: decode gaps at a prompt read's chunk boundaries, opt-in (MAYA_GLM_PREFILL_GAPS) ### 📊 Changes **10 files changed** (+862 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+3 -2) 📝 `docs/SETTINGS.md` (+2 -0) 📝 `include/strata/core/glm_model.hpp` (+18 -0) ➕ `include/strata/core/prefill_gaps.hpp` (+68 -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` (+87 -4) 📝 `src/program/generate.cpp` (+330 -15) ➕ `tests/core/prefill_pieces_test.cpp` (+182 -0) </details> ### 📄 Description ## Summary With `--parallel`, admitting a request drains every running request and reads the whole new prompt in one go, so a long read stops every other conversation for all of it. Two opt-in ways to keep them decoding during a read: - **`MAYA_GLM_PREFILL_GAPS=<percent>[,<max gap ms>]`** (a split with `MAYA_GLM_SPLIT_ROWS`): the read stays one pipelined call; at its chunk boundaries (every part idle, the pipeline and the expert pool's loan kept) the running requests decode for about `<percent>`% of the time, at least one round, at most `<max gap ms>` (4000) a gap, plus one gap before each read. A gap that overruns the cap ends the gaps of that read. - **`MAYA_GLM_PREFILL_INTERLEAVE=<tokens>[,<rounds>[,cut]]`**: the read in pieces with decode rounds between them; for where gaps cannot run (one GPU, no split rows). By default the pieces keep the uncut read's chunk boundaries. STOP, PAUSE and engine errors during a read are handled for both the reader and the decoders (a PAUSE inside a gap keeps its state, taken once the read is over). Unset, the scheduler and the prompt path run as before. ## Why Measured under several concurrent Claude Code sessions (agentic coding: long multi-turn conversations, subagents, tool calls, auto-mode safety checks) through the Anthropic Messages API with `--parallel 8`: - Before this and the related PRs, prompt reads took ~56% of the wall time, one at a time, and every other conversation waited through each one; requests queued (8 running and ~9 waiting at the busiest). - Reads are mostly short, but a cold read of a long conversation (a client restart, a compaction, a long tool result) takes tens of seconds to minutes, and every other session's main loop and subagents stall for all of it. ## Measured Hardware: - **[A]** 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, no AVX-512); 96 GB DDR5; driver 615.71.09, CUDA 13.4. - **[B]** 2x NVIDIA RTX PRO 5000 Blackwell 72 GB, each on PCIe 5.0 x16; AMD EPYC 9734 (the engine on 8 CPUs); 125 GB RAM; driver 595.91.07, CUDA 13.4. - **[C]** 2x NVIDIA RTX 5090 32 GB, each on PCIe 5.0 x8; Intel Core Ultra 7 270K Plus; 93 GB RAM for the engine; driver 595.99.02, CUDA 13.4. Models: GLM-5.3-Flash EXL3 sc 3.10 bpw (every expert in VRAM on [A] and [B]; ~56% on [C], the rest from a 48 GB RAM tier and the SSD) and Maya-L (IQ3_S / IQ4_XS experts, ~85% in VRAM on [A]). | hardware | read | setting | read time | the others' tokens during the read | |---|---|---|---|---| | [B], all in VRAM (an earlier release) | 90K tokens, 4 greedy requests decoding | off | 32.6 s | 0 | | | | gaps 20 | 39.9 s (+22%) | 914 (22.9 tok/s) | | | | gaps 30 | 44.7 s (+37%) | 1,499 (33.5 tok/s) | | [A], all in VRAM | a 1K / 4K / 8K turn on a restored conversation, 3 decoding | no gaps | 1.13 / 3.12 / 5.90 s | 40 tok/s | | | | gaps 20 | 1.35 / 3.59 / 6.77 s (+15-19%) | 51 tok/s | | [C], streamed from RAM (these commits on v1.1.20) | 90K tokens, 4 decoding | off | 74.6 s | 0 | | | | gaps 20 | 97.7 s (+31%) | 44-57 each | | | | interleave (8192-token pieces) | 102.3 s (+37%) | 11-21 each | - Longest stall of a decoding stream on a read-heavy test load ([B], 30-120K-token prompts, 4-8 clients): 69-86 s off, 6.0 s with gaps 20 and the gap before each read. - Maya-L live on [A], 5-8 running: one gap per short read, 10-18% of its time, the others decoding at 82-110 tok/s in it, no gap over its cap. - Live on [A], EXL3: gaps 20 for ~9 h with up to 8 running, 0 engine errors. ## Recommendation On a split with several conversations, set `MAYA_GLM_PREFILL_GAPS=20`: a read takes ~20% longer and nobody waits a whole read. `30` gives the others more for a longer read. With experts streamed from RAM it works but costs more (+31% on a 90K read), and the cap keeps a slow gap from stretching the read. On one GPU, gaps are off; interleave is the option there (not measured). Leave both off with one conversation at a time, or where only a read's own latency matters. ## Exactness Neither is bit-exact. The chunk boundaries are the uncut read's, but a gap's decode (or the steps between interleave pieces) can move experts in and out of VRAM, so a later chunk can find other experts resident, staged or on the CPU lane and sum their outputs in another order. Observed ([B]): with 4 greedy decoders during a 90K read, the long request's answer differed from the setting off while the decoders and a queued request matched; flags off matched the unmodified release. ## How it was verified - **On v1.1.23 (this branch), [A]:** `prefill_pieces_test` (piece cuts; the gap gate with a threaded pipeline of 2-3 parts, 1-7 chunks: every part idle in a gap, every chunk read once in order, no deadlock) and `split_groups_test` pass; both commits build; the serve tests pass (345, with the new interleave cases on `fake_multi_engine.py`); `tools/check_hip_compat.py` is clean. - **[C]:** the rows above, with a decoder's client killed during the read, a long prompt killed during its own read and a request queued behind it; with fair slices (`MAYA_FAIR_SLICE_S=3`, 8 decoders) a PAUSE during the read was deferred and its 89,801-token state kept (the log holds a single ~90K read); 0 errors. - **Not run:** one GPU (interleave), gaps with `MAYA_GLM_PREFILL_KEEP` lowered, an A/B against off with experts partly in RAM. Together with #385 (multi-request MTP), running both settings needs one small follow-up commit; it is ready and goes in after the second of the two. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:26:10 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#505
No description provided.