mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #325] [CLOSED] GLM batched rows: each routed expert once per group and no empty launches, opt-in (MAYA_GLM_GROUP_EXPERTS, MAYA_GLM_SKIP_EMPTY) #468
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#468
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/325
Author: @somnergy
Created: 10/20/2026
Status: ❌ Closed
Base:
main← Head:pr/group-experts-skip-empty📝 Commits (2)
301c3aeGLM batched rows: leave out empty wait / fetch / CPU-lane launches (STRATA_GLM_SKIP_EMPTY, off by default)8d56b70GLM batched rows: each routed expert once for all the rows of a group (STRATA_GLM_GROUP_EXPERTS, off by default)📊 Changes
12 files changed (+785 additions, -47 deletions)
View changed files
📝
CMakeLists.txt(+8 -0)📝
docs/SETTINGS.md(+2 -0)📝
include/strata/core/glm_model.hpp(+11 -1)📝
include/strata/kernels/glm_fast.hpp(+14 -1)📝
src/core/glm_fast_path.cu(+113 -36)📝
src/core/glm_fast_state.hpp(+19 -0)📝
src/core/glm_memory.hpp(+16 -0)📝
src/core/glm_multi.cu(+1 -2)📝
src/core/glm_rows.cu(+168 -3)📝
src/kernels/cuda/glm_fast.cu(+105 -2)📝
src/program/generate.cpp(+1 -2)➕
tests/glm_moe_rows_test.cu(+327 -0)📄 Description
What
Two opt-in settings for the batched decode step (
--parallelon one GPU, or a split withMAYA_GLM_SPLIT_ROWS), both off by default. They change which launches run and how the MoE work of a step's rows is arranged, not the arithmetic of a row.MAYA_GLM_SKIP_EMPTY=1(STRATA_GLM_SKIP_EMPTY). The rows path launchesmoe_wait,moe_fetchandmoe_cpu_waitfor every row and MoE layer, although the route that decides whether they have work runs on the device. With the setting:check_residentalso keeps a per-layer flag (every expert of the layer in VRAM as of the last tier update; between updates VRAM only gains), and the rows of such a layer leave all three out - whatMAYA_GLM_RESIDENT_SKIPdoes for the whole model on the token path;moe_wait_fetch: block 0 waits for the host's answer to a disk miss and hands the fetch sources to the other blocks through device memory, then every block copies its share).The single-request token path is unchanged (its launches are part of its graphs' key). The CPU-expert deferral (
moe_defer_wait_) keeps its own condition on the CPU-lane wait.MAYA_GLM_GROUP_EXPERTS=1(STRATA_GLM_GROUP_EXPERTS). In a batched step only the dense weights were shared: each row ran its whole MoE chain alone, so an expert two rows routed was read twice, and each row's CPU-lane experts were a request of their own. With the setting a step's MoE layer runs the way the verify window's batched MoE runs a window's tokens:fast_moe_route, factored out offast_moe_experts) into the window's per-token route state, each row's wait and fetch before the next row's route;rows_scr, allocated with the window's buffers before the expert pool is sized), so a scratch clash never needs a redo;mv_nt, then each distinct routed expert runs once for the rows that chose it (moe_win_experts,exl3::win_experts), then the rows' CPU-lane answers in one launch (moe_cpu_wait_rows);MoeRequest::win_rows) and answers their CPU-lane experts as one merged request on the part's own CPU pool.The grouped path keeps its own error string, fails loudly rather than drop the rows' CPU-lane answers past
kMaxMvNtrows, and says once in the log when the setting is on but a group runs its experts row by row (no window buffers).Glm5Model::split_rows_setting()is now the one parse ofSTRATA_GLM_SPLIT_ROWS(the scheduler,seq_alloc_arenasand the grouped rows' scratch sizing all use it; the same atof + clamp to 0..rows_max() the scheduler had).Cost: 8 scratch expert slots for each extra row of a group (k - 1 rows on a split,
--parallel- 1 on one GPU) and the verify window's buffers, taken from VRAM before the pool is sized.tests/glm_moe_rows_test.cu(GPU, no model) checks the grouped experts, the fused wait / fetch and the rows' CPU-lane waits against the per-row kernels bit for bit, on random Q8_0 experts. Without a GPU it prints "no GPU, skipped".How to enable
MAYA_GLM_GROUP_EXPERTS=1and / orMAYA_GLM_SKIP_EMPTY=1, with--parallel> 1 (andMAYA_GLM_SPLIT_ROWSon a split). Rows indocs/SETTINGS.md.How it was verified
The setup: 2x RTX PRO 5000 Blackwell 72 GB, GLM-5.3-Flash EXL3 3.1 bpw (every expert in VRAM), split rows 4,
--parallel 8at 512K, KV streaming (window 196608), int8 KV, greedy.mainand this branch were built the same way with nvcc 13.4.glm_moe_rows_teston the GPU: ok (bit for bit against the per-row kernels).The 8-stream aggregate of builds at main's behaviour varied 131.4-131.8 tok/s across five runs. VRAM before the pool: +0.32 GB on the first GPU and +0.27 GB on the second (the scratch slots and route state).
The run did not cover RAM-tier experts (the CPU lane and PCIe fetches inside a batched step); the kernels of that path are what
glm_moe_rows_testchecks. I didn't use the greedy texts of the 8 x ~126K workload as an identity check, because two fresh starts of main alone already differ on 3 of 8 streams there (the read order of 8 simultaneous requests varies). Details are in the validation summary that follows in a comment.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.