mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #385] [CLOSED] GLM several conversations: MTP drafting in the batched steps, opt-in (MAYA_GLM_MULTI_MTP) #504
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#504
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/385
Author: @somnergy
Created: 10/22/2026
Status: ❌ Closed
Base:
main← Head:pr/glm-multi-mtp📝 Commits (3)
6e56c54GLM batched rows: the rows' mHC and KDA recurrence in one launch each, opt-in (MAYA_GLM_ROWS_BATCH)0d7e87fGLM batched rows: mv_nt past 8 activations in groups of 8; a gather kernel for a window's KDA inputs61b7264GLM several conversations: MTP drafting in the batched steps, opt-in (MAYA_GLM_MULTI_MTP)📊 Changes
17 files changed (+2300 additions, -181 deletions)
View changed files
📝
CMakeLists.txt(+10 -2)📝
docs/SETTINGS.md(+5 -0)📝
include/strata/core/glm_model.hpp(+59 -3)➕
include/strata/core/mtp_rows.hpp(+73 -0)📝
include/strata/kernels/glm_fast.hpp(+27 -5)📝
src/core/glm_fast_path.cu(+27 -5)📝
src/core/glm_fast_state.hpp(+7 -2)📝
src/core/glm_model.cu(+3 -1)📝
src/core/glm_mtp.cu(+7 -5)➕
src/core/glm_mtp_rows.cu(+889 -0)📝
src/core/glm_multi.cu(+2 -0)📝
src/core/glm_rows.cu(+226 -139)➕
src/core/glm_rows_state.hpp(+69 -0)📝
src/kernels/cuda/glm_fast.cu(+140 -12)📝
src/program/generate.cpp(+312 -7)➕
tests/core/mtp_rows_test.cpp(+130 -0)➕
tests/glm_rows_kernels_test.cu(+314 -0)📄 Description
Summary
With
--parallel, a request alone gets the speculative (MTP) decode, but as soon as a second one runs every request gets one token a step and the NextN block sits idle. This adds MTP drafting to the batched steps, off by default:MAYA_GLM_MULTI_MTP=<drafts>(1-7): each running request's batched step carries a verify window - the token it feeds plus the NextN block's drafts - as consecutive rows of its group. The head keeps the rows up to the first draft that differs from the model's pick; after a miss the recurrent (KDA) states are restored from a copy taken before the window and the kept rows replayed. The drafts of all requests run as batched rows of the NextN block.MAYA_GLM_MULTI_MTP_MAX(default 4) uses the windows only while that many requests or fewer run.MAYA_GLM_ROWS_BATCH=1: a batched step's residual mixing (hc) and KDA prep + recurrence in one launch for all rows instead of one a row (the windows use its per-row scratch).mv_ntpast 8 activations and a gather kernel for the windows' KDA inputs, adapted from #257 (credited).With the settings off nothing new is allocated and the scheduler's paths are unchanged.
Why
Measured under several concurrent Claude Code sessions (agentic coding: long multi-turn conversations, subagents, tool calls, auto-mode safety checks) driving one server through the Anthropic Messages API with
--parallel 8:--parallel 1, the existing single-request MTP) gave 79 tok/s per request but left 4.6 requests waiting and served 413 requests an hour, against 598 with--parallel 8and these changes.Measured
Hardware:
Models: GLM-5.3-Flash EXL3 sc 3.10 bpw (every expert in VRAM on [A] and [B]; ~56% on [C], the rest from RAM and the SSD) and Maya-L (IQ3_S / IQ4_XS experts; ~85% in VRAM on [A], the rest in RAM, CPU lane on).
Every expert in VRAM, [B] (the same changes on an earlier release, before squashing), ~64K-token prompts, 300 greedy tokens, aggregate decode tok/s; every column with split rows 4, even groups, grouped experts, skip empty,
ROWS_BATCH=1,PREFILL_GAPS=20:MULTI_MTP=1(gate 4)MULTI_MTP=3, no gateAcceptance at ~64K: one draft 79-86% (~1.8 tokens a verify step), three drafts 46-62%.
ROWS_BATCHalone ([B], 8 x ~128K): +4.5-5.4% decode.Live, [A]: EXL3, every expert in VRAM,
MULTI_MTP=1for ~8 h: 78.5-81% of drafts accepted, 1.76-1.80 tokens a verify step, 0 engine errors. Maya-L with 5-8 running: only 17 of 198 requests drafted (accepted drafts 0.7% of the output), while the NextN block held ~4.5 GB that would hold ~370 experts.Recommendation
With every expert in VRAM and 2-4 requests often running, set
MAYA_GLM_MULTI_MTP=1(andMAYA_GLM_ROWS_BATCH=1); keep the default gate, which turns the windows off above 4 running, where they only cost (8 running without the gate: 117 vs 170 tok/s). One draft, not more: the second and third drafts are accepted much less often and every draft is a row of the group. With experts partly in RAM and 5 or more requests running most of the time, leave it off and keep the NextN block's VRAM for experts (MAYA_GLM_NO_MTP=1). Where experts stream from RAM, and on one GPU, the speed was not measured.Exactness
MULTI_MTP: the kept tokens are the ones the batched step without drafts writes, given the same other settings - a draft is kept only where it equals the model's pick, and a miss is undone by restore + replay. Not bitwise across runs: which experts a step finds in VRAM or on the CPU lane follows the tiers' timing.ROWS_BATCH: the kernels are bitwise equal to the per-row ones (unit test), but at ~126K tokens 5 of 8 greedy streams differed from the setting off ([B]); the cause was not found.docs/SETTINGS.mdsays so.mv_ntpast 8 activations,kda_gather: bitwise.How it was verified
glm_rows_kernels_test,glm_mv_nt_test(and its generic variant),glm_moe_rows_test,glm_hc/kda/ffn/dsa/kv_stream_parity --selftest,glm_lat8_test,glm_layer_graph_test,mtp_rows_testandsplit_groups_testpass, as on main. Every commit builds (nvcc 13.4, sm_75 and sm_120, tests on);tools/check_hip_compat.pyis clean.Together with #386 (prompt-read gaps), running both settings needs one small follow-up commit (no tier update inside a read's gap; no per-request draft steps while a read holds its context). 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.