mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #84] [MERGED] GLM prefetch that pays on a RAM-bound split: start the copy after this layer's fetch, on a few blocks, and copy only the prediction's top ranks (STRATA_GLM_PREFETCH_AT / _BLOCKS / _RANK) #324
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#324
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/84
Author: @sociolog
Created: 10/10/2026
Status: ✅ Merged
Merged: 10/10/2026
Merged by: @mw00
Base:
main← Head:pr-prefetch📝 Commits (1)
b5a4491GLM prefetch: when the copy starts (STRATA_GLM_PREFETCH_AT), how many blocks it takes (STRATA_GLM_PREFETCH_BLOCKS) and which prediction ranks it copies (STRATA_GLM_PREFETCH_RANK); README row for the prefetch📊 Changes
4 files changed (+40 additions, -12 deletions)
View changed files
📝
README.md(+1 -0)📝
include/strata/kernels/glm_fast.hpp(+1 -1)📝
src/core/glm_fast_path.cu(+22 -5)📝
src/kernels/cuda/glm_fast.cu(+16 -6)📄 Description
What
STRATA_GLM_PREFETCH_Ncopies the next layer's predicted non-resident experts into its spares while a layer computes.As it is, it cost us 13.6 % decode while it raised VRAM hits by 7.5 points. Three switches, each read once:
STRATA_GLM_PREFETCH_AT=route|fetch|cpu- when the copy starts: at once (the default, as before: beside thislayer's own PCIe fetch and its CPU lane), after this layer's fetch (the link is free), or after its CPU-lane answer.
The prefetch lists are double-buffered by layer parity and the next layer waits for the copy before its experts run,
so any of the three is safe.
STRATA_GLM_PREFETCH_BLOCKS=<n>- the copy kernel's blocks (default half the SMs, as before). A PCIe pull needsfew SMs; every SM it holds is one the main stream waits for.
STRATA_GLM_PREFETCH_RANK=<n>- copy only the prediction's first n ranks. The route kernel took the first predictedexpert that is not resident; the top guesses usually are resident already, so that was often a rank-5..7 guess.
README: a row for the prefetch and these switches (
PREFETCH_Nhad none).Measured
Ryzen 9 5900X + 128 GB DDR4, RTX 3090 + 3060 (x8 each), warm 21K API test (fresh 21K prompt, then 2,500 tokens at
21K depth); Maya-M with
RAM_RESIDENT=1, split 30,CPU_PLAN=012234567:N=1(as it is)N=1 AT=cpu BLOCKS=8N=1 AT=fetch BLOCKS=8N=1 AT=fetch BLOCKS=4N=1 AT=fetch BLOCKS=2N=2 AT=fetch BLOCKS=8N=1 AT=fetch BLOCKS=4 RANK=2(twice)N=1 AT=fetch BLOCKS=4 RANK=1N=1 AT=fetch BLOCKS=4 RANK=3/N=2 ... RANK=3Why the rank: route logs with the predictions beside the next layer's real top 8 - the next layer used the prediction's
rank 0 / 1 / 2 / 3 96 / 88 / 75 / 62 % of the time and ranks 4..7 52 / 41 / 31 / 24 % (3090 half; the 3060 half 99 / 94
/ 89 / 80 .. 36 %). The prefetches as they were: 70 % used on the 3090 half. A wrong copy costs the link about what a
right one saves.
Maya-L there (12 MB experts,
RAM_GB=96+ NVMe, calibrated plan,STRATA_GLM_VRAM_EVICT=lrufrom #78):RANK=211.46 (no gain over 11.75 without prefetch),
RANK=112.02 (+2.3 % on top of #78, +5.0 % over 11.45 with neither).On an agent-like workload (one conversation, 40 turns of short answers on a reused, growing context 22K -> 89K, a
20K-token prompt read every 8th turn;
tools-style driver over/v1/chat/completions), Maya-M, same box: answerdecode weighted by tokens 19.31 -> 20.21 tok/s (+4.7 %) with
N=1 AT=fetch BLOCKS=4 RANK=2, 19.42 -> 20.41 atcontexts over 60K (+5.1 %); 0 failures in either run, and 0 in a third run with Maya-L (
RANK=1, 11.4 tok/s) -the prompt -> answer handoffs on reused prefixes are where the #39 races showed, so it was worth the check.
Checks run on this branch: builds (sm_75, sm_86);
glm_dsa_parity,glm_ffn_parity,glm_hc_parity,glm_kda_parity,glm_layer_parity--selftest: all PASS;python -m unittest serve.test_server serve.test_tools serve.test_mcp serve.test_detok: OK; the 21K API test on the real model with this exact build andN=1 AT=fetch BLOCKS=4 RANK=2: 20.11 tok/s at 21K (VRAM hits 69.3 %), clean. It merges cleanly with #76, #78, #80 and #81.The code, the measurements and this description were produced with the help of Claude, an AI assistant by Anthropic.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.