mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #270] [MERGED] GLM prompt on a split without NVLink: the waiting GPU computes a share of the working half's staged experts over its own PCIe link (MAYA_GLM_PREFILL_CALC, opt-in) #438
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#438
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/270
Author: @sociolog
Created: 10/18/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @mw00
Base:
main← Head:prompt-help📝 Commits (1)
e5a25a7GLM prompt on a split without NVLink: the waiting GPU computes a share of the working half's staged experts over its own PCIe link (MAYA_GLM_PREFILL_CALC, off by default)📊 Changes
3 files changed (+754 additions, -144 deletions)
View changed files
📝
docs/SETTINGS.md(+1 -0)📝
include/strata/core/glm_model.hpp(+5 -0)📝
src/core/glm_prefill.cu(+748 -144)📄 Description
What
On a two-GPU layer split, a prompt of one chunk runs the halves one after the other: while the first GPU runs its
layers, the second GPU and its PCIe link wait, and the other way round. When most routed experts live in the RAM tier,
most of each half is the staging of those experts over the working GPU's own link (
MAYA_GLM_PREFILL_PROF=1, a2K prompt on an RTX 3090 + RTX 3060:
moe_staged67 % of each half; the two halves' stream times add up to the walltime).
MAYA_GLM_DUAL_PREFILL(#121) puts the waiting GPU's link to work through NVLink; without peer access(GeForce cards, no NVLink) its peer copy would cross the working GPU's link anyway. #138 (a short prompt cut into one
chunk per GPU, pipelined) goes after the same idle GPU, but where most experts come from RAM each extra chunk stages
them again: on the machine below it is 3-23 % slower from 1K to 7K tokens (
MAYA_GLM_PREFILL_SHORT=1, one run).MAYA_GLM_PREFILL_CALC=1(off by default): the waiting GPU computes a share of each MoE layer's RAM-tier expertsitself - their weights over its own PCIe link from the working GPU's pinned RAM tier, the chunk's inputs and routes
over the host to it, and the weighted sum of its rows back over the host, added into the layer's output after the
combine. Both links stream at once.
reconstruct + cuBLAS for the rest) move out of
prefill_half's lambdas into file-level functions on an explicitlane (stream, cuBLAS handle, weight scratch, x, row tokens, output window) - unchanged, operation for operation - so
the waiting GPU computes exactly what the working GPU would.
the share the other GPU takes), then a learned share for the waiting GPU (the lightest experts when it has fewer
multiprocessors, else the most routed), the rest on the working GPU. The waiting GPU's rows go last in the sorted
order; the working GPU never computes them.
portable) and up the waiting GPU's link while the working GPU runs the shared expert and the router; the routes go
into mapped memory with the counts (no copy engine).
into a ring of 3 groups of 4 slots, the same products, its window added into a zeroed sum (
moe_combine_add, routeorder), the sum down in 4 pieces; the working GPU uploads each piece as it lands (after the CPU rows' upload) into
the tail of
OUTPc(the CPU rows are capped to leave the chunk's rows there).(
calc_carve; the ring drops to 2 groups if it must, else the mode stays off for that prompt and says so). Pinned:a chunk's sum (T x n_embd floats) a GPU, the routes, x made portable.
waiting GPU's copies never land in a carve still in use and a part's own half never starts its copies while its
share of the other half still reads that carve; a part whose carve held a share sets its MMQ row ids again.
way up) are read at the next one, and the share is nudged until they end together (
MAYA_GLM_PREFILL_CALC_SHAREfixes it).
MAYA_GLM_PREFILL_TRACE=1prints both lane ends per layer,MAYA_GLM_PREFILL_VERBOSE=1the experts androws the waiting GPU computed and the shares.
MAYA_GLM_DUAL_PREFILL(where peer access works that one wins), not in the pipeline (prompts of severalchunks keep both GPUs busy already), EXL3 experts only (an MMQ pack keeps the path as before).
MAYA_GLM_PREFILL_CALC_CHECK=1(debug, synchronous): the working GPU computes the share again and prints how farthe two sums differ, layer by layer.
Checked
turboderp's GLM-5.3-Flash
sc_3.10bpwon RTX 3090 + RTX 3060 (PCIe 4.0 x8 each, no NVLink), Ryzen 9 5900X, 128 GB,layers [0, 28) / [28, 45), most routed experts in the RAM tier (
MAYA_GLM_RAM_RESIDENT=1), the CPU lane on.Prompt time (fresh prompts, two each, one engine start a run, a quiet machine; off / on / off / on interleaved):
MAYA_GLM_PREFILL_CALC=1(The mean of 4 prompts an arm; each arm's runs within 1 % of each other, the arms' ranges apart at every size.
v1.1.15 itself in the same series: the same as off, within 1 %.) The learned shares settle at 0.51-0.55; with
MAYA_GLM_PREFILL_TRACE=1a layer's two lanes end within a few ms of each other. Longer prompts gain less: theirexperts' compute and the attention grow with the tokens while the staged bytes stay about the same.
Answers: the scorer with its context through the prompt path (
MAYA_GLM_SCORE_PREFILL=1: 2,048 tokens ofheld-out prose as one chunk through both halves, the next 650 scored token by token), CPU lane off, against v1.1.15:
MAYA_GLM_PREFILL_CALC=1MAYA_GLM_PREFILL_SUB=512(only the mixers' blocking changes)Not bit-exact by design: the share's rows are summed apart and added after the working GPU's, and cuBLAS may pick other
kernels on the other GPU. The KL is that of any last-bit change in a 2K prefill on this model (the sub-batch control
above: routing near-ties flip).
MAYA_GLM_PREFILL_CALC_CHECK=1over four prompts (168 helped layers): where theRTX 3060 computes for the RTX 3090 (the lightest experts, the tensor-core kernels) its sums are bit-identical to the
3090's own (100 layers, every value equal); where the 3090 computes for the 3060 (the most routed, cuBLAS) rel. L2
3.5e-5 on average, 8.1e-5 at most. Off, the token path and the prompt path are unchanged: the scorer through the
one-token path KL 0.000000 against v1.1.15 with the CPU lane off and on, through the prompt path 0.000000 (lane off).
Memory: nvidia-smi every 2 s through all four runs - the same peaks off and on (RTX 3090 23,601 MiB, RTX 3060
11,467 MiB of 12,288). Pinned RAM: +128 MB a GPU at 8K chunks (the sum), the routes, x made portable.
With the CPU lane on, the prompt's CPU share plan learns from the copy times, so even v1.1.15 is not repeatable from
start to start through the prompt path (against its own dump: KL 0.0163); this branch off 0.0154, on 0.0158.
Not compiled for HIP here (every CUDA call it adds has its mapping in
hip_compat/cuda_runtime.h).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.