[PR #24] [MERGED] CPU lane: time the PCIe link with the GPU awake, serve in-flight demotions from RAM instead of disk, per-GPU lane threads #283

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/24
Author: @tanutanu56
Created: 10/8/2026
Status: ✅ Merged
Merged: 10/8/2026
Merged by: @mw00

Base: main ← Head: cpu-lane-link-wake-demote-wait


📝 Commits (1)

  • 6725aa0 CPU lane: time the PCIe link with the GPU awake; serve in-flight demotions from RAM; per-GPU lane threads

📊 Changes

2 files changed (+48 additions, -5 deletions)

View changed files

📝 README.md (+1 -0)
📝 src/core/glm_fast_path.cu (+47 -5)

📄 Description

Fixes the two findings from #13, plus the per-GPU STRATA_GLM_CPU_LANE<n> knob you said was welcome. Rebased on main (v1.0.14).

Changes (src/core/glm_fast_path.cu, README)

  1. fast_cpu_lane_setup: time the link with the GPU awake. A short %globaltimer spin kernel runs on a side stream while the one-expert copies (and the streaming copies for cpu_ps_ms) are timed, after a 400 ms ramp. Without it a consumer card at P8 has its link at Gen1: on an RTX 4070 Ti SUPER (PCIe 3.0 x4) one expert timed 10.1 ms against 2.6 ms awake, and on an RTX 5070 Ti (4.0 x16) 1.93 ms against 0.25 ms, so the plan sent most RAM-tier experts to the CPU on a link that was really 2.5x faster than the CPU. 24 reps instead of 12.
  2. fast_service miss path: a demoted expert whose copy is still landing is read from its RAM slot, not from disk. An expert evicted from VRAM in fast_boundary step (3) sits in kRDemote with its D2H copy in F->draining until the next boundary makes it live. The miss path only took slots in kRLoad/kRNew, so a route needing that expert in the meantime fell through to the disk read. The fix waits on that drain's event (a ~0.3 ms copy against a ~13 ms disk read) and uses the slot. Only entries that are really in F->draining are taken, so the background-move demotions are untouched.
  3. STRATA_GLM_CPU_LANE<n> sets the lane threads for CUDA<n> alone (falls back to STRATA_GLM_CPU_LANE). README Tuning table row added.

Measured

2x consumer GPUs: RTX 4070 Ti SUPER 16 GB (PCIe 3.0 x4) + RTX 5070 Ti 16 GB (PCIe 4.0 x16), Ryzen 7 3700X, 128 GB DDR4, Windows 11, Maya-S, 32K context. Official maya.py --bench, v1.0.14:

decode (tok/s) prefill 2k prefill 8k
main (v1.0.14) 8.1 112 166
this PR, defaults 9.1 118 169
this PR + STRATA_GLM_SPLIT=17, STRATA_GLM_CPU_LANE0=6, STRATA_GLM_CPU_LANE1=2 14.6 187 289

The defaults gain less than on v1.0.11 (where I first measured 7.1 -> 14.6 with the same two fixes), since #12 and --calibrate already improved the start-up guess; the per-GPU thread counts are what the two unequal links need. With the CPU lane off (STRATA_GLM_CPU_LANE=0), 96-token greedy answers: 400 -> 300 ms/token.

Greedy parity

I could not get token-identical output, and I'd rather say why than hide it:

  • main against main, same settings (STRATA_GLM_CPU_LANE=0, STRATA_GLM_RAM_GB=60, STRATA_GLM_NO_SPEC=1, temperature 0, 3 chat prompts + a 2k and a 6k document prompt): identical in all 5.
  • main against this PR, same settings: differs in all 5 (from the first generated token in three of them). The text is the same kind of answer with different wording.
  • main against main with only STRATA_GLM_RAM_GB=45 instead of 60: also differs in 4 of 5 (first differences at token 38, 7, 1, 9). STRATA_GLM_UNIFORM_SLOTS=1 (a different VRAM layout) stays identical.

So on this machine the output depends on where the experts come from (RAM against disk), and this PR changes that mix, so a bit-exact comparison is not a pass/fail test here. I have not found the source of that dependence. Your V100 parity tests would tell if it is specific to my setup.

Not included

--kv int8 --kv-resident 20480 hanging on the second request (reported in #13): I could not reproduce it on v1.0.14 with 9 varied requests (multi-turn, 2.5k-token prompt, Japanese). It was seen on v1.0.11.

🤖 Generated with Claude Code


🔄 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/24 **Author:** [@tanutanu56](https://github.com/tanutanu56) **Created:** 10/8/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `cpu-lane-link-wake-demote-wait` --- ### 📝 Commits (1) - [`6725aa0`](https://github.com/mw00/project-maya/commit/6725aa00ce4e64ace1da102ac7b357bbe5be1e6c) CPU lane: time the PCIe link with the GPU awake; serve in-flight demotions from RAM; per-GPU lane threads ### 📊 Changes **2 files changed** (+48 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+1 -0) 📝 `src/core/glm_fast_path.cu` (+47 -5) </details> ### 📄 Description Fixes the two findings from #13, plus the per-GPU `STRATA_GLM_CPU_LANE<n>` knob you said was welcome. Rebased on main (v1.0.14). ## Changes (`src/core/glm_fast_path.cu`, README) 1. **`fast_cpu_lane_setup`: time the link with the GPU awake.** A short `%globaltimer` spin kernel runs on a side stream while the one-expert copies (and the streaming copies for `cpu_ps_ms`) are timed, after a 400 ms ramp. Without it a consumer card at P8 has its link at Gen1: on an RTX 4070 Ti SUPER (PCIe 3.0 x4) one expert timed 10.1 ms against 2.6 ms awake, and on an RTX 5070 Ti (4.0 x16) 1.93 ms against 0.25 ms, so the plan sent most RAM-tier experts to the CPU on a link that was really 2.5x faster than the CPU. 24 reps instead of 12. 2. **`fast_service` miss path: a demoted expert whose copy is still landing is read from its RAM slot, not from disk.** An expert evicted from VRAM in `fast_boundary` step (3) sits in `kRDemote` with its D2H copy in `F->draining` until the next boundary makes it live. The miss path only took slots in `kRLoad`/`kRNew`, so a route needing that expert in the meantime fell through to the disk read. The fix waits on that drain's event (a ~0.3 ms copy against a ~13 ms disk read) and uses the slot. Only entries that are really in `F->draining` are taken, so the background-move demotions are untouched. 3. **`STRATA_GLM_CPU_LANE<n>`** sets the lane threads for CUDA`<n>` alone (falls back to `STRATA_GLM_CPU_LANE`). README Tuning table row added. ## Measured 2x consumer GPUs: RTX 4070 Ti SUPER 16 GB (PCIe 3.0 x4) + RTX 5070 Ti 16 GB (PCIe 4.0 x16), Ryzen 7 3700X, 128 GB DDR4, Windows 11, Maya-S, 32K context. Official `maya.py --bench`, v1.0.14: | | decode (tok/s) | prefill 2k | prefill 8k | |---|---:|---:|---:| | main (v1.0.14) | 8.1 | 112 | 166 | | this PR, defaults | 9.1 | 118 | 169 | | this PR + `STRATA_GLM_SPLIT=17`, `STRATA_GLM_CPU_LANE0=6`, `STRATA_GLM_CPU_LANE1=2` | **14.6** | **187** | **289** | The defaults gain less than on v1.0.11 (where I first measured 7.1 -> 14.6 with the same two fixes), since #12 and `--calibrate` already improved the start-up guess; the per-GPU thread counts are what the two unequal links need. With the CPU lane off (`STRATA_GLM_CPU_LANE=0`), 96-token greedy answers: 400 -> 300 ms/token. ## Greedy parity I could not get token-identical output, and I'd rather say why than hide it: - main against main, same settings (`STRATA_GLM_CPU_LANE=0`, `STRATA_GLM_RAM_GB=60`, `STRATA_GLM_NO_SPEC=1`, temperature 0, 3 chat prompts + a 2k and a 6k document prompt): **identical** in all 5. - main against this PR, same settings: differs in all 5 (from the first generated token in three of them). The text is the same kind of answer with different wording. - main against main with only `STRATA_GLM_RAM_GB=45` instead of 60: **also differs** in 4 of 5 (first differences at token 38, 7, 1, 9). `STRATA_GLM_UNIFORM_SLOTS=1` (a different VRAM layout) stays identical. So on this machine the output depends on where the experts come from (RAM against disk), and this PR changes that mix, so a bit-exact comparison is not a pass/fail test here. I have not found the source of that dependence. Your V100 parity tests would tell if it is specific to my setup. ## Not included `--kv int8 --kv-resident 20480` hanging on the second request (reported in #13): I could not reproduce it on v1.0.14 with 9 varied requests (multi-turn, 2.5k-token prompt, Japanese). It was seen on v1.0.11. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:23:47 +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#283
No description provided.