[GH-ISSUE #30] Batch Slots on GLM Engine #15

Closed
opened 2026-10-29 21:19:09 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @genius1012 on GitHub (Oct 9, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/30

Could the GLM engine get Strata's batch slots (--batch N with --batch-groups pipelining one group per stage, auto in 0.1.41), ideally above 8 slots (16 at least ideally), plus in-RAM conversation parking that works with the split?
A /v1/responses endpoint would also help Codex-style clients.

Originally created by @genius1012 on GitHub (Oct 9, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/30 Could the GLM engine get Strata's batch slots (--batch N with --batch-groups pipelining one group per stage, auto in 0.1.41), ideally above 8 slots (16 at least ideally), plus in-RAM conversation parking that works with the split? A /v1/responses endpoint would also help Codex-style clients.
Author
Owner

@genius1012 commented on GitHub (Oct 10, 2026):

Hi, and thanks for Maya. Maya-L and the 16-GPU split are great work.

some additional context and analysi if it's helpful

A Maya-L with Strata-style batch slots across a multi-GPU split would likely be the best local GLM option for multi-lane serving. Today the GLM path serves one request at a time
(serve/server.py:7, FIFO lock at :963), so it can't take more than one lane.

What we found reading the GLM path (so you don't have to re-derive it; please correct anything we misread):

  • Per-sequence state is a singleton. Glm5Model has one pos_, one state_ arena, and per-layer offsets kda_S_ / kda_conv_ / dsa_lat_ / dsa_ik_ / dsa_ig_ / dsa_pool_
    (include/strata/core/glm_model.hpp:189-199). snap_, snap_pool_, kda_bak_ and the ik_ring_ are also single (:356-363, :416). FastState row buffers are single-row
    (src/core/glm_fast_state.hpp:194-205).
  • KDA recurrent update and DSA select take one state pointer and one scalar position (src/core/glm_fast_path.cu:3200, 3378, 3393).
  • The MoE doorbell carries one route per layer per token. That is MoeRequest{ids[8], w[8], miss_mask} and MoeResponse.cpu_part[4096]
    (include/strata/kernels/glm_fast.hpp:191-220). The expected-count logic assumes one per MoE layer per token (glm_fast_state.hpp:427). We think this is the hardest part.
  • glm_batch.cu batches T tokens of one sequence (chunked prefill, :1-6), not multiple sequences. Its KDA/DSA/MLA twins (:1825-1916) look like a useful starting point for
    multi-row decode kernels.
  • The layer-split hand-off is one residual per token (hop_to_next, glm_fast_path.cu:3717).

A possible staged plan (each stage behind an off-by-default STRATA_GLM_* setting, per CONTRIBUTING):

  1. Server admission and slot scheduler. Port Strata's admission/STOP/solo-return design (Strata 9461f5e, issue #465 series) with N slots reported on /slots. At first, admissions can stay sequential and the engine can still decode one sequence.
  2. Per-slot state carving on every split part: KDA S/conv, DSA latent/indexer, ik ring, snapshot; plus slot↔solo copies so a lone request keeps the solo/MTP path. The question here is the per-slot VRAM cost of KDA+DSA state at long context against expert-cache slots.
  3. Multi-row decode window: KDA prep/rec/conv, DSA prep/score/select with per-row positions and cell lists, MLA over per-row cells, HC, route, head and sampling per row. MTP drafts can be off in batch windows at first, as Strata did initially.
  4. Multi-route MoE service: a request per (row, layer) through the doorbell, a CPU lane answering many rows, spares and promotion under contention, and masks beyond 8 experts × 1 row.
  5. Split pipelining: slot groups flowing through the stages (--batch-groups equivalent, one hop row per group).
  6. Tests: bitwise parity of each slot's greedy tokens against solo, a tools/batch_test.py port, and server tests.
<!-- gh-comment-id:6091989795 --> @genius1012 commented on GitHub (Oct 10, 2026): Hi, and thanks for Maya. Maya-L and the 16-GPU split are great work. some additional context and analysi if it's helpful A Maya-L with Strata-style batch slots across a multi-GPU split would likely be the best local GLM option for multi-lane serving. Today the GLM path serves one request at a time (serve/server.py:7, FIFO lock at :963), so it can't take more than one lane. What we found reading the GLM path (so you don't have to re-derive it; please correct anything we misread): - Per-sequence state is a singleton. Glm5Model has one pos_, one state_ arena, and per-layer offsets kda_S_ / kda_conv_ / dsa_lat_ / dsa_ik_ / dsa_ig_ / dsa_pool_ (include/strata/core/glm_model.hpp:189-199). snap_, snap_pool_, kda_bak_ and the ik_ring_ are also single (:356-363, :416). FastState row buffers are single-row (src/core/glm_fast_state.hpp:194-205). - KDA recurrent update and DSA select take one state pointer and one scalar position (src/core/glm_fast_path.cu:3200, 3378, 3393). - The MoE doorbell carries one route per layer per token. That is MoeRequest{ids[8], w[8], miss_mask} and MoeResponse.cpu_part[4096] (include/strata/kernels/glm_fast.hpp:191-220). The expected-count logic assumes one per MoE layer per token (glm_fast_state.hpp:427). We think this is the hardest part. - glm_batch.cu batches T tokens of one sequence (chunked prefill, :1-6), not multiple sequences. Its KDA/DSA/MLA twins (:1825-1916) look like a useful starting point for multi-row decode kernels. - The layer-split hand-off is one residual per token (hop_to_next, glm_fast_path.cu:3717). A possible staged plan (each stage behind an off-by-default STRATA_GLM_* setting, per CONTRIBUTING): 1. Server admission and slot scheduler. Port Strata's admission/STOP/solo-return design (Strata 9461f5e, issue #465 series) with N slots reported on /slots. At first, admissions can stay sequential and the engine can still decode one sequence. 2. Per-slot state carving on every split part: KDA S/conv, DSA latent/indexer, ik ring, snapshot; plus slot↔solo copies so a lone request keeps the solo/MTP path. The question here is the per-slot VRAM cost of KDA+DSA state at long context against expert-cache slots. 3. Multi-row decode window: KDA prep/rec/conv, DSA prep/score/select with per-row positions and cell lists, MLA over per-row cells, HC, route, head and sampling per row. MTP drafts can be off in batch windows at first, as Strata did initially. 4. Multi-route MoE service: a request per (row, layer) through the doorbell, a CPU lane answering many rows, spares and promotion under contention, and masks beyond 8 experts × 1 row. 5. Split pipelining: slot groups flowing through the stages (--batch-groups equivalent, one hop row per group). 6. Tests: bitwise parity of each slot's greedy tokens against solo, a tools/batch_test.py port, and server tests.
Author
Owner

@mw00 commented on GitHub (Oct 10, 2026):

Thank you, that read matches the code. Two notes from work since then:

#76 (the MTP rework, in review) adds a multi-row decode window for one sequence. It covers much of your stage 3's kernel work, but for consecutive positions of one sequence, not separate sequences:

  • every per-token activation as rows;
  • multi-row GEMVs that read each weight once for all rows;
  • the mHC read and the KDA convs for all rows in one launch;
  • the KDA recurrence over the rows with its state in registers;
  • per-row DSA attention, and per-row MoE routes through the tiers.

Your stage 4 is also where #76 stopped. The tier protocol has one outstanding route per GPU: the response and the CPU-lane answer are single buffers, and a disk read for a route lands in staging the next route may reuse. So a window's rows route one after another, and their RAM, SSD and CPU-lane work does not overlap.

A response ring plus per-request staging would be the shared prerequisite for both batch slots and a faster verify. That part could be built and tested on its own first.

<!-- gh-comment-id:6096930815 --> @mw00 commented on GitHub (Oct 10, 2026): Thank you, that read matches the code. Two notes from work since then: **#76 (the MTP rework, in review) adds a multi-row decode window for one sequence.** It covers much of your stage 3's kernel work, but for consecutive positions of one sequence, not separate sequences: - every per-token activation as rows; - multi-row GEMVs that read each weight once for all rows; - the mHC read and the KDA convs for all rows in one launch; - the KDA recurrence over the rows with its state in registers; - per-row DSA attention, and per-row MoE routes through the tiers. **Your stage 4 is also where #76 stopped.** The tier protocol has one outstanding route per GPU: the response and the CPU-lane answer are single buffers, and a disk read for a route lands in staging the next route may reuse. So a window's rows route one after another, and their RAM, SSD and CPU-lane work does not overlap. A response ring plus per-request staging would be the shared prerequisite for both batch slots and a faster verify. That part could be built and tested on its own first.
Author
Owner

@mw00 commented on GitHub (Oct 11, 2026):

An update: most of this is in v1.0.33, from @0xPreDa's #93 and #94.

  • Several conversations at once: STRATA_GLM_SEQS=<n> (up to 8) on a split of two GPUs or more. The engine keeps n sequence states, and a token of each goes through the split's GPUs one behind the other, so every GPU works on a different conversation. On 4x RTX 4090 with Maya-S24: 110 tok/s alone, 225 tok/s in all for four. One request alone keeps the speculative decode.
  • Fair turns: STRATA_FAIR_SLICE_S=<seconds>. An answer that has been decoding that long while another request waits gives the engine to it, then continues where it was.
  • Parking: the conversation slots set a conversation aside on disk and bring it back. They work with a split.

Not covered:

  • More than 8 at once. Each extra state takes its room from the expert pool, so past a few conversations every one of them decodes slower.
  • /v1/responses. The server speaks /v1/chat/completions and /v1/messages.

I'm closing this since the core of it shipped. If you still need either of the last two, a new issue for just that part would be easiest to track.

<!-- gh-comment-id:6108260997 --> @mw00 commented on GitHub (Oct 11, 2026): An update: most of this is in [v1.0.33](https://github.com/mw00/project-maya/releases/tag/v1.0.33), from @0xPreDa's #93 and #94. - **Several conversations at once:** `STRATA_GLM_SEQS=<n>` (up to 8) on a split of two GPUs or more. The engine keeps n sequence states, and a token of each goes through the split's GPUs one behind the other, so every GPU works on a different conversation. On 4x RTX 4090 with Maya-S24: 110 tok/s alone, 225 tok/s in all for four. One request alone keeps the speculative decode. - **Fair turns:** `STRATA_FAIR_SLICE_S=<seconds>`. An answer that has been decoding that long while another request waits gives the engine to it, then continues where it was. - **Parking:** the conversation slots set a conversation aside on disk and bring it back. They work with a split. Not covered: - **More than 8 at once.** Each extra state takes its room from the expert pool, so past a few conversations every one of them decodes slower. - **`/v1/responses`.** The server speaks `/v1/chat/completions` and `/v1/messages`. I'm closing this since the core of it shipped. If you still need either of the last two, a new issue for just that part would be easiest to track.
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#15
No description provided.