[PR #60] [MERGED] One CPU lane pool for a split of 3+ GPUs (9 GPUs: decode 25.7 -> 30.7 tok/s); calibration on fresh prompts and a copy of the usage file #308

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/60
Author: @needmorevram
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @mw00

Base: main ← Head: glm-cpu-lane-threads


📝 Commits (1)

  • d772eab One CPU lane pool for a split of 3+ GPUs, sized as one GPU's (decode on 9 GPUs 25.7 -> 30.7 tok/s); the calibration measures on fresh prompts and works on a copy of the expert usage file

📊 Changes

5 files changed (+193 additions, -30 deletions)

View changed files

📝 README.md (+10 -5)
📝 src/core/glm_fast_path.cu (+46 -12)
📝 src/core/glm_fast_state.hpp (+4 -2)
📝 tools/calibrate_glm.py (+73 -11)
📝 tools/test_calibrate_glm.py (+60 -0)

📄 Description

Summary

Two fixes to how the GLM engine uses the CPU, found on a 9-GPU split:

  1. CPU threads on a split of 3+ GPUs. Each GPU used to get its own CPU lane pool of cores / GPUs threads (9 on a 9-GPU, 88-vCPU host). A decode token visits the cards one after another, so only one card's 9 threads ever worked and most of the CPU sat idle. Now one pool serves every card in turn, sized the same way as one GPU's pool. This is what Strata does: one expert pool for the whole process.
  2. Calibration (--calibrate) measured an unrealistic case and rewrote the user's usage profile.

How CPU threads are chosen

Split Before After
1 GPU physical cores, at most one NUMA node's less 4 unchanged
2 GPUs a pool per GPU, half the cores each, pinned per #44 unchanged: the pipelined speculative decode runs both cards at once
3+ GPUs a pool per GPU, cores / GPUs threads each one pool shared by all GPUs, sized as one GPU's (here 40), unpinned like one GPU's
  • Shared use: the shared pool runs one batch at a time. When a long prompt's chunks are pipelined across the cards, they take it in turn.
  • Overrides:
    • STRATA_GLM_CPU_SHARED=0 gives a pool per GPU again (A/B).
    • STRATA_GLM_CPU_SHARED=1 shares the pool on two GPUs too.
    • A card given its own count (STRATA_GLM_CPU_LANE<n>) keeps a pool of its own.

Benchmark: 9 GPUs

Setup: Maya-L (156 GB) on 8x RTX 5060 Ti 16 GB + RTX 3090 24 GB, 2x Xeon Gold 6152 (88 vCPUs, 2 NUMA nodes), 177 GB RAM, 32K context.

Method: the same build and harness for both rows, A/B'd with STRATA_GLM_CPU_SHARED=0. Greedy decode, thinking off, 256 tokens an answer, 3 rounds of 3 prompts, each prompt new to the engine (see the calibration change below), then one 8192-token prompt.

Decode VRAM hit CPU time per RAM-tier expert 8K prompt
A pool per GPU (9 threads each) 25.7 tok/s 95.9% 0.74 ms 1265 tok/s
One shared pool (40 threads) 30.7 tok/s 95.7% 0.32 ms 1466 tok/s

That's +19% decode and +16% on the 8K prompt.

  • Per-request A/B: in the same engine run, limiting the shared pool to 9 threads per request gave 25.4 tok/s, so the gain comes from the thread count.
  • Real chat: with the old pools, a real chat (thinking, temperature 1.0) on this machine ran at 24–25 tok/s. That matches the "before" row.
  • Measured base: this was measured with the change on v1.0.20, before #44. On v1.0.24 a pool per GPU is also pinned (#44), so the "before" row there may differ somewhat; the shared pool's code is unchanged.

Benchmark: 2 GPUs (why two GPUs keep a pool each)

Setup: 3090 + 5060 Ti, same model. Within each pair the layer split and the CPU/PCIe plan are fixed (STRATA_GLM_PCIE_SHARE=0), so only the pool layout differs.

One shared pool (STRATA_GLM_CPU_SHARED=1) A pool per GPU, pinned (default)
MTP drafting on (both cards at once), split 27 19.65 tok/s · 8K prompt 380 19.99 tok/s · 8K prompt 395
MTP drafting off (cards take turns), split 33 19.38 tok/s · 8K prompt 388 16.74 tok/s · 8K prompt 392
  • MTP on: the two layouts tie, so the default stays a pool per GPU.
  • MTP off: the shared pool is ahead (+16%). That's available with STRATA_GLM_CPU_SHARED=1.

Calibration (tools/calibrate_glm.py)

  • Fresh prompts for every measurement. The tuning used to answer the same 3 prompts dozens of times, so the expert tiers ended up holding exactly those answers' experts.
    • On 9 GPUs it measured at a 99.2% VRAM hit rate, with 2.6 experts per token on the CPU, and reported 31.8 tok/s. A real chat on the same engine had 95–96%, 13–16 experts per token on the CPU, and 24–25 tok/s.
    • So the CPU lane's settings (PCIe share, threads) were chosen with almost no work on the CPU, and the thread sweep came out flat.
    • Now each measurement takes the next group of 3 from 60 prompts (code, an explanation, a list).
    • Result on 9 GPUs with the shared pool: the hit rate stays at 97.4–97.7% through the run, and the thread sweep separates (40 threads 31.8 tok/s, 20: 29.7, 10: 29.3).
  • A copy of the expert usage file. The engine saves expert_usage.txt after every answer, and the next start loads the experts into VRAM in that order, so the tuning's answers were rewriting the user's profile. The calibration's engine now reads and writes a copy in a temporary folder. The user's file was unchanged after more than 100 calibration and benchmark answers.

Output

As CONTRIBUTING notes, which expert runs on the CPU or the GPU can change the last bits. With the faster pool, the start-up plan hands more RAM-tier experts to the CPU (9 GPUs: 0 1 2 3 4 4 5 6 7 becomes 0 1 2 3 4 5 6 7 8 on CUDA0). I did not compare greedy tokens.

Changes

  • src/core/glm_fast_path.cu: shared_cpu_pool(), and the thread rule for a shared pool in fast_cpu_lane_setup (sized as one GPU's, less a core for each other card's service thread; #44's pinning only for per-GPU pools).
  • src/core/glm_fast_state.hpp: cpu_pool becomes a shared_ptr, and Workers::run takes one batch at a time.
  • tools/calibrate_glm.py: the 60 prompts, Session.next_group, usage_copy.
  • README.md: STRATA_GLM_CPU_LANE's default, a STRATA_GLM_CPU_SHARED row, the STRATA_GLM_CPU_PIN row's scope, the tuning paragraph.
  • tools/test_calibrate_glm.py: 4 tests (no prompt repeats in a run, the prompt groups, usage_copy, run() uses a copy).

Checks

  • python tools/check_hip_compat.py: every CUDA name has a mapping (no new CUDA calls).
  • The engine builds (CUDA, sm_86 + sm_120).
  • All 18 Python test files pass.
  • The full --calibrate run on 9 GPUs completed (650 s) and kept the engine's own settings.

🔄 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/60 **Author:** [@needmorevram](https://github.com/needmorevram) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `glm-cpu-lane-threads` --- ### 📝 Commits (1) - [`d772eab`](https://github.com/mw00/project-maya/commit/d772eab0a7cbd7b5f694f7ba76597cc542b88207) One CPU lane pool for a split of 3+ GPUs, sized as one GPU's (decode on 9 GPUs 25.7 -> 30.7 tok/s); the calibration measures on fresh prompts and works on a copy of the expert usage file ### 📊 Changes **5 files changed** (+193 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+10 -5) 📝 `src/core/glm_fast_path.cu` (+46 -12) 📝 `src/core/glm_fast_state.hpp` (+4 -2) 📝 `tools/calibrate_glm.py` (+73 -11) 📝 `tools/test_calibrate_glm.py` (+60 -0) </details> ### 📄 Description ## Summary Two fixes to how the GLM engine uses the CPU, found on a 9-GPU split: 1. **CPU threads on a split of 3+ GPUs.** Each GPU used to get its own CPU lane pool of `cores / GPUs` threads (9 on a 9-GPU, 88-vCPU host). A decode token visits the cards one after another, so only one card's 9 threads ever worked and most of the CPU sat idle. Now one pool serves every card in turn, sized the same way as one GPU's pool. This is what Strata does: one expert pool for the whole process. 2. **Calibration (`--calibrate`) measured an unrealistic case and rewrote the user's usage profile.** ## How CPU threads are chosen | Split | Before | After | |---|---|---| | 1 GPU | physical cores, at most one NUMA node's less 4 | unchanged | | 2 GPUs | a pool per GPU, half the cores each, pinned per #44 | unchanged: the pipelined speculative decode runs both cards at once | | 3+ GPUs | a pool per GPU, `cores / GPUs` threads each | **one pool shared by all GPUs, sized as one GPU's** (here 40), unpinned like one GPU's | - **Shared use:** the shared pool runs one batch at a time. When a long prompt's chunks are pipelined across the cards, they take it in turn. - **Overrides:** - `STRATA_GLM_CPU_SHARED=0` gives a pool per GPU again (A/B). - `STRATA_GLM_CPU_SHARED=1` shares the pool on two GPUs too. - A card given its own count (`STRATA_GLM_CPU_LANE<n>`) keeps a pool of its own. ### Benchmark: 9 GPUs **Setup:** Maya-L (156 GB) on 8x RTX 5060 Ti 16 GB + RTX 3090 24 GB, 2x Xeon Gold 6152 (88 vCPUs, 2 NUMA nodes), 177 GB RAM, 32K context. **Method:** the same build and harness for both rows, A/B'd with `STRATA_GLM_CPU_SHARED=0`. Greedy decode, thinking off, 256 tokens an answer, 3 rounds of 3 prompts, each prompt new to the engine (see the calibration change below), then one 8192-token prompt. | | Decode | VRAM hit | CPU time per RAM-tier expert | 8K prompt | |---|---|---|---|---| | A pool per GPU (9 threads each) | 25.7 tok/s | 95.9% | 0.74 ms | 1265 tok/s | | One shared pool (40 threads) | **30.7 tok/s** | 95.7% | **0.32 ms** | **1466 tok/s** | That's **+19% decode** and **+16% on the 8K prompt**. - **Per-request A/B:** in the same engine run, limiting the shared pool to 9 threads per request gave 25.4 tok/s, so the gain comes from the thread count. - **Real chat:** with the old pools, a real chat (thinking, temperature 1.0) on this machine ran at 24–25 tok/s. That matches the "before" row. - **Measured base:** this was measured with the change on v1.0.20, before #44. On v1.0.24 a pool per GPU is also pinned (#44), so the "before" row there may differ somewhat; the shared pool's code is unchanged. ### Benchmark: 2 GPUs (why two GPUs keep a pool each) **Setup:** 3090 + 5060 Ti, same model. Within each pair the layer split and the CPU/PCIe plan are fixed (`STRATA_GLM_PCIE_SHARE=0`), so only the pool layout differs. | | One shared pool (`STRATA_GLM_CPU_SHARED=1`) | A pool per GPU, pinned (default) | |---|---|---| | MTP drafting on (both cards at once), split 27 | 19.65 tok/s · 8K prompt 380 | 19.99 tok/s · 8K prompt 395 | | MTP drafting off (cards take turns), split 33 | 19.38 tok/s · 8K prompt 388 | 16.74 tok/s · 8K prompt 392 | - **MTP on:** the two layouts tie, so the default stays a pool per GPU. - **MTP off:** the shared pool is ahead (+16%). That's available with `STRATA_GLM_CPU_SHARED=1`. ## Calibration (`tools/calibrate_glm.py`) - **Fresh prompts for every measurement.** The tuning used to answer the same 3 prompts dozens of times, so the expert tiers ended up holding exactly those answers' experts. - On 9 GPUs it measured at a 99.2% VRAM hit rate, with 2.6 experts per token on the CPU, and reported 31.8 tok/s. A real chat on the same engine had 95–96%, 13–16 experts per token on the CPU, and 24–25 tok/s. - So the CPU lane's settings (PCIe share, threads) were chosen with almost no work on the CPU, and the thread sweep came out flat. - Now each measurement takes the next group of 3 from 60 prompts (code, an explanation, a list). - Result on 9 GPUs with the shared pool: the hit rate stays at 97.4–97.7% through the run, and the thread sweep separates (40 threads 31.8 tok/s, 20: 29.7, 10: 29.3). - **A copy of the expert usage file.** The engine saves `expert_usage.txt` after every answer, and the next start loads the experts into VRAM in that order, so the tuning's answers were rewriting the user's profile. The calibration's engine now reads and writes a copy in a temporary folder. The user's file was unchanged after more than 100 calibration and benchmark answers. ## Output As CONTRIBUTING notes, which expert runs on the CPU or the GPU can change the last bits. With the faster pool, the start-up plan hands more RAM-tier experts to the CPU (9 GPUs: `0 1 2 3 4 4 5 6 7` becomes `0 1 2 3 4 5 6 7 8` on CUDA0). I did not compare greedy tokens. ## Changes - `src/core/glm_fast_path.cu`: `shared_cpu_pool()`, and the thread rule for a shared pool in `fast_cpu_lane_setup` (sized as one GPU's, less a core for each other card's service thread; #44's pinning only for per-GPU pools). - `src/core/glm_fast_state.hpp`: `cpu_pool` becomes a `shared_ptr`, and `Workers::run` takes one batch at a time. - `tools/calibrate_glm.py`: the 60 prompts, `Session.next_group`, `usage_copy`. - `README.md`: `STRATA_GLM_CPU_LANE`'s default, a `STRATA_GLM_CPU_SHARED` row, the `STRATA_GLM_CPU_PIN` row's scope, the tuning paragraph. - `tools/test_calibrate_glm.py`: 4 tests (no prompt repeats in a run, the prompt groups, `usage_copy`, `run()` uses a copy). ## Checks - `python tools/check_hip_compat.py`: every CUDA name has a mapping (no new CUDA calls). - The engine builds (CUDA, sm_86 + sm_120). - All 18 Python test files pass. - The full `--calibrate` run on 9 GPUs completed (650 s) and kept the engine's own settings. --- <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:03 +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#308
No description provided.