mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[GH-ISSUE #56] Windows, dual-socket, single GPU: decode varies ~30% between server restarts (13.5 vs 18.5 tok/s at 128K) - CPU lane lines inside #23
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#23
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?
Originally created by @noahark on GitHub (Oct 9, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/56
Machine
--gpu 1), context 32768STRATA_GLM_PCIE_SHARE=0.25,STRATA_GLM_CPU_LANE=18A/B
Same v1.0.21 build, same config, only the pin env differs. Server-side
predicted_per_secondfrom/v1/statuslast_timings, warm expert cache, ~350-390-token answers, 3-4 runs each:STRATA_GLM_CPU_PIN=0So on this Windows dual-socket box the automatic per-node binding costs ~22%, while the #44 measurement on Linux (2x Xeon Gold 6152) gained +29% (15.4 -> 19.8). Same feature, opposite sign across OSes - Windows thread-affinity/NUMA topology as seen from the engine may differ enough to matter on old boxes like this one.
Suggestion
Until more Windows dual-socket machines are measured, defaulting the pin off on Windows (or documenting
STRATA_GLM_CPU_PIN=0next to the #44 notes for Windows users) would save others the 20% we almost shipped with. Happy to run more variants (STRATA_GLM_CPU_PIN=1explicit, differentCPU_LANE) if useful.Related: first Windows + V100 run report (install + context-tier ladder) in a separate issue.
@mw00 commented on GitHub (Oct 9, 2026):
Thank you for the A/B. Since v1.0.26 the README explains it:
STRATA_GLM_CPU_PINis Linux-only, so on Windows the engine pins nothing whatever it is set to;So the 15.1 against 19.4 tokens/s came from something that differed between the two starts, not from the setting. A good place to look is the two starts'
glm fast: CUDA<n> CPU lane:log lines. On a two-socket PC, where Windows puts the threads and the pinned RAM tier can change from one start to the next.If you can post those lines from a slow start and a fast one, we can see whether it is the lane's calibration or the memory placement.
@noahark commented on GitHub (Oct 9, 2026):
You are right, and thank you for untangling it. I checked v1.0.21's
glm_fast_path.cu(the tree I measured on): the pin block is gated onn_parts_ >= 2, so on this single-GPU boxSTRATA_GLM_CPU_PINdid nothing either way - the 15.1 vs 19.4 was start-to-start variance, not the setting. Retracting that title now.I reproduced the restart variance on the same v1.0.21 build, same config (Maya-S-v2, one V100, 128K tier, tuned env PCIE 0.25 / CPU_LANE 18), 2 warmups + 2 ~370-token answers after each start:
The CPU lane lines you asked for, one per 131072-ctx start since yesterday (the split policy is identical every time; only the measured ms differ):
(starts 2-4 above are restarts 1-3 in the table; none of the calibration numbers separate the slow from the fast start.)
What does separate them is the runtime stat. A slow phase vs a fast one, same workload style:
The VRAM pool is equally full in both (3171-3177 of 3276); the slow phase does ~2x the RAM-tier fetches, ~2x the CPU-lane time per token and ~10 points less VRAM hit - as if the promoted hot set does not overlap the routed experts as well on some starts.
One oddity: restarts 1 and 2 are nearly identical to the decimal (13.4/13.5 and 15.5/15.5), which looks more like a small set of alternating states than random placement. Happy to run more restarts, pin the process ourselves, or try anything else on this box - it reproduces in a few minutes.
@mw00 commented on GitHub (Oct 10, 2026):
Thank you for the restarts. The stat lines narrow it down:
Two places that set can come from:
expert_usage.txtnext to the pack, rewritten after every request), blended with the model's own routing profile.To tell them apart:
git pullin the Maya folder, thenSTART-MAYA.bat, thenSTART-MAYA.bat --calibrateonce)."STRATA_GLM_USAGE": "0"in the config's"env"block. The warm-up then follows only the model's own profile, the same at every start. If the three restarts give the same speed, the saved profile is the cause.glm statline early and late in a long answer. If the VRAM hit climbs toward ~81% as it goes, the promotions fix the start's set, only slowly.The near-identical pairs (13.4/13.5, 15.5/15.5) fit a small set of usage profiles alternating between starts.
@mw00 commented on GitHub (Oct 11, 2026):
An update on the restart-to-restart difference: we reproduced it and #99 fixes the cause (next release).
At start the engine times how long the CPU takes for an expert, and that sets how many RAM-tier experts the CPU lane takes for the engine's whole life. The timing was 16 runs in about 40 ms. A burst of other work on the CPU at that moment, such as the OS reclaiming memory right after the RAM tier is pinned, covered all of them. On a V100 here one start timed 0.63 ms where the usual is 0.32, its CPU lane took half its share, and decode was 16% slower until the next restart. Your 13.5 vs 18.5 tok/s looks like the same thing, with the CPU lane lines differing between starts.
Now it times five rounds spread over about half a second and keeps the fastest round's median, since other work only ever adds time. On the V100, under a heavy bursty load, the worst start went from 0.97 ms to 0.52, and quiet starts read 0.319 every time.
Also, from v1.0.32:
STRATA_GLM_CPU_CAL=<file>(#81) keeps the timing in a file, so later starts reuse it instead of timing again. That alone takes the variation away once a good timing is saved.When the release is out, could you restart a few times and compare the
CPU lane:lines and decode?@noahark commented on GitHub (Oct 11, 2026):
Tested on the release as asked. Eight restarts, v1.0.32 source build (
ea55be3, sm_70), Maya-S-v2-IQ2_XXS, one V100-PCIE-32GB, 131072 context, config env unchanged (STRATA_GLM_PCIE_SHARE=0.25,STRATA_GLM_CPU_LANE=18) plusSTRATA_GLM_CPU_CAL=<file>. Protocol per start: 2 warmups ("Say hi.", 24 tokens) + 2 measured answers (fixed prompt,max_tokens380, effort high, server defaults). The box was quiet throughout: no user process above ~0.25 cores, disk 99.9% idle.0 1 1 2 3 4 4 5 6Three findings:
STRATA_GLM_CPU_CALstops it. Five fresh timings on a quiet box spread 0.395-0.551 ms; the reuse starts repeat the saved values byte-for-byte and logthose times from ... (not timed). So #99's steadier timing is wanted, and the CAL file works as the stopgap on Windows.0 1 1 2 3 4 4 5 6) despite the timing spread, and the one fast start's fresh timing (0.410) is indistinguishable from the slow ones (0.395/0.415). On this box the plan is robust to the timing noise, so the ~30% decode gap must come from somewhere else.So on this dual-socket Windows box #99 removes one variance source (the lane timing), and the remaining slow/fast lottery is a memory-placement effect. It also does not alternate the way v1.0.21 did (1 fast start in 8 here, vs the earlier 2 slow then 1 fast). Happy to collect more if it helps pin the placement down — for instance, if there is a debug env that prints which NUMA node the pin landed on, I'll log it across restarts.
Build footnote for other Volta boxes: the new
__grid_constant__kernel inglm_fast.cuis compute_70+, so a hand-rolledCMAKE_CUDA_ARCHITECTURES=nativebuild on a machine that also has a pre-70 card (our GTX 1060) fails to compile unlessCUDA_VISIBLE_DEVICESis limited to the V100 —maya.py's installer already does exactly that, so this only bites hand-written build scripts; the RELEASE-CHECKLIST's one-line CMake fix would remove the trap entirely.@mw00 commented on GitHub (Oct 11, 2026):
The steadier CPU-lane timing is out in v1.0.33. After updating, could you restart a few times and compare the
CPU lane:lines and decode? WithSTRATA_GLM_CPU_CAL=<file>(v1.0.32) a good timing is also kept across starts.@noahark commented on GitHub (Oct 11, 2026):
Updated to v1.0.33 (
6083122, source build, sm_70) and reran the matrix as asked: eight restarts on the same box (one V100-PCIE-32GB, dual Xeon E5-2696 v3, 128 GB DDR3L), Maya-S-v2-IQ2_XXS, 131072 context, config env unchanged (STRATA_GLM_PCIE_SHARE=0.25,STRATA_GLM_CPU_LANE=18). Six fresh starts (the CAL file deleted before each) and two reuse starts, protocol identical to the v1.0.32 round (2 warmups + 2 measured answers,max_tokens380, server defaults, quiet box).The lane plan was
0 1 1 2 3 4 4 5 6in all eight starts; the runtime expert cost is the secondglm statline'scpu lane ... in ... ms/tokdivided by its experts/tok.Practically, restarting until a start lands on the ~0.71 ms side is the workaround that works today. Standing offer from the last round: if a debug env can print where the pinned tier landed (NUMA node / page spread), I'll log it across restarts and we can pin the placement side of it down.
@noahark commented on GitHub (Oct 11, 2026):
Chased the placement lead from the last round to the end. Everything below is on v1.0.33, Maya-S-v2-IQ2_XXS, one V100-PCIE-32GB, dual E5-2696 v3, Windows 10.
The tier's physical pages tell the whole story. I scanned the engine's working set at runtime (QueryWorkingSetEx, the Node field at bit 16 on 19H1+): the 66.4 GB tier lands 82% on node 0 / 18% on node 1 on fast starts and 15% / 85% on slow starts. Ten scanned starts, every one on the predicted side: 82/18 decodes at 0.73 ms a CPU-lane expert, 15/85 at 0.85-0.88. The start-time timing remains uncorrelated (0.37-0.57 either way), as you found with #99.
Three hypotheses the scan ruled out, with the test that killed each:
What actually differs: the GPU's DMA path. cudaMemcpy H2D from each node's pinned memory to the V100: 11.0 GB/s from node 0, 9.5 GB/s from node 1 - the card hangs off node 0's PCIe, and node 1's memory feeds it over the QPI link. With the tier 85% on node 1, every ram fetch and promotion (18-28 a token here) crosses the QPI link at -14% bandwidth while the CPU lane competes for the same link on its minority reads; the per-expert cost lands 17% higher and the decode with it. So "which node holds the tier" matters not because the CPU lane reads it there, but because the GPU does.
One physical note: the tier (66.4 GB) is larger than a node's 64 GB, so a start can never put it all on one side - the 82/18 fast split is already close to node 0's ceiling after the OS takes its share. The lottery is only about which side takes the majority.
And the Windows API wall, for the record:
VirtualAllocExNumahonors its node argument only for fresh whole allocations (a 66 GB one-shot would be single-node and cannot fit); committing a reserved range ignores the node entirely (measured: 256 alternating blocks, 100% landed on one node), and page placement does not follow the touching thread (measured: two threads pinned to opposite nodes, first-touching alternating pages - the split follows nothing). So unlike Linux there is no user-space way to place a registered range of this size in Windows from inside the engine.Practical outcome for this box: your restart suggestion is now mechanized - a local build probes the split at start ("the tier sits on node N") and the launcher restarts unless the tier landed on the GPU's side. That holds decode at the fast mode every start. If you see a cleaner lever from the engine side (two arenas with the split deliberately lopsided toward the GPU's node, the way the class arenas already exist?), the scan tool is a ~150-line CS file I'm happy to hand over.
@noahark commented on GitHub (Oct 11, 2026):
Collecting the dead ends from this investigation in one place, each with the measurement that killed it, so nobody retraces them. All on the same box as before (dual E5-2696 v3, one V100-PCIE-32GB, Windows 10, v1.0.33 source build, Maya-S-v2-IQ2_XXS, 66.4 GB tier).
1.
VirtualAllocExNumablock interleave - the node argument is ignored for a reserved range. The idea: oneVirtualAllocreserve of the whole tier, then commit each 2 MB block withVirtualAllocExNuma(..., MEM_COMMIT, node)alternating node 0/1, thencudaHostRegisterthe whole range. Measured (a 512 MB / 256-block test before touching the engine): 256 blocks committed with alternating node arguments landed 100% on node 1 - zero followed the argument. The node is honored only for a fresh whole allocation, and a tier larger than a node cannot be one. Dead.2. First-touch placement - pages do not follow the touching thread on Windows. The idea (the Linux path's MPOL_INTERLEAVE equivalent): plain
VirtualAllocreserve+commit, one toucher thread per node pinned viaSetThreadGroupAffinity, each faulting every nnodes-th page. Measured: a standalone 512 MB test once read back ~50/50 (that was luck - the two pin masks had silently collapsed to the same group-0 mask), but repeated properly, and in the engine itself, the split stays lopsided regardless of which node touches what. Dead.3.
SetThreadIdealProcessorExon top of the group affinity - no effect either. Same setup as (2) with the ideal processor also moved to the target node's core: the engine's tier still came up 94.6% on one node. Whatever policy picks a demand-zero page's node, it is neither the running nor the ideal core. Dead.4. Pinning the CPU lane onto the tier's node - works as code, changes nothing. The full implementation exists in a local branch: node enumeration, node->group/core maps, a
pin_threadWindows path (SetThreadGroupAffinityover concatenated group indices), a start-time probe of the tier's majority node, and the pool's 18 threads pinned onto that node's 36 CPUs (logged: "the tier sits on node 1: the CPU lane pinned"). Measured on a slow draw: decode still 9.6/11.4 tok/s, per-expert cost 0.853-0.862 ms - byte-for-byte the slow mode. The lane's threads were never the bottleneck; the GPU's fetches are. Dead as a fix (the probe half of this branch is what PR #112 keeps).5. Large-page morphology - no signal. The
QueryWorkingSetExLargePage bit over the tier's regions: 0.0% on every start scanned with the field (plain 4 KB pages throughout, fast side and slow alike). Not a huge-page/fragmentation story. Dead.6. Node 1's memory being slower - symmetric everywhere. Pinned-to-node probes: single-thread reads 3.4 vs 3.9 GB/s, 18-thread concurrent reads 12.2-12.4 vs 12.7-12.9 GB/s. And what is asymmetric is the GPU path: H2D
cudaMemcpyfrom pinned memory 11.0 GB/s (node 0, the card's PCIe side) vs 9.5 GB/s (node 1, over the socket link). The asymmetry lives in the DMA, not the DRAM. Dead.7. For completeness, two upstream-mechanism items already reported: v1.0.33's five-round timing did not narrow the start-time spread here (0.370-0.569 ms across six fresh starts vs v1.0.32's 0.395-0.551) - the probe reads the pinned tier too, so a bad placement times slow in every round; and
STRATA_GLM_CPU_CALreuse locks the plan, not the placement - a reuse start draws the lottery afresh.What survives all of this: the draw decides which node feeds the GPU over the socket link, Windows gives user space no lever over the draw, and the working mitigations are visibility (PR #112's log line) plus restart-on-a-bad-draw. An engine-side fix would need the GPU's PCIe node (not exposed by
cudaDevAttrHostNumaIdon this Volta + 582.78, but available on newer cards) and a deliberately lopsided arena split toward it.@mw00 commented on GitHub (Oct 11, 2026):
Thank you, the eight-start matrix settles one thing: the runtime cost separates the starts and the start timing doesn't. So it isn't the CPU timing, it's placement, as you said. I think Windows' processor groups explain the pattern:
The debug line you offered to log is in v1.0.34 (#110). On Windows with two NUMA nodes or more, every GPU prints at start:
The page counts may say
not reportedif Windows won't report the driver's pinned pages. If you can log this line next to the CPU-lane cost across a few restarts, we'll know whether it's the group. If it is, the fix is to run the CPU lane on the tier's socket, or interleave the tier over both sockets as on Linux. I'd write that next.A quick test meanwhile:
start /NODE 0 START-MAYA.bat(then/NODE 1) from a command prompt asks Windows for that node, and the engine the server starts should inherit it. The new line shows whether it did.@mw00 commented on GitHub (Oct 11, 2026):
Sorry, my reply above crossed your last two comments: I answered the 09:25 round without having read 12:15 and 12:55. Your measurements settle it, and my processor-group guess was wrong. You pinned the lane onto the tier's node and nothing changed, so it isn't the CPU side. The asymmetry is the GPU's DMA path (H2D 11.0 against 9.5 GB/s from the far node), and every RAM fetch and promotion pays it.
The log line: v1.0.34 (#110) shipped a similar start line an hour after your #112, from the same API. Yours is the one measured on the box that shows the problem, and your launcher reads its format, so let's keep one line, yours. Details on #112.
An engine-side fix, along the lines you outline:
cudaDevAttrHostNumaId, so it works on Volta too.The expert tables already hold a pointer per slot, so the decode doesn't care how many pieces there are; the work is in how the tier is pinned. It's a real change, so I'd want your box to test it. Would you run a build of it when it's ready?
@noahark commented on GitHub (Oct 11, 2026):
Yes - happy to run the build the moment it's up. The box reproduces the lottery on demand (a few restarts is all it takes), the scan tool and the restart matrix are in place, and the probe line from #112 will confirm each start's draw during the test. The piece-wise placement matches what the API allows here: fresh whole allocations were the one form whose node argument measured as honored, and hottest-first slot filling means the far node holds the cold experts - both ends of that are testable on this machine.