[PR #44] [MERGED] GLM split and prompt chunks: --layer-split auto, --prefill auto | N, per-GPU CPU lane pinning, RAM-tier huge-page fix #297

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

📋 Pull Request Information

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

Base: main ← Head: glm-split-prefill


📝 Commits (1)

  • dee8818 GLM split and prompt chunks: --layer-split auto prices every placement, --prefill auto | N sizes the chunk from each card's pool, each GPU's CPU lane on CPUs of its own, the RAM tier's huge pages only when free 2 MB blocks cover it

📊 Changes

9 files changed (+1191 additions, -188 deletions)

View changed files

📝 README.md (+26 -2)
📝 include/strata/core/glm_model.hpp (+11 -0)
📝 maya.py (+44 -1)
📝 src/core/glm_fast_path.cu (+198 -4)
📝 src/core/glm_fast_state.hpp (+28 -3)
📝 src/core/glm_model.cu (+534 -79)
📝 src/core/glm_prefill.cu (+251 -99)
📝 src/program/generate.cpp (+14 -0)
➕ tools/test_maya_prefill.py (+85 -0)

📄 Description

Summary

This adds an automatic layer split and prompt-chunk sizing to the GLM path. It also makes a split's CPU lanes pin to their own CPUs on any machine and fixes a RAM-tier stall on the second GPU. Nothing is tuned to one machine. Every number is derived at load time from the cards, the host and the pack.

Before the layers load, every placement on 2–4 GPUs is priced by the decode time it predicts:

  • Room: each card's room for experts, after its layers' dense weights, state, head, MTP block and reserve.
  • Coverage: the share of each layer's routes covered by the experts that card then holds. This uses the machine's usage counts, or a coverage curve when there are none.
  • Layer time: each layer's reads over the card's memory bandwidth (memory clock × bus width).
  • Miss time: each miss over the host's RAM read speed, measured at start.

The fastest placement that every card can start (pool floor plus a 512-token chunk) is chosen. A two-GPU split with MTP drafting is priced by its slower card; other cases add up the cards. Ties go to the balanced placement. With more than 4 GPUs the split stays by free VRAM. STRATA_GLM_SPLIT_LOG=1 prints every placement.

--prefill auto | N | 0: chunk calculation

  • auto (written by setup): the largest chunk on the 256-token grid, up to 8192, whose buffers each card's expert pool can lend. A card lends up to 90% of its slots, or 85% when under 90% of the expert bytes are held pinned. A route's experts plus the spares always stay. The prestage buffer is the ring.
  • N (e.g. 32768, a plain number): that chunk, halved until the pool can lend it.
  • 0: token by token.
  • Split: a split uses the smallest card's chunk and logs which card limits it. The other cards' pinned staging is capped to that size.
  • Setup:
    • maya.py keeps an edited value when setup runs again.
    • It suggests --prefill 32768 with 96 GB of RAM or more.
    • It warns about chunks above 8192 under 64 GB.

STRATA_GLM_CPU_PIN: per-GPU CPU lanes on CPUs of their own

Each part of a split gets its own CPUs:

  • Enough NUMA nodes: a whole node per part, and each GPU's own node when the GPUs are on different ones.
  • Otherwise: an even share of one node's physical cores, with SMT siblings kept together.

The process affinity mask is respected. Before this change, the parts' pools shared cores: one part's idle workers spun while the other worked. STRATA_GLM_CPU_PIN=0 turns pinning off for A/B tests.

RAM tier: huge pages only when free 2 MB blocks cover it

MADV_HUGEPAGE is now applied only when /proc/buddyinfo shows enough free blocks of order ≥ 9 to cover the tier. A split's second card used to pin its tier after the first had taken most of the RAM. On fragmented memory it sat in kernel compaction for over 10 minutes. With 4 KB pages the same tier (34.8 GB) pins in 12 s.

Measurements

Measured with a 137 GB community 3.5-bit quant of GLM-5.3-Flash (Q3_K/Q2_K experts; not one of the setup's downloads). Prompt speeds are in tokens/s:

Setup 7.8K 8.4K 14.8K 26.6K
RTX 3090, --prefill auto (8192-token chunks) 482 466 532 491
RTX 3090, --prefill 32768 473 529 764 970
RTX 3090 + RTX 5060 Ti, --prefill auto (8192) 430 501 648 727
  • RTX 3090 + RTX 5060 Ti prompt at 26.6K: 423 → 727 tok/s with --prefill auto.
  • Decode on the same split, 2× Xeon Gold 6152, with CPU pinning: 15.4 → 19.8 tok/s.
  • The split search balances the cards: 26 layers on the first card with MTP drafting, 29 without.

Changes

  • src/core/glm_model.cu: split search (glm_search_bounds, host_read_bps), split setup, and the smallest-card chunk cap.
  • src/core/glm_prefill.cu: prefill_mode, the auto | N chunk bisection, prefill_cap / prefill_settle.
  • src/core/glm_fast_path.cu, src/core/glm_fast_state.hpp: part_cpus pinning, pool_avail, the buddyinfo huge-page check.
  • include/strata/core/glm_model.hpp, src/program/generate.cpp: the new members and passing --prefill through.
  • maya.py: --prefill auto in the config's args, kept across setup runs, plus the RAM tips.
  • README.md: --prefill options and measured table, the split search, the pinning and env rows.
  • tools/test_maya_prefill.py: 2 new tests.

Testing

  • Full build passes.
  • All 17 Python test files pass, including the new tools/test_maya_prefill.py.
  • Benchmarked on RTX 3090 alone and RTX 3090 + RTX 5060 Ti (decode and 7.8K–26.6K prompts), as in the table above.

🔄 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/44 **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-split-prefill` --- ### 📝 Commits (1) - [`dee8818`](https://github.com/mw00/project-maya/commit/dee8818c2a597c5726053bc1fc071c64b33c7db0) GLM split and prompt chunks: --layer-split auto prices every placement, --prefill auto | N sizes the chunk from each card's pool, each GPU's CPU lane on CPUs of its own, the RAM tier's huge pages only when free 2 MB blocks cover it ### 📊 Changes **9 files changed** (+1191 additions, -188 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+26 -2) 📝 `include/strata/core/glm_model.hpp` (+11 -0) 📝 `maya.py` (+44 -1) 📝 `src/core/glm_fast_path.cu` (+198 -4) 📝 `src/core/glm_fast_state.hpp` (+28 -3) 📝 `src/core/glm_model.cu` (+534 -79) 📝 `src/core/glm_prefill.cu` (+251 -99) 📝 `src/program/generate.cpp` (+14 -0) ➕ `tools/test_maya_prefill.py` (+85 -0) </details> ### 📄 Description ## Summary This adds an automatic layer split and prompt-chunk sizing to the GLM path. It also makes a split's CPU lanes pin to their own CPUs on any machine and fixes a RAM-tier stall on the second GPU. Nothing is tuned to one machine. Every number is derived at load time from the cards, the host and the pack. ### `--layer-split auto`: split search Before the layers load, every placement on 2–4 GPUs is priced by the decode time it predicts: - **Room:** each card's room for experts, after its layers' dense weights, state, head, MTP block and reserve. - **Coverage:** the share of each layer's routes covered by the experts that card then holds. This uses the machine's usage counts, or a coverage curve when there are none. - **Layer time:** each layer's reads over the card's memory bandwidth (memory clock × bus width). - **Miss time:** each miss over the host's RAM read speed, measured at start. The fastest placement that every card can start (pool floor plus a 512-token chunk) is chosen. A two-GPU split with MTP drafting is priced by its slower card; other cases add up the cards. Ties go to the balanced placement. With more than 4 GPUs the split stays by free VRAM. `STRATA_GLM_SPLIT_LOG=1` prints every placement. ### `--prefill auto | N | 0`: chunk calculation - **`auto`** (written by setup): the largest chunk on the 256-token grid, up to 8192, whose buffers each card's expert pool can lend. A card lends up to 90% of its slots, or 85% when under 90% of the expert bytes are held pinned. A route's experts plus the spares always stay. The prestage buffer is the ring. - **`N`** (e.g. `32768`, a plain number): that chunk, halved until the pool can lend it. - **`0`**: token by token. - **Split:** a split uses the smallest card's chunk and logs which card limits it. The other cards' pinned staging is capped to that size. - **Setup:** - `maya.py` keeps an edited value when setup runs again. - It suggests `--prefill 32768` with 96 GB of RAM or more. - It warns about chunks above 8192 under 64 GB. ### `STRATA_GLM_CPU_PIN`: per-GPU CPU lanes on CPUs of their own Each part of a split gets its own CPUs: - **Enough NUMA nodes:** a whole node per part, and each GPU's own node when the GPUs are on different ones. - **Otherwise:** an even share of one node's physical cores, with SMT siblings kept together. The process affinity mask is respected. Before this change, the parts' pools shared cores: one part's idle workers spun while the other worked. `STRATA_GLM_CPU_PIN=0` turns pinning off for A/B tests. ### RAM tier: huge pages only when free 2 MB blocks cover it `MADV_HUGEPAGE` is now applied only when `/proc/buddyinfo` shows enough free blocks of order ≥ 9 to cover the tier. A split's second card used to pin its tier after the first had taken most of the RAM. On fragmented memory it sat in kernel compaction for over 10 minutes. With 4 KB pages the same tier (34.8 GB) pins in 12 s. ## Measurements Measured with a 137 GB community 3.5-bit quant of GLM-5.3-Flash (Q3_K/Q2_K experts; not one of the setup's downloads). Prompt speeds are in tokens/s: | Setup | 7.8K | 8.4K | 14.8K | 26.6K | | --- | --- | --- | --- | --- | | RTX 3090, `--prefill auto` (8192-token chunks) | 482 | 466 | 532 | 491 | | RTX 3090, `--prefill 32768` | 473 | 529 | 764 | 970 | | RTX 3090 + RTX 5060 Ti, `--prefill auto` (8192) | 430 | 501 | 648 | 727 | - RTX 3090 + RTX 5060 Ti prompt at 26.6K: 423 → 727 tok/s with `--prefill auto`. - Decode on the same split, 2× Xeon Gold 6152, with CPU pinning: 15.4 → 19.8 tok/s. - The split search balances the cards: 26 layers on the first card with MTP drafting, 29 without. ## Changes - `src/core/glm_model.cu`: split search (`glm_search_bounds`, `host_read_bps`), split setup, and the smallest-card chunk cap. - `src/core/glm_prefill.cu`: `prefill_mode`, the `auto | N` chunk bisection, `prefill_cap` / `prefill_settle`. - `src/core/glm_fast_path.cu`, `src/core/glm_fast_state.hpp`: `part_cpus` pinning, `pool_avail`, the buddyinfo huge-page check. - `include/strata/core/glm_model.hpp`, `src/program/generate.cpp`: the new members and passing `--prefill` through. - `maya.py`: `--prefill auto` in the config's args, kept across setup runs, plus the RAM tips. - `README.md`: `--prefill` options and measured table, the split search, the pinning and env rows. - `tools/test_maya_prefill.py`: 2 new tests. ## Testing - Full build passes. - All 17 Python test files pass, including the new `tools/test_maya_prefill.py`. - Benchmarked on RTX 3090 alone and RTX 3090 + RTX 5060 Ti (decode and 7.8K–26.6K prompts), as in the table above. --- <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:54 +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#297
No description provided.