[PR #192] GLM expert pool sizing: --expert-cache auto|N and --vram-reserve-mib in the config, checked once the pool is written #385

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

Original Pull Request: https://github.com/mw00/project-maya/pull/192

State: closed
Merged: Yes


What this changes

A GLM pack's expert pool already took the free VRAM less a fixed 700 MB. --expert-cache and --vram-reserve-mib in a
config were parsed and then ignored; only STRATA_GLM_RESERVE_MB in the environment changed anything. This makes the
pool's size a setting in the config's "args":

  • --expert-cache auto (the default; the setup now writes it into every config): the pool takes the free VRAM less
    the reserve, as before, and then checks that budget once it is written. The budget is allocated in 1 GiB pieces
    and zeroed, and the free VRAM is read again. If the card is short of the reserve, the pool gives back the
    difference and is checked again (up to six times). If the driver refuses a piece, the budget ends at what it gave.
    Under Windows an allocation counts only once it is touched, so the free figure read before it can be about 1 GB
    high, and a card filled past it pages GPU memory to system RAM instead of failing: the start looks normal and
    decode is several times slower. On Linux the figure is exact and the check gives nothing back.
  • --expert-cache N (the user's own value): the first GPU's pool holds at most N of its largest experts; a
    split's later GPUs stay on auto. It is not checked once written.
  • --vram-reserve-mib N: the VRAM kept free beside the pool (default 700 MiB, 1024 on a Linux APU), and
    --vram-reserve-later-mib N for a split's later GPUs. Given in the args, they win over the environment
    variables, which keep working.
  • A small card whose default reserve would leave the pool less than a route's experts and the spares in every
    layer lowers the reserve as far as 300 MiB and says so. A reserve set by hand is kept.
  • One budget (Glm5Model::pool_budget) sizes the prompt path's chunk, the pool and the layer-split search, so
    they agree, the check's correction included.
  • At start, each GPU's free VRAM with everything loaded is printed (maya serve: CUDA0: ... MiB of VRAM free with everything loaded). Below 256 MiB (512 on a later GPU) the line adds LOW and the reserve that would leave room.
  • Setup: "--expert-cache", "auto" in every config, a new --vram-reserve-mib N option, and a setup again keeps
    all three settings as they were edited.
  • Docs: docs/SETTINGS.md "The expert pool's size", a docs/SETUP.md row, a docs/WINDOWS.md note.

Measured

EXL3-4.05bpw with the DFlash2 drafter, 32K context, a short greedy run (three questions, 256 tokens each).

Run Expert pool Free VRAM at start Decode tok/s
RTX 3090 alone, --expert-cache auto 14.47 GB, 1,231 slots (as before) 431 MiB 16.9 / 13.5 / 18.1
RTX 3090 alone, a free figure faked 1 GiB high (STRATA_GLM_POOL_CHECK_TEST_MB=1024) + --vram-reserve-mib 1000 13.14 GB, 1,118 slots: the check gave back 1.04 GB 1,791 MiB 17.4 / 13.8 / 17.6
RTX 3090 alone, --expert-cache 600 7.05 GB, exactly 600 slots 8,027 MiB 14.5 / 10.5 / 14.6
RTX 3090 + 8x RTX 5060 Ti, --expert-cache auto 10,839 slots (as before) 596-805 MiB a GPU 71.8 / 37.3 / 66.0
the same, --vram-reserve-later-mib 400 10,988 slots (the 3090's 1,746 unchanged) 310-504 MiB on the later GPUs: LOW 77.4 / 41.8 / 67.2
the same, --expert-cache 1500 the 3090's layers [0, 8) hold every expert (291 slots each), the split search gave it one layer fewer 4,439 MiB on the 3090 68.5 / 35.5 / 65.1

On Linux the sizing is the same as before: the check gives nothing back, the 3090 keeps 1,231 slots and nine GPUs
keep 10,839. With the free figure faked 1 GiB high, the pool gave back 1.04 GB, the prompt chunk was sized from the
same corrected figure (32,768 -> 31,232 tokens), and the card ended with the reserve plus the faked gigabyte free.

One thing the start-up line showed: the 3090 alone with DFlash2 had 431 MiB free at start and 77 MiB after the first
request, because the drafter's verify windows allocate on first use, after the pool is sized. That is fine on Linux,
where a full card fails an allocation instead of paging. On Windows it is a reason to raise the reserve, and
docs/WINDOWS.md says so.

Tests

  • tests/glm_memory_test.cpp: the small-card reserve and the check's give-back (glmfast::pool_reserve,
    glmfast::pool_give_back).
  • tools/test_maya_prefill.py: --expert-cache auto in every config, and a hand-set number and the reserves kept by a
    setup again.
  • Python suites: tools 265 OK, serve 180 OK (3 skipped).
  • The runs above, on Linux. Not run on Windows, so the WDDM case itself is only simulated with the test knob.
**Original Pull Request:** https://github.com/mw00/project-maya/pull/192 **State:** closed **Merged:** Yes --- ## What this changes A GLM pack's expert pool already took the free VRAM less a fixed 700 MB. `--expert-cache` and `--vram-reserve-mib` in a config were parsed and then ignored; only `STRATA_GLM_RESERVE_MB` in the environment changed anything. This makes the pool's size a setting in the config's `"args"`: - **`--expert-cache auto`** (the default; the setup now writes it into every config): the pool takes the free VRAM less the reserve, as before, and then **checks that budget once it is written**. The budget is allocated in 1 GiB pieces and zeroed, and the free VRAM is read again. If the card is short of the reserve, the pool gives back the difference and is checked again (up to six times). If the driver refuses a piece, the budget ends at what it gave. Under Windows an allocation counts only once it is touched, so the free figure read before it can be about 1 GB high, and a card filled past it pages GPU memory to system RAM instead of failing: the start looks normal and decode is several times slower. On Linux the figure is exact and the check gives nothing back. - **`--expert-cache N`** (the user's own value): the first GPU's pool holds at most N of its largest experts; a split's later GPUs stay on auto. It is not checked once written. - **`--vram-reserve-mib N`**: the VRAM kept free beside the pool (default 700 MiB, 1024 on a Linux APU), and **`--vram-reserve-later-mib N`** for a split's later GPUs. Given in the args, they win over the environment variables, which keep working. - **A small card** whose default reserve would leave the pool less than a route's experts and the spares in every layer lowers the reserve as far as 300 MiB and says so. A reserve set by hand is kept. - **One budget** (`Glm5Model::pool_budget`) sizes the prompt path's chunk, the pool and the layer-split search, so they agree, the check's correction included. - **At start**, each GPU's free VRAM with everything loaded is printed (`maya serve: CUDA0: ... MiB of VRAM free with everything loaded`). Below 256 MiB (512 on a later GPU) the line adds `LOW` and the reserve that would leave room. - **Setup**: `"--expert-cache", "auto"` in every config, a new `--vram-reserve-mib N` option, and a setup again keeps all three settings as they were edited. - Docs: `docs/SETTINGS.md` "The expert pool's size", a `docs/SETUP.md` row, a `docs/WINDOWS.md` note. ## Measured EXL3-4.05bpw with the DFlash2 drafter, 32K context, a short greedy run (three questions, 256 tokens each). | Run | Expert pool | Free VRAM at start | Decode tok/s | | --- | --- | --- | --- | | RTX 3090 alone, `--expert-cache auto` | 14.47 GB, 1,231 slots (as before) | 431 MiB | 16.9 / 13.5 / 18.1 | | RTX 3090 alone, a free figure faked 1 GiB high (`STRATA_GLM_POOL_CHECK_TEST_MB=1024`) + `--vram-reserve-mib 1000` | 13.14 GB, 1,118 slots: the check gave back 1.04 GB | 1,791 MiB | 17.4 / 13.8 / 17.6 | | RTX 3090 alone, `--expert-cache 600` | 7.05 GB, exactly 600 slots | 8,027 MiB | 14.5 / 10.5 / 14.6 | | RTX 3090 + 8x RTX 5060 Ti, `--expert-cache auto` | 10,839 slots (as before) | 596-805 MiB a GPU | 71.8 / 37.3 / 66.0 | | the same, `--vram-reserve-later-mib 400` | 10,988 slots (the 3090's 1,746 unchanged) | 310-504 MiB on the later GPUs: `LOW` | 77.4 / 41.8 / 67.2 | | the same, `--expert-cache 1500` | the 3090's layers [0, 8) hold every expert (291 slots each), the split search gave it one layer fewer | 4,439 MiB on the 3090 | 68.5 / 35.5 / 65.1 | On Linux the sizing is the same as before: the check gives nothing back, the 3090 keeps 1,231 slots and nine GPUs keep 10,839. With the free figure faked 1 GiB high, the pool gave back 1.04 GB, the prompt chunk was sized from the same corrected figure (32,768 -> 31,232 tokens), and the card ended with the reserve plus the faked gigabyte free. One thing the start-up line showed: the 3090 alone with DFlash2 had 431 MiB free at start and 77 MiB after the first request, because the drafter's verify windows allocate on first use, after the pool is sized. That is fine on Linux, where a full card fails an allocation instead of paging. On Windows it is a reason to raise the reserve, and `docs/WINDOWS.md` says so. ## Tests - `tests/glm_memory_test.cpp`: the small-card reserve and the check's give-back (`glmfast::pool_reserve`, `glmfast::pool_give_back`). - `tools/test_maya_prefill.py`: `--expert-cache auto` in every config, and a hand-set number and the reserves kept by a setup again. - Python suites: tools 265 OK, serve 180 OK (3 skipped). - The runs above, on Linux. Not run on Windows, so the WDDM case itself is only simulated with the test knob.
bsakaguchi 2026-10-29 21:24: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#385
No description provided.