mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3413] [CLOSED] [Engine] NUMA-split CPU expert pool, on by default on dual-socket Linux boxes #4623
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4623
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3413
Author: @baptisterajaut
Created: 10/20/2026
Status: ❌ Closed
Base:
main← Head:feat/numa-pool📝 Commits (10+)
1e54cb8feat: per-NUMA-node task slices and counters in the CPU expert pool (opt-in)565ba69fix: NUMA split refuses STRATA_EXCHANGE_ROTATE=1, diag sums the slices in a split phase, mixed-mode split testf7be4a2feat: per-NUMA-slice byte ranges of a complement slotfb26531test: assert slice-0/slice-1 ranges never intersect, across neighbouring slots too937129bfeat: place complement row slices on their NUMA node by pinned first touch (opt-in)1e857ebfix: release the model files' cached pages before NUMA placement of the complement67bcf5ffix: judge NUMA placement after registration, log silent no-ops and per-node shortfall up front077a131fix: word the NUMA per-node shortfall as at risk, FAILED stays for the verdictsb3dba4afix: refuse a lopsided NUMA split and accept only 1/test for STRATA_NUMA_SPLITf8280b0fix: report an unverifiable NUMA placement instead of FAILED when move_pages fails📊 Changes
10 files changed (+1060 additions, -44 deletions)
View changed files
📝
docs/DETAILS.md(+22 -0)📝
include/strata/core/expert_source.hpp(+14 -0)📝
include/strata/kernels/cpu/pool.hpp(+63 -0)📝
include/strata/kernels/cpu/pool_plan.hpp(+31 -1)📝
src/core/expert_source.cpp(+288 -3)📝
src/kernels/cpu/pool.cpp(+315 -32)📝
src/kernels/cpu/pool_plan_test.cpp(+54 -0)📝
src/kernels/cpu/pool_tasks_test.cpp(+203 -2)📝
src/program/generate.cpp(+24 -6)📝
tests/core/file_expert_source_test.cpp(+46 -0)📄 Description
Problem and result
On a dual-socket box the CPU expert pool either stays on one socket (the 0.2.0 default, 11 workers here) or spreads across both and gets slower, as the benchmarks behind the 0.2.0 default (#674, #707) found. With the split, both sockets' cores pay off. As agreed in #3201, it is on by default when the pool's CPUs span 2 NUMA nodes, and
STRATA_NUMA_POOL=0turns it off.Box: 2x Xeon Gold 6226, 64 GB (32 GB per NUMA node), RTX 3090 on PCIe 3.0, Qwen3.8-Flash-Next-Uncensored IQ4_XS at 262K context, kernel booted with
iommu=pt. Server decode:+9.7 % over the default. Two earlier sessions, with the IOMMU translating DMA (the Debian default), gave +14 % and +11.5 %: the default gained from the faster bus, the split did not move (details below). A split without the placement (diagnostic build, earlier session) gave 51.0 against 53.1 for the default. Neither more cores, nor local memory at 12 workers, nor the per-node pool slices without the placement explains the gain: it takes both halves at 22 workers. Prompt speed and VRAM hit rate are unchanged. A machine with one NUMA node runs exactly as before: same worker count, no log line. A test checks it; no single-socket machine was at hand, so it ran on this box with the process bound to one node (
numactl --cpunodebind=0), which the pool's topology detection follows.Related discussion
https://github.com/Niko1221/Strata/issues/3201 (scope agreed: on by default with two NUMA nodes,
STRATA_NUMA_POOL=0to turn it off). #2242 took a different route, binding the complement to the GPU's node, and was declined for lack of dual-socket measurements.Approach
--pool-workers Nalternates sockets. The default spans both sockets only when the split will follow (Linux, exactly 2 nodes, pinned threads, noSTRATA_EXCHANGE_ROTATE=1), since 22 workers without the split are the slowest arm above.STRATA_EXCHANGE_ROTATE=1, unpinned threads and a lopsided worker layout turn the split off, with the reason in the log; the pool then runs as in 0.2.0.STRATA_NUMA_POOL=testbuilds the same slices on any machine, without placement.--aux-cpus.Validation
Passed:
pool_plan_testOK;file_expert_source_testPASS;pool_tasks_test"360 bitwise comparisons passed, 192 of them in NUMA-split mode", and its default check: unset 22 workers split on,122 workers split on,011 workers.pool_tasks_testundernumactl --cpunodebind=0on the same box: unset 11 workers split off,111 split off,011; the unset runs log nothing,1logs "NUMA split off: the pool's CPUs span 1 NUMA node(s)". Not run on a real single-socket machine.NUMA split on: slice 0 = node 0 (12 threads), slice 1 = node 1 (11 threads), 22 workers, placement 100.0 / 99.6 %;STRATA_NUMA_POOL=0gives 11 workers on socket 0 and no split line. One start per arm, a functional check, not a speed comparison.pool_plan_testOK;pool_tasks_test"360 bitwise comparisons passed, 192 of them in NUMA-split mode", 20 runs out of 20;file_expert_source_testPASS.pool_plan_testandpool_tasks_testpass.Failed: none observed.
Not run:
STRATA_NUMA_POOL=1logs "NUMA split off: the split needs Linux").Limits
Test protocol
Box: HP Z6 G4, 2x Xeon Gold 6226 (12 cores each, 2 NUMA nodes), 64 GB DDR4 (32 GB per NUMA node) on 4 of 6 channels per socket, RTX 3090 on PCIe 3.0 x16, CUDA 13.2, Debian 12 kernel 6.1 booted with
iommu=pt. Engine at ca1dafbd on v0.2.0-beta, server config:--pack orca-iq4_xs --native Qwen3.8-Flash-Next-Uncensored-IQ4_XS --expert-cache auto --resident-budget-gib 55 --prefill auto --spec 4 --spec-min-p 0.5 --mtp mtp/rt --mtp-max-t 2 --max-context 262144 --kv int8 --vram-reserve-mib 844 --adapt-async 1, expert profile frozen (md5 checked before every start, profile saving off). Every arm ran with the same config env:STRATA_POOL_SPIN_US=200,STRATA_ROUTE_TAIL_SKIP=0,STRATA_DECODE_TIMING=1. Harness, configs and raw logs: https://gist.github.com/baptisterajaut/0cd495f3e548be4964406f1198119e28Arms: measured before the switch became
STRATA_NUMA_POOLand on by default. D = default (split off, 11 workers); S = split on (22 workers); X = split with--pool-workers 12; N = split off with--pool-workers 22. Server starts in the order D1 S1 D2 S2 X1 N1 S3 X2 N2 S4, no drop_caches between them (production-like). Per start: a 60K-token passkey prompt twice (prompt speed, passkey checked), then 3 decode samples of a fixed prompt (Python LRU cache with type hints plus 5 design bullets, max_tokens 3000, reasoning_effort low, sampled), decode speed read from the server'stimings.predicted_per_second, VRAM hit rate from the server's done line. A split start below 95 % placement on a node would have been discarded; none was.Prompt speed 1282 to 1341 tok/s across all arms, passkey found in all 20 prompt runs, VRAM hit rate 72 to 79 %. N streams 4.0 to 4.7 % of the routed experts over PCIe against 1.2 to 2.4 % in the other arms.
Earlier sessions, same protocol and binary, IOMMU in translated mode (
DMA-FQ, pinned H2D 7.7 to 9.2 GB/s against 12.3 withiommu=pt). First, order D1 S1 X1 D2 S2 X2 N1 S3 N2 S4:Second, order A1 S5 D3 A2 S6, A = split with the placement skipped by a throwaway switch on a diagnostic build (not in this PR):
Prompt speed 926 to 1037 tok/s across all arms of both sessions, passkey found in all 20 prompt runs of the first. VRAM hit rate 71 to 77 %.
Misc. notes: tuning on this box
Every arm ran with the same tuning, set before this work for reasons unrelated to the split:
--adapt-async 1: the adaptive tier's VRAM/RAM expert swaps happen between windows instead of inside them. On 0.1.45, 34.5 to about 54 tok/s on the LRU prompt (single runs), the swaps' cost per window from 24.5 to 2.7 ms.STRATA_POOL_SPIN_US=200, for heat: an idle worker sleeps after 200 µs instead ofkSpinBeforeSleep20 ms (pool.hpp:264). With ~30 ms windows and work at each of the 48 layers, the default kept every pool core spinning. No visible cost on CPU expert time (16.7 to 18.3 ms per window against 17.8).STRATA_ROUTE_TAIL_SKIP=0, to judge the quant without the lossy default skip (docs/QUANTS.md:158-162). It costs speed in every arm.--resident-budget-gib 55instead of the 40 setup.py gives on 64 GB (it leaves 24 GB beside the budget, setup.py:548): the box is headless and idles at about 4 GB, so the ~44 GiB complement fits in RAM and nothing is read from the NVMe.STRATA_DECODE_TIMING=1only adds timing log lines.iommu=pton the kernel command line, for the main table only: Debian's kernel translated every DMA (DMA-FQ), which held pinned H2D at 7.7 to 9.2 GB/s on PCIe 3.0 x16; passthrough gives 12.3 GB/s and about +30 % prompt speed. It is a gen3/gen4 matter: on xrip's PCIe 2.0 x16 box (#3201) the copy speed is the same in both modes, andiommu=ptbroke the GSP boot of a card on a patched driver there.PS from the human behind this PR:
main()in src/program/generate.cpp runs from line 2269 to the end of the file, 14,306 lines. Not this PR's business, but splitting it would make changes like this one a lot less scary to write and to review.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.