mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #121] [MERGED] GLM prompt: dual-link staging - the waiting GPU of a two-GPU split stages every second expert over its own PCIe link + NVLink (opt-in) #353
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#353
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/121
Author: @q8atnight
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @mw00
Base:
main← Head:pr/dual-prefill📝 Commits (4)
511e5d1GLM prompt: dual-link staging - in a two-GPU split's serial prompt the waiting GPU stages every second expert through its own PCIe link + NVLink (STRATA_GLM_DUAL_PREFILL)c309d0ehip_compat: cudaErrorPeerAccessAlreadyEnabled (dual-link prompt staging)2d922b0docs/SETTINGS.md: STRATA_GLM_DUAL_PREFILL75dc842bench/p2p_fetch_probe.cu: what two GPUs' PCIe links + NVLink deliver into one GPU (copy kernels, DMA, two-hop)📊 Changes
5 files changed (+245 additions, -0 deletions)
View changed files
➕
bench/p2p_fetch_probe.cu(+140 -0)📝
docs/SETTINGS.md(+1 -0)📝
include/strata/core/glm_model.hpp(+2 -0)📝
include/strata/hip_compat/cuda_runtime.h(+1 -0)📝
src/core/glm_prefill.cu(+101 -0)📄 Description
Why
A prompt of up to one chunk (
--prefill, 32K here) runs the split's two halves one after the other. While one GPUworks through its layers, the other GPU and its PCIe link wait. On this box, staging the experts that aren't in VRAM
is about two thirds of the prompt time for short and mid-size prompts (
STRATA_GLM_PREFILL_PROF, 1K + 4K prompts:moe_staged65.7 % / 64.6 % of the two GPUs' stream time). So the prompt is bound by one x8 link.What
STRATA_GLM_DUAL_PREFILL=1(off by default). It runs only on the serial path ofprefill_run(one chunk, orSTRATA_GLM_PREFILL_SERIAL) with two parts that can reach each other's memory.j) goes from the host into the waiting GPU's owngbufslot
(b, j)over its own PCIe link (that GPU'scopystream). From there it goes peer to peer into the workingGPU's group buffer (
cudaMemcpyPeerAsync, over NVLink). The working GPU waits for that copy (ev_hready[b], anevent on the helper's device) and for its own copy before
run_set.(
ev_hidle), so itsgbufis free.dual_prefill_ready()runs once: it enables peer access both ways and creates the events. If anything fails, theprompt stages as before.
with this on is 1168 tokens/s, against 1468 pipelined.
Why two hops: a direct H2D
cudaMemcpyAsyncinto GPU 0 issued on a GPU 1 stream still rides GPU 0's link(measured 13.3 GB/s, the same as one link). Staging in GPU 1 and then a peer copy gave 20.8 GB/s into GPU 0
(
bench/p2p_fetch_probe.cu, below). Without NVLink the peer copy would cross GPU 0's link anyway, so expect no gainon PCIe-only peer access.
Exactness
STRATA_GLM_SCORE=3000+STRATA_GLM_SCORE_PREFILL=1(a 3000-token context through the prompt path, then 400 scoredtokens), reference = unmodified v1.0.34: KL 0.000000, same top token 100 %. The same holds with
STRATA_GLM_PREFILL_CPU=0.Caveat: the prompt's CPU-share plan learns from the measured copy times. Faster copies can move different experts to
the CPU, which changes the last bits, as any timing change does. One experimental variant here (prestage split too)
showed KL 0.0016 that way. With the CPU share off, that variant was exact as well.
Speed
Maya-M, 2x RTX 3090 (PCIe 4.0 x8 each, NVLink bridge), Ryzen 9 3950X, 128 GB DDR4-3600, RAM-resident. Fresh text,
no conversation reuse; each length runs twice and the second run counts. Tokens/s:
Probe of the links (engine stopped, 16 x 8.6 MB experts into GPU 0):
HIP: one error name mapped (
cudaErrorPeerAccessAlreadyEnabled);tools/check_hip_compat.pypasses. Not run on AMDor Windows here. Docs: a row in
docs/SETTINGS.md.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.