mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #391] [MERGED] GLM batched decode: the rows' DSA attention, selections, scores and KV resolves in one launch, opt-in (MAYA_GLM_ROWS_ATTN, MAYA_GLM_ROWS_SMALL) #510
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#510
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/391
Author: @somnergy
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @mw00
Base:
main← Head:pr/glm-rows-attn📝 Commits (9)
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)2973a1aGLM batched decode: the rows' DSA attention in one launch, opt-in (MAYA_GLM_ROWS_ATTN)2d2d6ddGLM batched decode: the rows' indexer selections in one launch with MAYA_GLM_ROWS_ATTNb017368GLM batched decode: a verify window's rows on a streamed layer in the rows' attention966a67bGLM batched decode: the rows' indexer scores, KV resolves and expert grouping in fewer launches, opt-in (MAYA_GLM_ROWS_SMALL)561ddecglm_rows_attn_test: check the rows' KV resolves by what the attention readsdf0f599Merge main into pr/glm-rows-attn (the PRs merged before it, side by side: test lists, settings rows, includes, the prompt read's loop)📊 Changes
20 files changed (+3279 additions, -192 deletions)
View changed files
📝
CMakeLists.txt(+16 -2)📝
docs/SETTINGS.md(+7 -0)📝
include/strata/core/glm_model.hpp(+59 -3)➕
include/strata/core/mtp_rows.hpp(+73 -0)📝
include/strata/kernels/glm_fast.hpp(+59 -7)📝
include/strata/kernels/glm_kv_stream.hpp(+14 -0)📝
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(+370 -141)➕
src/core/glm_rows_state.hpp(+76 -0)📝
src/kernels/cuda/glm_fast.cu(+271 -18)📝
src/kernels/cuda/glm_kv_stream.cu(+33 -1)📝
src/program/generate.cpp(+312 -7)➕
tests/core/mtp_rows_test.cpp(+130 -0)➕
tests/glm_rows_attn_test.cu(+610 -0)➕
tests/glm_rows_kernels_test.cu(+314 -0)📄 Description
Depends on #385 (multi-request MTP): this branch is built on it, so the diff here includes #385's commits until it merges; the commits of this PR are the last 5.
Summary
In a batched decode step a DSA layer ran the absorbed attention once a row: one row's split attention fills only 64 thread blocks, so a launch a row leaves much of a large card idle. Two opt-in settings put the rows of a step together, each row running the per-row kernel's own device code, so the output is bitwise the same:
MAYA_GLM_ROWS_ATTN=1: the DSA attention of all the rows in one launch (gf::mla_attend_rows; a token ofmla_split_mma_kernelmay name its own latents and cells), the query and output projections of all rows at once, and the rows' indexer selections in one launch. With KV streaming, a run of one conversation's consecutive rows (an MTP verify window) resolves its selections in one call, so window groups take the batched path too.MAYA_GLM_ROWS_SMALL=1: the rows' indexer scores, KV-streaming resolves and routed-expert grouping in one launch each.With them off nothing new is allocated.
ROWS_ATTNtakes 28 MB a GPU and needs the tensor-core attention (compute capability 8.0+, kv_lora 512); elsewhere the rows run one by one 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: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; split rows 4. 8 conversations of ~33K tokens (then 4), three 5-s windows each, aggregate decode tok/s:
ROWS_ATTN=1ROWS_SMALL=1Per 4-row step on the first GPU: 22.2 -> 17.1 -> 16.7 ms. Caveats: repetitive synthetic text and 33K contexts (live: 40-190K); the expert grouping was timed before upstream's change to
moe_win_group_kernel, soROWS_SMALL's grouping share is likely smaller on main. With Maya-L (~85% of experts in VRAM, same box) both ran live ~6 h, 0 engine errors; no A/B there.Recommendation
With 3 or more requests decoding on a compute capability 8.0+ GPU, set
MAYA_GLM_ROWS_ATTN=1andMAYA_GLM_ROWS_SMALL=1: same output, a faster step. They do nothing in single-row groups (2 running without MTP windows, or the lone row of a 2 + 1 split) and below compute capability 8.0. With experts partly in RAM the step is dominated by waits for RAM-tier experts, so expect less; streamed from RAM and one GPU were not measured.Exactness
Bitwise.
tests/glm_rows_attn_test.cu(GPU, no model, 828 cases) compares each row's attention withmla()per row byte for byte (2-16 rows, contexts up to ~60K, resident and KV-streamed caches including verify-window rows, FP16 and INT8 latents), and the selections, scores, KV resolves and expert grouping with the per-row and one-thread kernels. Greedy, off vs on, 300 tokens: 12 of 12 identical for each setting.How it was verified
glm_rows_attn_test(828 cases),glm_rows_kernels_test,glm_mv_nt_test,glm_moe_rows_testand theglm_*_parity --selftesttests pass, as on main; every commit builds (nvcc 13.4, sm_75 and sm_120);tools/check_hip_compat.pyis clean.moe_route(each row's route claims spare expert slots that the next row sees; one launch would change the tiers' behaviour).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.