[PR #70] [MERGED] GLM CPU lane: calibrate on experts read from DRAM, not from the L3 #314

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

📋 Pull Request Information

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

Base: main ← Head: cpu-lane-calibration


📝 Commits (1)

  • 7ce83f9 GLM CPU lane: calibrate on experts read from DRAM, not from the L3

📊 Changes

1 file changed (+16 additions, -7 deletions)

View changed files

📝 src/core/glm_fast_path.cu (+16 -7)

📄 Description

The CPU lane's start-up calibration times the CPU from the L3 cache, but decode reads its RAM-tier experts from DRAM. On a desktop CPU it therefore thinks the CPU is about 1.5x faster than it is. The split then keeps too many RAM-tier experts on the CPU, and the GPU waits for the lane.

Cause. The calibration ran 16 timed calls on the same 4 RAM-tier experts. Four of Maya-S24's 7.5 MB experts are 30 MB, which stays in a 7950X's 64 MB L3 after the first call. Decode reads ~1.1 GB of RAM-tier experts per token, so they always come from DRAM.

Fix. Each warm-up and timed call takes the next 4 of up to 64 RAM-tier experts of the calibration layer (~480 MB), so every timed call reads from DRAM. With fewer than 64 in the tier, the sets repeat sooner. The PCIe timing and STRATA_GLM_CPU_LANE_CHECK still use the first expert. One file, +16 / -7 lines.

Measurements

1x Tesla V100-PCIE-32GB (PCIe 3.0 x16), Ryzen 9 7950X (16C, 64 MB L3, DRAM reads ~57 GB/s), 62 GB RAM, Maya-S24, --max-context 131072, STRATA_GLM_KV_INT8=1. --bench, 8 starts alternating stock and fix:

CPU time an expert Plan (of 0..8 RAM-tier experts the CPU takes) Decode (tok/s)
v1.0.28 0.098 / 0.132 / 0.132 / 0.098 ms 0 1 2 3 4 5 5 6 7 or 0 1 2 3 4 4 5 6 7 24.4 / 25.6 / 25.4 / 24.3 (mean 24.9)
this PR 0.140 / 0.148 / 0.140 / 0.141 ms 0 1 2 3 3 4 5 6 7 every start 26.6 / 26.4 / 26.1 / 26.8 (mean 26.5, +6%)
  • In real decode the lane ran ~146 experts per token in ~23.6 ms, about 0.16 ms an expert (~47 GB/s from DRAM). The new calibration is close to that; the old one was not.
  • The old calibration was also unstable: its starts measured 0.098 or 0.132 ms and chose different plans.
  • Before writing the fix I set plans by hand with STRATA_GLM_CPU_PLAN (v1.0.23, same setup). 0 1 2 3 3 4 5 6 7 was the best of three: 26.9 / 27.5 tok/s, against 25.1 / 25.3 for 0 1 2 3 4 5 5 6 7 and 25.9 / 25.4 for 0 1 2 2 3 4 4 5 6. The fix now picks that plan by itself.
  • Prefill unchanged: 2K 286-296 tok/s in every start; 8K 585-590, except one start of each (fix 533, stock 506).

Not tested

  • Hosts where 64 experts fit in the cache (very large L3 parts): the sets repeat and the time is still a cache time, as before.
  • Two or more GPUs, and the shared CPU pool of 3+ GPU splits: same code path, not run here.

🤖 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/70 **Author:** [@merbanan](https://github.com/merbanan) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/10/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `cpu-lane-calibration` --- ### 📝 Commits (1) - [`7ce83f9`](https://github.com/mw00/project-maya/commit/7ce83f9d86e7012f58222d6f4f0bd67922dfc3e8) GLM CPU lane: calibrate on experts read from DRAM, not from the L3 ### 📊 Changes **1 file changed** (+16 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `src/core/glm_fast_path.cu` (+16 -7) </details> ### 📄 Description The CPU lane's start-up calibration times the CPU from the L3 cache, but decode reads its RAM-tier experts from DRAM. On a desktop CPU it therefore thinks the CPU is about 1.5x faster than it is. The split then keeps too many RAM-tier experts on the CPU, and the GPU waits for the lane. **Cause.** The calibration ran 16 timed calls on the same 4 RAM-tier experts. Four of Maya-S24's 7.5 MB experts are 30 MB, which stays in a 7950X's 64 MB L3 after the first call. Decode reads ~1.1 GB of RAM-tier experts per token, so they always come from DRAM. **Fix.** Each warm-up and timed call takes the next 4 of up to 64 RAM-tier experts of the calibration layer (~480 MB), so every timed call reads from DRAM. With fewer than 64 in the tier, the sets repeat sooner. The PCIe timing and `STRATA_GLM_CPU_LANE_CHECK` still use the first expert. One file, +16 / -7 lines. ## Measurements 1x Tesla V100-PCIE-32GB (PCIe 3.0 x16), Ryzen 9 7950X (16C, 64 MB L3, DRAM reads ~57 GB/s), 62 GB RAM, Maya-S24, `--max-context 131072`, `STRATA_GLM_KV_INT8=1`. `--bench`, 8 starts alternating stock and fix: | | CPU time an expert | Plan (of 0..8 RAM-tier experts the CPU takes) | Decode (tok/s) | |---|---|---|---| | v1.0.28 | 0.098 / 0.132 / 0.132 / 0.098 ms | `0 1 2 3 4 5 5 6 7` or `0 1 2 3 4 4 5 6 7` | 24.4 / 25.6 / 25.4 / 24.3 (mean 24.9) | | this PR | 0.140 / 0.148 / 0.140 / 0.141 ms | `0 1 2 3 3 4 5 6 7` every start | 26.6 / 26.4 / 26.1 / 26.8 (mean 26.5, +6%) | - In real decode the lane ran ~146 experts per token in ~23.6 ms, about 0.16 ms an expert (~47 GB/s from DRAM). The new calibration is close to that; the old one was not. - The old calibration was also unstable: its starts measured 0.098 or 0.132 ms and chose different plans. - Before writing the fix I set plans by hand with `STRATA_GLM_CPU_PLAN` (v1.0.23, same setup). `0 1 2 3 3 4 5 6 7` was the best of three: 26.9 / 27.5 tok/s, against 25.1 / 25.3 for `0 1 2 3 4 5 5 6 7` and 25.9 / 25.4 for `0 1 2 2 3 4 4 5 6`. The fix now picks that plan by itself. - Prefill unchanged: 2K 286-296 tok/s in every start; 8K 585-590, except one start of each (fix 533, stock 506). ## Not tested - Hosts where 64 experts fit in the cache (very large L3 parts): the sets repeat and the time is still a cache time, as before. - Two or more GPUs, and the shared CPU pool of 3+ GPU splits: same code path, not run here. 🤖 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:24:06 +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#314
No description provided.