[PR #463] [CLOSED] ds4: DS4_COPY_NUMA up to 4 NUMA parts (a CPU-lane pool per socket of a 4-socket host) #541

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/463
Author: @geoffreybyers
Created: 10/24/2026
Status: ❌ Closed

Base: main ← Head: ds4-copy-numa-4


📝 Commits (1)

  • 39f57d0 ds4: DS4_COPY_NUMA up to 4 NUMA parts (a CPU-lane pool per socket of a 4-socket host)

📊 Changes

2 files changed (+12 additions, -7 deletions)

View changed files

📝 docs/SETTINGS.md (+1 -0)
📝 src/ds4/ds4_model.cu (+11 -7)

📄 Description

DeepSeek's CPU lane copies its RAM experts into at most 2 NUMA parts, with a worker pool per part. On a host with 3 or 4 sockets, the other sockets' cores and memory bandwidth go unused.

On a 4× Xeon E7-8880 v4 (88 cores), for example, the lane ran 44 threads on sockets 0–1, and that cap holds whatever MAYA_DS4_CPU_LANE or --cpu-threads say.

The change

DS4_COPY_NUMA (set in the config's "env") now accepts 1–4 instead of 1–2. Each part is a set of rows on its own node, with a worker pool there. Most of the code already loops over NH; only three places were fixed at two:

  • ram_part (slot → its parts) and the copy's base array are now std::array<uint8_t*, kMaxNH> (kMaxNH = 4), filled for every part.
  • The flow's staging IoQueue::Job jobs[6] (3 matrices × 2 parts) is now jobs[3 * kMaxNH]. With 4 parts it overflowed the stack ("stack smashing detected") the first time a long prompt pulled copied experts into staging; short chats never reach that path.
  • The DS4_COPY_NUMA clamp: max(1, min(kMaxNH, n)).

The default is unchanged (at most 2 parts). Nothing changes unless DS4_COPY_NUMA is set to 3 or 4. There's a row for it in docs/SETTINGS.md.

Measured

Setup:

  • 4× Xeon E7-8880 v4, 499 GB RAM, RTX 3090s on PCIe 3.0, CUDA 13.0, f26d8ba.
  • Maya-S + DSpark, --mmap-experts off, DS4_ENGRAM_RAM=1, DS4_REQUIRE_ALL_RAM=1, under numactl --interleave=all.

Method:

  • Short chats: three 300-token answers, greedy, thinking off, three rounds after a warm-up round (mean of 9).
  • Then a 68K-token WikiText prompt with a needle at 5%.
Short-chat decode 68K: prompt read 68K: decode
2× 3090 (sockets 0–1 side), stock, two runs 38.5 / 36.9 tok/s 655 / 644 23.5 / 23.8
2× 3090 (sockets 0–1 side), DS4_COPY_NUMA=4, two runs 49.1 / 49.3 806 / 805 32.4 / 32.8
2× 3090 (sockets 2–3 side), stock 39.4 802 26.1
2× 3090 (sockets 2–3 side), DS4_COPY_NUMA=4 48.9 802 32.4
4× 3090, stock 55.4 1,329 36.7
4× 3090, DS4_COPY_NUMA=4 55.9 1,324 33.9

The needle was found in every run.

  • Two cards: 13,082 experts (144 GB) sit on the CPU lane, so its memory bandwidth decides decode, and all four sockets give +24–34% decode.
  • Four cards: 9,177 experts (101 GB) on the lane, and no gain.

Output: greedy answers differ between these runs in their last bits and words, but they differ between two stock runs as well. The parts split rows, not sums, so each row is computed in full by one node. The differences come from the per-token CPU/GPU choice, which follows measured timings.

Checks

  • HIP mapping: tools/check_hip_compat.py passes; no new CUDA calls.
  • Not run here: the NVIDIA build matrix and the V100 parity tests.

🤖 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/463 **Author:** [@geoffreybyers](https://github.com/geoffreybyers) **Created:** 10/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `ds4-copy-numa-4` --- ### 📝 Commits (1) - [`39f57d0`](https://github.com/mw00/project-maya/commit/39f57d090ee0db90c177c74ee044424cdcee99dd) ds4: DS4_COPY_NUMA up to 4 NUMA parts (a CPU-lane pool per socket of a 4-socket host) ### 📊 Changes **2 files changed** (+12 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+1 -0) 📝 `src/ds4/ds4_model.cu` (+11 -7) </details> ### 📄 Description DeepSeek's CPU lane copies its RAM experts into at most **2 NUMA parts**, with a worker pool per part. On a host with 3 or 4 sockets, the other sockets' cores and memory bandwidth go unused. On a 4× Xeon E7-8880 v4 (88 cores), for example, the lane ran 44 threads on sockets 0–1, and that cap holds whatever `MAYA_DS4_CPU_LANE` or `--cpu-threads` say. ## The change `DS4_COPY_NUMA` (set in the config's `"env"`) now accepts `1`–`4` instead of `1`–`2`. Each part is a set of rows on its own node, with a worker pool there. Most of the code already loops over `NH`; only three places were fixed at two: - **`ram_part`** (slot → its parts) and the copy's **`base`** array are now `std::array<uint8_t*, kMaxNH>` (`kMaxNH = 4`), filled for every part. - **The flow's staging `IoQueue::Job jobs[6]`** (3 matrices × 2 parts) is now `jobs[3 * kMaxNH]`. With 4 parts it overflowed the stack ("stack smashing detected") the first time a long prompt pulled copied experts into staging; short chats never reach that path. - **The `DS4_COPY_NUMA` clamp:** `max(1, min(kMaxNH, n))`. **The default is unchanged** (at most 2 parts). Nothing changes unless `DS4_COPY_NUMA` is set to 3 or 4. There's a row for it in `docs/SETTINGS.md`. ## Measured **Setup:** - 4× Xeon E7-8880 v4, 499 GB RAM, RTX 3090s on PCIe 3.0, CUDA 13.0, f26d8ba. - Maya-S + DSpark, `--mmap-experts off`, `DS4_ENGRAM_RAM=1`, `DS4_REQUIRE_ALL_RAM=1`, under `numactl --interleave=all`. **Method:** - Short chats: three 300-token answers, greedy, thinking off, three rounds after a warm-up round (mean of 9). - Then a 68K-token WikiText prompt with a needle at 5%. | | Short-chat decode | 68K: prompt read | 68K: decode | |---|---:|---:|---:| | 2× 3090 (sockets 0–1 side), stock, two runs | 38.5 / 36.9 tok/s | 655 / 644 | 23.5 / 23.8 | | 2× 3090 (sockets 0–1 side), `DS4_COPY_NUMA=4`, two runs | **49.1 / 49.3** | **806 / 805** | **32.4 / 32.8** | | 2× 3090 (sockets 2–3 side), stock | 39.4 | 802 | 26.1 | | 2× 3090 (sockets 2–3 side), `DS4_COPY_NUMA=4` | **48.9** | 802 | **32.4** | | 4× 3090, stock | 55.4 | 1,329 | 36.7 | | 4× 3090, `DS4_COPY_NUMA=4` | 55.9 | 1,324 | 33.9 | The needle was found in every run. - **Two cards:** 13,082 experts (144 GB) sit on the CPU lane, so its memory bandwidth decides decode, and all four sockets give **+24–34% decode**. - **Four cards:** 9,177 experts (101 GB) on the lane, and no gain. **Output:** greedy answers differ between these runs in their last bits and words, but they differ between two stock runs as well. The parts split rows, not sums, so each row is computed in full by one node. The differences come from the per-token CPU/GPU choice, which follows measured timings. ## Checks - **HIP mapping:** `tools/check_hip_compat.py` passes; no new CUDA calls. - **Not run here:** the NVIDIA build matrix and the V100 parity tests. 🤖 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:26:35 +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#541
No description provided.