mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 19:04:50 +07:00
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#637
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/630
Author: @merbanan
Created: 10/28/2026
Status: 🔄 Open
Base:
main← Head:pr/route-one📝 Commits (3)
aecbbc9GLM decode route: the top k by rank, every thread at once - a micro-optimization (MAYA_GLM_ROUTE_RANK, on by default; =0: topk_warp)8340e0eGLM decode route: the route kernel's reads and writes reordered - a micro-optimization (MAYA_GLM_ROUTE_FAST, on by default; MAYA_GLM_ROUTE_PROF measures it)958e696GLM decode route in one pass an expert (MAYA_GLM_ROUTE_ONE, on by default; =0: moe_route_kernel): each thread its own expert's score, rank and entries, one warp the plan a lane an entry and the request - three block barriers instead of nine, no single-thread loop; the same plan and request bit for bit (glm_route_one_test)📊 Changes
7 files changed (+835 additions, -27 deletions)
View changed files
📝
CMakeLists.txt(+7 -0)📝
docs/SETTINGS.md(+4 -0)📝
include/strata/kernels/glm_fast.hpp(+2 -0)📝
src/core/glm_fast_path.cu(+5 -0)📝
src/core/glm_model.cu(+1 -0)📝
src/kernels/cuda/glm_fast.cu(+524 -27)➕
tests/glm_route_one_test.cu(+292 -0)📄 Description
Stacked on #486, which is stacked on #451. The first two commits belong to those PRs; this PR adds the third.
This PR computes the decode's route in one pass per expert:
__syncthreads_or.route_rank, the same ruletopk_rankuses (now a shared helper). The k owners write their own plan entries: id, weight, table entry, home, count.The result is three block barriers instead of nine, and no single-thread loop. The shared expert's swiglu/q8_1 stays in the other blocks, as before.
The same plan and request, bit for bit.
MAYA_GLM_ROUTE_ONEis on by default;=0givesmoe_route_kernel. It applies to the plain decode route (withROUTE_RANKandROUTE_FAST, no predictor, no look-ahead, no near ids). The other cases keepmoe_route_kernel. The setting has a row indocs/SETTINGS.md.tools/check_hip_compat.pypasses.Exactness
tests/glm_route_one_test.cu(CUDA tests,glm_route_one_test) runs 20000 random routes under both kernels. It covers:It hashes the plan, the sequences, the whole table, the counters,
sh_hq, the error flag and the ring slot. All 40000 routes match on a V100 (this branch) and on an RTX 2060. The deterministic decode (CPU lane off,MAYA_GLM_RAM_GB=50) gives the same tokens at 2K, 8K and 27K.Speed
Measured on a Tesla V100-PCIE-32GB at 250 W with a Ryzen 9 7950X and turboderp's EXL3 2.05bpw, on v1.1.35 with this stack.
The route kernel (
MAYA_GLM_ROUTE_PROF, µs per route at ~1.38 GHz):The test's own timing of back-to-back routes shows 20.0 -> 16.4 µs (affinity 0) and 17.8 -> 16.0 µs (affinity 0.02).
Decode, deterministic (CPU lane off,
MAYA_GLM_RAM_GB=50, mean of 4 interleaved rounds, ms per token):That is -1.0 to -1.1 % against main, and -0.35 % against #451 + #486.
Decode, served settings (CPU lane on,
DEFER_CPU=1,ROUTE_AFFINITY=0.02, default RAM tier, mean of 3 rounds × 3 prompts):All 9 runs of this stack beat all 9 runs of main. On its own, this commit's gain over #486 is inside the noise in the served setting. Its case is the route kernel: a quarter less serial time at every MoE layer, which counts for more on a faster GPU where the route is a bigger share of a token. It has been running on our served V100 since 2026-10-28.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.