[PR #4016] [Engine] dsv41: --numa-experts bands — every NUMA node serves the CPU lane #4879

Open
opened 2026-11-07 16:31:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4016
Author: @chimpera
Created: 10/24/2026
Status: 🔄 Open

Base: main ← Head: pr/dsv41-numa-bands


📝 Commits (1)

  • b3aaeb7 dsv41: --numa-experts bands — every NUMA node serves the CPU lane

📊 Changes

4 files changed (+269 additions, -66 deletions)

View changed files

📝 docs/DEEPSEEK41.md (+13 -0)
📝 src/dsv41/ds4_main.cpp (+7 -1)
📝 src/dsv41/ds4_model.cu (+245 -65)
📝 src/dsv41/ds4_model.hpp (+4 -0)

📄 Description

Problem and result

On a host with more than two NUMA nodes, the CPU expert lane places its
copied experts on the first two nodes only (the part layout: whole rows of
each matrix a node, NH = min(2, nodes)), and the other nodes' cores and
memory bandwidth stand idle while routed experts compute. On a 4-node
ThreadRipper, decode runs at 30.2 tok/s with half the machine unused.

With --numa-experts bands, every 128-row band of every expert matrix is
placed on node (band + expert) % nodes: the same one copy of the model in
RAM, every node's cores and its local memory serving — 44.8 tok/s on the
same host, same day, same configuration (+48%), outputs identical token for
token. The default (parts) is unchanged; bands is opt-in and declines
with a note when it cannot serve (one node, n_ff/dim not a multiple of 128
rows, an EXL3 pack).

none (a focused, opt-in performance change with its benchmark; opened straight as a PR per CONTRIBUTING)

Approach

  • Placement: the copy writer scatters each matrix band by band to its node;
    the per-node region is one slot-stride sized for the worst node share
    (ceil of bands / nodes), so slot addressing stays pure arithmetic —
    band b of expert e sits at region[(b + e) % NN] + lay[r] + (b / NN) * band bytes. The (b + e) rotation makes one node's bands an
    arithmetic progression with step NN (position b / NN for every expert)
    and spreads each matrix's remainder bands across nodes.
  • Dispatch: one pool per node; every pool sees every ticket and keeps the
    ones whose bands live on its node (one CAS to skip). The part layout's
    dispatch is untouched behind the same run_nodes.
  • Consumption: the 64-row compute jobs address their half of a band at
    +64 * row_b (whole rows; the up matrix with its own role's row width),
    pass rows [0, 64) relative to that base (the kernels walk rows from the
    base pointer they are given), and the iq kernels' output pointers are
    pre-offset the same way (they index output by the row range's start).
  • Safety: a boot-time self-check samples 256 bands of the scattered copy
    and compares them against the model file, byte for byte.
  • 128 whole rows are the formats' finest legal split — the same bound the
    NH guard uses — so any GGUF mix of expert formats serves.
  • Compatibility: with parts (the default) every stock operand is taken
    unchanged; the only part-path changes are the dispatch lambda signature
    ((item, pool), pool ignored) and pool count bookkeeping. Docs:
    docs/DEEPSEEK41.md gains a "Computers with several NUMA nodes" section
    with the measured numbers.

Validation

Environment: ThreadRipper Pro 5965WX (4 NUMA nodes, Zen 3, AVX2, 24
threads), RTX 5090 + RTX 3090, CUDA 13.4 (archs 86;120), the official
IQ2_XS 2.25-bpw set. Revision: this branch (single commit on 7dd5cf18).
Where two instances ran at once, the second lane's copy was capped
(DS4_COPY_GB=110) equally on both sides of every comparison.

Passed:

  • Build (CUDA): cmake -S . -B build-dsv41 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES=86;120 -DSTRATA_BUILD_DSV41=ON -DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_COMPILER=/usr/local/cuda-13.4/bin/nvcc && cmake --build build-dsv41 -j --target strata-dsv41 — clean, on the
    bare 7dd5cf18 + this commit and inside our patched tree.
  • Default path unchanged: --numa-experts unset (parts), RTX 3090, greedy
    A/B against reference outputs the stock build produced — 4/4 prompts
    identical, re-run on the final commit (the 4 prompts and the comparison
    command are in the validation log).
  • Bands over 2 nodes (--numa-experts bands=2, forced on the 4-node host):
    boot self-check "256 sampled bands match the model file"; greedy A/B 4/4
    identical; decode median 20.7 tok/s (vs 18.4 parts).
  • Bands over every node (--numa-experts bands): boot self-check passes;
    greedy A/B 4/4 identical; decode median 25.9 tok/s (vs 18.4 parts on the
    same card, same cap, same day).
  • The 5090 (RTX 5090, full copy, no cap): parts 30.2 → bands 43.7 tok/s
    median on this branch (same protocol: bench.py --rounds 3 --warmup --only mid.txt), outputs bit-identical across the switch (4/4). An
    env-gated build of the same algorithm measured 44.8 the same morning —
    both runs cited as measured; the spread is boot-to-boot.

Failed:

  • None observed.

Not run:

  • HIP and SYCL builds: the dsv41 path is excluded from HIP builds by the
    CMake guard next to STRATA_BUILD_DSV41; there is no SYCL variant of the
    lane. Not applicable rather than skipped.
  • More than 4 NUMA nodes: the arithmetic and the ownership check are
    node-count-generic (clamped at 8), but no 6/8-node host was available.
    bands=2 on this 4-node host exercises the multi-node path at a count
    the part layout also serves.
  • A true 2-socket host: measured here only as forced bands=2 on 4-node
    hardware, which is not the same memory topology.
  • EXL3 packs with the flag set: gated off by design (a note is printed);
    no EXL3 pack was at hand to show the note.
  • Windows.

Limits

  • Two-node hosts should expect a much smaller gain than four-node ones: the
    part layout already uses both nodes there. What remains is finer-grained
    balance (whole 128-row bands vs half-range parts).
  • The boot self-check samples 256 bands (every layer's regions share one
    layout); it is a tripwire, not a full verification.
  • Only the GGUF copy lane; the EXL3 CPU lane keeps its layout.

🤖 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/Niko1221/Strata/pull/4016 **Author:** [@chimpera](https://github.com/chimpera) **Created:** 10/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/dsv41-numa-bands` --- ### 📝 Commits (1) - [`b3aaeb7`](https://github.com/Niko1221/Strata/commit/b3aaeb7c148c16a32f48bfb2b8d6ec4a7f48b606) dsv41: --numa-experts bands — every NUMA node serves the CPU lane ### 📊 Changes **4 files changed** (+269 additions, -66 deletions) <details> <summary>View changed files</summary> 📝 `docs/DEEPSEEK41.md` (+13 -0) 📝 `src/dsv41/ds4_main.cpp` (+7 -1) 📝 `src/dsv41/ds4_model.cu` (+245 -65) 📝 `src/dsv41/ds4_model.hpp` (+4 -0) </details> ### 📄 Description ## Problem and result On a host with more than two NUMA nodes, the CPU expert lane places its copied experts on the first two nodes only (the part layout: whole rows of each matrix a node, `NH = min(2, nodes)`), and the other nodes' cores and memory bandwidth stand idle while routed experts compute. On a 4-node ThreadRipper, decode runs at 30.2 tok/s with half the machine unused. With `--numa-experts bands`, every 128-row band of every expert matrix is placed on node `(band + expert) % nodes`: the same one copy of the model in RAM, every node's cores and its local memory serving — 44.8 tok/s on the same host, same day, same configuration (+48%), outputs identical token for token. The default (`parts`) is unchanged; `bands` is opt-in and declines with a note when it cannot serve (one node, n_ff/dim not a multiple of 128 rows, an EXL3 pack). ## Related discussion none (a focused, opt-in performance change with its benchmark; opened straight as a PR per CONTRIBUTING) ## Approach - Placement: the copy writer scatters each matrix band by band to its node; the per-node region is one slot-stride sized for the worst node share (ceil of bands / nodes), so slot addressing stays pure arithmetic — band `b` of expert `e` sits at `region[(b + e) % NN] + lay[r] + (b / NN) * band bytes`. The `(b + e)` rotation makes one node's bands an arithmetic progression with step NN (position `b / NN` for every expert) and spreads each matrix's remainder bands across nodes. - Dispatch: one pool per node; every pool sees every ticket and keeps the ones whose bands live on its node (one CAS to skip). The part layout's dispatch is untouched behind the same `run_nodes`. - Consumption: the 64-row compute jobs address their half of a band at `+64 * row_b` (whole rows; the up matrix with its own role's row width), pass rows `[0, 64)` relative to that base (the kernels walk rows from the base pointer they are given), and the iq kernels' output pointers are pre-offset the same way (they index output by the row range's start). - Safety: a boot-time self-check samples 256 bands of the scattered copy and compares them against the model file, byte for byte. - 128 whole rows are the formats' finest legal split — the same bound the NH guard uses — so any GGUF mix of expert formats serves. - Compatibility: with `parts` (the default) every stock operand is taken unchanged; the only part-path changes are the dispatch lambda signature (`(item, pool)`, pool ignored) and pool count bookkeeping. Docs: `docs/DEEPSEEK41.md` gains a "Computers with several NUMA nodes" section with the measured numbers. ## Validation Environment: ThreadRipper Pro 5965WX (4 NUMA nodes, Zen 3, AVX2, 24 threads), RTX 5090 + RTX 3090, CUDA 13.4 (archs 86;120), the official IQ2_XS 2.25-bpw set. Revision: this branch (single commit on 7dd5cf18). Where two instances ran at once, the second lane's copy was capped (`DS4_COPY_GB=110`) equally on both sides of every comparison. **Passed:** - Build (CUDA): `cmake -S . -B build-dsv41 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES=86;120 -DSTRATA_BUILD_DSV41=ON -DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_COMPILER=/usr/local/cuda-13.4/bin/nvcc && cmake --build build-dsv41 -j --target strata-dsv41` — clean, on the bare 7dd5cf18 + this commit and inside our patched tree. - Default path unchanged: `--numa-experts` unset (parts), RTX 3090, greedy A/B against reference outputs the stock build produced — 4/4 prompts identical, re-run on the final commit (the 4 prompts and the comparison command are in the validation log). - Bands over 2 nodes (`--numa-experts bands=2`, forced on the 4-node host): boot self-check "256 sampled bands match the model file"; greedy A/B 4/4 identical; decode median 20.7 tok/s (vs 18.4 parts). - Bands over every node (`--numa-experts bands`): boot self-check passes; greedy A/B 4/4 identical; decode median 25.9 tok/s (vs 18.4 parts on the same card, same cap, same day). - The 5090 (RTX 5090, full copy, no cap): parts 30.2 → bands 43.7 tok/s median on this branch (same protocol: `bench.py --rounds 3 --warmup --only mid.txt`), outputs bit-identical across the switch (4/4). An env-gated build of the same algorithm measured 44.8 the same morning — both runs cited as measured; the spread is boot-to-boot. **Failed:** - None observed. **Not run:** - HIP and SYCL builds: the dsv41 path is excluded from HIP builds by the CMake guard next to `STRATA_BUILD_DSV41`; there is no SYCL variant of the lane. Not applicable rather than skipped. - More than 4 NUMA nodes: the arithmetic and the ownership check are node-count-generic (clamped at 8), but no 6/8-node host was available. `bands=2` on this 4-node host exercises the multi-node path at a count the part layout also serves. - A true 2-socket host: measured here only as forced `bands=2` on 4-node hardware, which is not the same memory topology. - EXL3 packs with the flag set: gated off by design (a note is printed); no EXL3 pack was at hand to show the note. - Windows. ## Limits - Two-node hosts should expect a much smaller gain than four-node ones: the part layout already uses both nodes there. What remains is finer-grained balance (whole 128-row bands vs half-range parts). - The boot self-check samples 256 bands (every layer's regions share one layout); it is a tripwire, not a full verification. - Only the GGUF copy lane; the EXL3 CPU lane keeps its layout. 🤖 Generated with [Claude Code](https://claude.ai/claude-code) --- <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 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
Niko1221/Strata#4879
No description provided.