[PR #118] [CLOSED] GLM decode: fetch overlap - the resident experts compute while the PCIe fetch is on the link (opt-in, bit-exact) #351

Closed
opened 2026-10-29 21:24:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/118
Author: @q8atnight
Created: 10/11/2026
Status: ❌ Closed

Base: main ← Head: pr/fetch-overlap


📝 Commits (3)

  • e37e7c3 GLM decode: fetch overlap - a route's PCIe fetches on a side stream while the resident experts compute (STRATA_GLM_FETCH_OVERLAP, bit-exact)
  • 9eb294b fetch overlap: the side stream at the highest priority (STRATA_GLM_FETCH_PRIO=0: off); HIP mappings
  • ceda603 docs/SETTINGS.md: STRATA_GLM_FETCH_OVERLAP / _BLOCKS / _PRIO

📊 Changes

6 files changed (+137 additions, -14 deletions)

View changed files

📝 docs/SETTINGS.md (+1 -0)
📝 include/strata/hip_compat/cuda_runtime.h (+2 -0)
📝 include/strata/kernels/glm_fast.hpp (+12 -2)
📝 src/core/glm_fast_path.cu (+76 -3)
📝 src/core/glm_fast_state.hpp (+8 -0)
📝 src/kernels/cuda/glm_fast.cu (+38 -9)

📄 Description

What

STRATA_GLM_FETCH_OVERLAP=1 (off by default). In fast_moe, a route's experts that come over PCIe (moe_fetch) are
copied on a side stream while the experts already in VRAM run their gate/up and down on the main stream. The fetched
ones follow once they have landed.

  • moe_split_plan (one tiny kernel after moe_wait): splits the plan into the resident entries and the fetched ones
    (fetch_src != 0), 8 + 8 device pointers. moe_gate_up / moe_down then run with a MoeDev copy whose
    plan_ptr is one half or the other. The kernels already skip an entry whose plan_ptr is 0, so gate/up needs no
    change. The shared expert's down rides the first gate/up launch, as before.
  • Bit-exact: moe_down gets an optional part_mode. Mode 1 parks each entry's down row values in an 8 x n_embd
    buffer and writes nothing. Mode 2 computes its own entries, takes the others' values from the buffer, then runs the
    same combine in the same plan order. Two launches give bit for bit what one launch gives. Mode 0 (the default) is
    the old kernel path.
  • The side stream at the highest priority (STRATA_GLM_FETCH_PRIO=0 turns that off). At equal priority the expert
    kernels' many blocks filled the SMs first and the fetch started late. STRATA_GLM_FETCH_BLOCKS sets the fetch's
    blocks (default a quarter of the SMs).
  • Off in a captured layer graph (STRATA_GLM_KDA_GRAPH), where the stream fork would be captured with it.
  • HIP: two new runtime names mapped (cudaStreamCreateWithPriority, cudaDeviceGetStreamPriorityRange);
    tools/check_hip_compat.py passes. Not built or run on AMD here.
  • Docs: a row in docs/SETTINGS.md.

Exactness

STRATA_GLM_SCORE=64, 1199 scored tokens (README, serve/frontend.py, CHANGELOG, a German paragraph), reference =
the unmodified v1.0.34 build: KL 0.000000 (max 0.0000), same top token 100.00 %. The same build run twice gives
the same, so the scoring path is deterministic and the check is exact.

Speed

Maya-M, 2x RTX 3090 (PCIe 4.0 x8 each), Ryzen 9 3950X, 128 GB DDR4-3600, STRATA_GLM_RAM_RESIDENT=1,
--max-context 262144 --kv int8. Harness: one engine start per run, the same 18 calibrate prompts, greedy, thinking off,
256 tokens, after 6 warm-up prompts. Every run gets a fresh copy of the usage file. The comparison is per prompt
against interleaved runs without the setting (ratio to the mean of the neighbouring references).

run vs references prompts faster
overlap, 20 blocks, normal priority (1st) +1.9 % 13/18
overlap, 20 blocks, normal priority (2nd) +2.1 % 16/18
overlap, 41 blocks, normal priority +0.5 % 11/18
overlap, 20 blocks, highest priority +2.7 % 16/18
reference vs reference ±0.4 % —

STRATA_GLM_PROF on CUDA0 (layers 0-23): 29.2 → 27.1 ms a token of stream time. The fetch wait still dominates
(12.7 ms a token): this box's x8 links are the bottleneck, and the overlap only hides the resident experts' ~2 ms
behind it.

On a box whose links are faster than its expert kernels, the gain should be larger.
Untested here: one GPU, AMD, and Windows. The change is off by default.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/118 **Author:** [@q8atnight](https://github.com/q8atnight) **Created:** 10/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/fetch-overlap` --- ### 📝 Commits (3) - [`e37e7c3`](https://github.com/mw00/project-maya/commit/e37e7c325c3168b5d3bccbd0d137af51138fb448) GLM decode: fetch overlap - a route's PCIe fetches on a side stream while the resident experts compute (STRATA_GLM_FETCH_OVERLAP, bit-exact) - [`9eb294b`](https://github.com/mw00/project-maya/commit/9eb294bae342fb97c68d64eb787afe9898b37086) fetch overlap: the side stream at the highest priority (STRATA_GLM_FETCH_PRIO=0: off); HIP mappings - [`ceda603`](https://github.com/mw00/project-maya/commit/ceda603a7f8086149d169d6dd9e3bd8b6efb5ae4) docs/SETTINGS.md: STRATA_GLM_FETCH_OVERLAP / _BLOCKS / _PRIO ### 📊 Changes **6 files changed** (+137 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+1 -0) 📝 `include/strata/hip_compat/cuda_runtime.h` (+2 -0) 📝 `include/strata/kernels/glm_fast.hpp` (+12 -2) 📝 `src/core/glm_fast_path.cu` (+76 -3) 📝 `src/core/glm_fast_state.hpp` (+8 -0) 📝 `src/kernels/cuda/glm_fast.cu` (+38 -9) </details> ### 📄 Description ## What `STRATA_GLM_FETCH_OVERLAP=1` (off by default). In `fast_moe`, a route's experts that come over PCIe (`moe_fetch`) are copied on a side stream while the experts already in VRAM run their gate/up and down on the main stream. The fetched ones follow once they have landed. - `moe_split_plan` (one tiny kernel after `moe_wait`): splits the plan into the resident entries and the fetched ones (`fetch_src != 0`), 8 + 8 device pointers. `moe_gate_up` / `moe_down` then run with a `MoeDev` copy whose `plan_ptr` is one half or the other. The kernels already skip an entry whose `plan_ptr` is 0, so gate/up needs no change. The shared expert's down rides the first gate/up launch, as before. - **Bit-exact:** `moe_down` gets an optional `part_mode`. Mode 1 parks each entry's down row values in an 8 x n_embd buffer and writes nothing. Mode 2 computes its own entries, takes the others' values from the buffer, then runs the same combine in the same plan order. Two launches give bit for bit what one launch gives. Mode 0 (the default) is the old kernel path. - **The side stream at the highest priority** (`STRATA_GLM_FETCH_PRIO=0` turns that off). At equal priority the expert kernels' many blocks filled the SMs first and the fetch started late. `STRATA_GLM_FETCH_BLOCKS` sets the fetch's blocks (default a quarter of the SMs). - Off in a captured layer graph (`STRATA_GLM_KDA_GRAPH`), where the stream fork would be captured with it. - HIP: two new runtime names mapped (`cudaStreamCreateWithPriority`, `cudaDeviceGetStreamPriorityRange`); `tools/check_hip_compat.py` passes. Not built or run on AMD here. - Docs: a row in `docs/SETTINGS.md`. ## Exactness `STRATA_GLM_SCORE=64`, 1199 scored tokens (README, `serve/frontend.py`, CHANGELOG, a German paragraph), reference = the unmodified v1.0.34 build: **KL 0.000000 (max 0.0000), same top token 100.00 %**. The same build run twice gives the same, so the scoring path is deterministic and the check is exact. ## Speed Maya-M, 2x RTX 3090 (PCIe 4.0 x8 each), Ryzen 9 3950X, 128 GB DDR4-3600, `STRATA_GLM_RAM_RESIDENT=1`, `--max-context 262144 --kv int8`. Harness: one engine start per run, the same 18 calibrate prompts, greedy, thinking off, 256 tokens, after 6 warm-up prompts. Every run gets a fresh copy of the usage file. The comparison is per prompt against interleaved runs without the setting (ratio to the mean of the neighbouring references). | run | vs references | prompts faster | |---|---:|---:| | overlap, 20 blocks, normal priority (1st) | +1.9 % | 13/18 | | overlap, 20 blocks, normal priority (2nd) | +2.1 % | 16/18 | | overlap, 41 blocks, normal priority | +0.5 % | 11/18 | | **overlap, 20 blocks, highest priority** | **+2.7 %** | **16/18** | | reference vs reference | ±0.4 % | — | `STRATA_GLM_PROF` on CUDA0 (layers 0-23): 29.2 → 27.1 ms a token of stream time. The fetch wait still dominates (12.7 ms a token): this box's x8 links are the bottleneck, and the overlap only hides the resident experts' ~2 ms behind it. On a box whose links are faster than its expert kernels, the gain should be larger. Untested here: one GPU, AMD, and Windows. The change is off by default. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:24:32 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#351
No description provided.