mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[GH-ISSUE #570] GLM: start copying an expert from the SSD to the GPU before its read has finished (+12% decode, same output) #237
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#237
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?
Originally created by @pschaub on GitHub (Oct 27, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/570
The problem: When a GLM model does not fit into VRAM and RAM, Maya keeps part of the experts on the SSD. When a token needs one of them, the GPU waits until the whole expert has been read from the SSD, and only then copies it over. Reading and copying run one after the other.
The idea: Copy each piece of the expert to the GPU as soon as that piece has been read, while the rest is still being read. Most of the copy then hides behind the read. zephel01/Abyss, a Maya fork, already does this (d626d96, on by default there). I ported it to Maya as an opt-in setting,
MAYA_GLM_STREAM_FETCH=1.What it brings: On my PC decode is about 12% faster, prefill stays the same, and the output is the same. It is off by default, so nothing changes unless you turn it on.
Who it helps: Everyone whose model does not fit into VRAM and RAM, so that experts are read from the SSD while answering. Without SSD reads the setting changes nothing.
Where it waits today: The host reads all pieces first and answers the GPU only after that:
github.com/mw00/project-maya@88a746c9f9/src/core/glm_fast_path.cu (L4487-L4511)Then the GPU copies each expert in one go:
github.com/mw00/project-maya@88a746c9f9/src/kernels/cuda/glm_fast.cu (L4342-L4352)With the setting on, the GPU waits per piece instead and copies it as soon as it is in RAM, as in Abyss's kernel (glm_fast.cu#L2783-L2804). This is a different overlap from #118, which overlaps compute with the copy; this one overlaps the copy with the SSD read.
Measurements: Maya-S-v2 IQ2_XXS at 32K,
--benchagainst unchanged v1.1.29, 3 sessions of 5 rounds, the order changing from round to round:MAYA_GLM_STREAM_FETCH=1Decode was ahead in 15 of 15 rounds. Prefill is unchanged, and with the setting off the build is as fast as before. The output is identical (KL 0, same top token at 100 % over 1,471 positions). The code it touches is unchanged in v1.1.33.
I only measured Windows with one GPU and GGUF, so it would be good to see it on Linux and other GPUs before turning it on by default. A PR with the change as an opt-in setting follows.
My setup: Maya v1.1.29 built from source, MSVC 19.44, CUDA 13.4, RTX 5090 32 GB, 64 GB DDR5, Ryzen 9 9950X3D2, 8 TB NVMe, Windows 11, driver 621.01, Maya-S-v2 IQ2_XXS
@klvnblst commented on GitHub (Oct 27, 2026):
An independent data point on a different machine: a laptop where the gain is smaller, +2.7%, but it showed up in every pair. I ported the idea myself onto v1.1.33 (your PR wasn't up yet), opt-in as
MAYA_GLM_STREAM_FETCH=1. The patch is below in case it helps the PR.Setup: ASUS Strix SCAR 18, RTX 5090 Laptop 24 GB (sm_120), Core Ultra 9 275HX (no SMT), 64 GB RAM, Intel RST RAID 0 NVMe, Windows 11, CUDA 12.8, MSVC 19.44, driver 617.42. Model: Maya-S24 at 131072 context, MTP drafting.
Env:
KV_INT8=1 DISK_READERS=8 DISK_SKIP_W=0.12 MISS_SKIP_W=0.12 MISS_SKIP_FROM=23 VRAM_EVICT=lru PCIE_SHARE=0.10 READ_CHUNKS=4.maya.py --bench, decode tok/s, in run order with the pairs interleaved:MAYA_GLM_STREAM_FETCH=1Results:
READ_CHUNKS=8was slower here (24.3). This RST RAID still prefers 4, as in #67.tools/calibrate_glm.pyon the streaming build again keptPCIE_SHARE=0.10andREAD_CHUNKS=4.Why the gain is smaller here than your 12%:
Quality (17 small tasks: code with hidden tests, exact answers, long-context needles; greedy, thinking off):
How the port differs from Abyss d626d96:
MoeResponsegainsstream_mask,ready[8]and the chunk layout (s_gu,s_dn,s_chunks). Thenmoe_fetch_kernelandmoe_wait_fetch_kernelboth handle streamed entries without signature changes. That covers the token path, the MTP verify window (glm_window.cu) and the batched rows (glm_rows.cu): a call site still using the old whole-blob copy could otherwise copy chunks that have not landed.stream_maskonly for this route's own answer: whenwait_seq != 0andresp->seq == wait_seq.__nanosleep(128)to poll PCIe less while the copies run.x_cb < 0), because EXL3's pieces are laid out differently.3 * chunks <= 32, the bits onereadyword holds. Abyss allows up to 16 chunks, i.e. 48 bits.nw) are waited for before the early answer..cufiles build as C++17, so the host sets the bits throughstd::atomic<unsigned>over the word rather thanstd::atomic_ref.patch against v1.1.33 (
88a746c)