[PR #654] Qwen CYBER-FROST on RAM-short PCs: unbuffered expert reads, context leaves VRAM to experts #652

Open
opened 2026-10-29 21:27:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/654
Author: @mw00
Created: 10/29/2026
Status: 🔄 Open

Base: main ← Head: cf-mercury-1137


📝 Commits (1)

  • ee47bb6 Experts that no tier holds are read unbuffered; Qwen setup keeps VRAM for experts on RAM-short PCs

📊 Changes

4 files changed (+140 additions, -18 deletions)

View changed files

📝 include/strata/core/expert_source.hpp (+7 -1)
📝 maya.py (+6 -4)
📝 src/core/expert_source.cpp (+123 -13)
📝 tools/test_setup_qwen.py (+4 -0)

📄 Description

CYBER-FROST (Q5_K_M, 112.5 GB) on a Tesla V100 32 GB + 30 GB RAM + NVMe decoded ~6.6 tok/s, far below the same model on a V100 with 61 GB RAM.

Cause. Experts that neither VRAM (21 GiB) nor the RAM tier (22 GiB) holds are ~40% of the model; they are read from the GGUF when routed. A decode then pulls ~2 GB/s off the NVMe, and perf shows the CPU expert workers waiting for those reads (79% of samples in the pool's wait loop). The reads went through the mmap: 4 KB page faults plus a file cache that a 30 GB PC cannot spare (vmstat ~0.9 GB/s, swap and kswapd active) while the same NVMe reads 3.2 GB/s unbuffered at queue depth 4+. The setup also recommended a 256K context (KV 3.5 GB, 12% of the VRAM) that took the VRAM from the expert cache.

Changes.

  • GgufExpertSource: on Linux the misses are read unbuffered (O_DIRECT), one task per slice (gate/up/down) over the existing stagers, into the staging ring. A sample of experts is compared with the mapping at open; a file system that refuses O_DIRECT, or any mismatch, keeps the mapping (MAYA_EXPERT_DIRECT=0 turns it off). Windows and macOS paths are unchanged.
  • With no page cache to feed, the RAM tier keeps 4 GiB (8% of the RAM) free instead of 6 GiB (12%) when the reads are unbuffered (MAYA_EXPERT_HEADROOM_GB for measuring).
  • Qwen setup: when VRAM + RAM cannot hold every expert (memory_gb), the recommended context's KV takes at most 6% of the VRAM instead of 12% (V100 32 GB + 30 GB RAM: 128K). PCs that hold every expert are unchanged (a 3x V100 / 183 GB PC still gets 256K).

Measured (Mercury: V100 32 GB, 30 GB RAM, NVMe; decode tok/s, greedy, 3 prompts, warm, MTP on, internal numbers):

tok/s
v1.1.36 as set up (256K) 6.6
unbuffered reads only (256K) 7.3
+ 128K context + 4 GiB headroom (this PR) 8.3
this PR with MAYA_EXPERT_DIRECT=0 (old read path, 128K) 6.8
64K / 32K context 8.2 / 8.3

Run-to-run noise is about 0.5 tok/s. The NVMe is the limit now (~2.2 GB/s of 3.2); stager count 12 and MTP window 2-3 did not change it. The model needs ~113 GB; a PC with RAM for it (61 GB V100 PC: 25-31 tok/s) does not read the disk at all.

Checks. python -m unittest tools.test_setup_qwen (context cases added). The engine builds on Linux/CUDA; the non-Linux code is only guarded out. A PC that holds every expert in RAM never takes the miss path.

Not changed: nothing hidden or disabled. A longer context stays a choice in the setup and in the config.


🔄 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/654 **Author:** [@mw00](https://github.com/mw00) **Created:** 10/29/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `cf-mercury-1137` --- ### 📝 Commits (1) - [`ee47bb6`](https://github.com/mw00/project-maya/commit/ee47bb6cbbbd266a7eb978a82b8453723a8ff719) Experts that no tier holds are read unbuffered; Qwen setup keeps VRAM for experts on RAM-short PCs ### 📊 Changes **4 files changed** (+140 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/expert_source.hpp` (+7 -1) 📝 `maya.py` (+6 -4) 📝 `src/core/expert_source.cpp` (+123 -13) 📝 `tools/test_setup_qwen.py` (+4 -0) </details> ### 📄 Description CYBER-FROST (Q5_K_M, 112.5 GB) on a Tesla V100 32 GB + 30 GB RAM + NVMe decoded ~6.6 tok/s, far below the same model on a V100 with 61 GB RAM. **Cause.** Experts that neither VRAM (21 GiB) nor the RAM tier (22 GiB) holds are ~40% of the model; they are read from the GGUF when routed. A decode then pulls ~2 GB/s off the NVMe, and `perf` shows the CPU expert workers waiting for those reads (79% of samples in the pool's wait loop). The reads went through the mmap: 4 KB page faults plus a file cache that a 30 GB PC cannot spare (`vmstat` ~0.9 GB/s, swap and kswapd active) while the same NVMe reads 3.2 GB/s unbuffered at queue depth 4+. The setup also recommended a 256K context (KV 3.5 GB, 12% of the VRAM) that took the VRAM from the expert cache. **Changes.** - `GgufExpertSource`: on Linux the misses are read unbuffered (O_DIRECT), one task per slice (gate/up/down) over the existing stagers, into the staging ring. A sample of experts is compared with the mapping at open; a file system that refuses O_DIRECT, or any mismatch, keeps the mapping (`MAYA_EXPERT_DIRECT=0` turns it off). Windows and macOS paths are unchanged. - With no page cache to feed, the RAM tier keeps 4 GiB (8% of the RAM) free instead of 6 GiB (12%) when the reads are unbuffered (`MAYA_EXPERT_HEADROOM_GB` for measuring). - Qwen setup: when VRAM + RAM cannot hold every expert (`memory_gb`), the recommended context's KV takes at most 6% of the VRAM instead of 12% (V100 32 GB + 30 GB RAM: 128K). PCs that hold every expert are unchanged (a 3x V100 / 183 GB PC still gets 256K). **Measured** (Mercury: V100 32 GB, 30 GB RAM, NVMe; decode tok/s, greedy, 3 prompts, warm, MTP on, internal numbers): | | tok/s | |---|---| | v1.1.36 as set up (256K) | 6.6 | | unbuffered reads only (256K) | 7.3 | | + 128K context + 4 GiB headroom (this PR) | 8.3 | | this PR with `MAYA_EXPERT_DIRECT=0` (old read path, 128K) | 6.8 | | 64K / 32K context | 8.2 / 8.3 | Run-to-run noise is about 0.5 tok/s. The NVMe is the limit now (~2.2 GB/s of 3.2); stager count 12 and MTP window 2-3 did not change it. The model needs ~113 GB; a PC with RAM for it (61 GB V100 PC: 25-31 tok/s) does not read the disk at all. **Checks.** `python -m unittest tools.test_setup_qwen` (context cases added). The engine builds on Linux/CUDA; the non-Linux code is only guarded out. A PC that holds every expert in RAM never takes the miss path. Not changed: nothing hidden or disabled. A longer context stays a choice in the setup and in the config. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#652
No description provided.