mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #5462] [Engine] 4-card layer split: the expert cache per card falls as cards are added, and --prefill 1024 frees VRAM that the cache does not take #3577
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#3577
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 @sean640112 on GitHub (Nov 7, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5462
Area
[Engine]
Environment
nvidia-smi topo -mreports NODE between all of them0bdcef4682c5+cuda13.0--expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5 --mtp <mtp>/rt --max-context 131072 --kv int8 --ple-io ram --kv-resident 32768, plus--trim-stage-weightson the split runsgpu [0,1,2,4](index 3 is an RTX 2060, excluded on purpose),layer_split 12,24,36GPU indices follow
nvidia-smi; the split's last card (CUDA3) is the card at index 4.Why this report
docs/MULTI_GPU.mdsays a split "can add capacity without adding speed", so a sub-linear decode is not by itself surprising. Two things did surprise me, and both are cheap to check on any multi-card box: the expert cache per card falling with every card added — enough that four cards end up with less total cache than two — and--prefill 1024freeing about 2.6 GiB of prompt buffers per card without the cache growing into any of it.1. Expert cache per card falls with every card added
Same machine, same pack,
--expert-cache auto,--trim-stage-weightswherever a split exists. One run per configuration; decode is the median of six 256-token greedy requests.--trim-stage-weights; on two cards the flag made no difference at all (6,691 / 12.03 GiB either way), so it cannot be what makes the 4-card figure smaller.Question 1: is the per-card cache falling that fast expected?
--trim-stage-weightsshould leave each card holding only its own layers' dense weights, i.e. less per card as cards are added, not more. A fixed per-card cost (prompt buffers, context, buffers) explains the direction, but the step from 6.02 to 2.71 GiB per card between two and four cards is what I cannot account for.2.
--prefill 1024frees the prompt buffers, and the cache does not take the VRAMSame 4-card configuration, only
--prefillchanged. Both blocks below are from the engine's own log.--prefill auto:--prefill 1024:--prefillauto1024--prefill 1024works and does what the help says: the buffers fall from 3.53 to 0.90 GiB per card, about 10.5 GiB across four cards. The expert cache stays at exactly 6,144 slots / 10.82 GiB, and about 1.5-2 GB per card is left free. Decode is unchanged (101.09 against 101.28 tok/s wall, within run-to-run spread).Question 2: is
--expert-cache automeant to grow into VRAM freed this way? If it sizes the cache before the prompt buffers are known, could it re-size (or take the freed room on the next start) — and if not, is--expert-cache Nthe supported way to use that headroom on a layer split?3.
"parallel": 2works on a 4-stage layer splitdocs/BATCHING.mdsays "Only a layer split of two stages on two GPUs has been run." On this 4-stage split, with the top-level"parallel": 2,GET /propsreportedtotal_slots2 and one session gave:All three rows come from the same session, so this is a within-configuration comparison.
--trim-stage-weightsalso does what its help says on four cards: 97.7 → 110.8 tok/s engine (90.18 → 101 tok/s wall), i.e. +13.4%, reproduced with the flag and withSTRATA_STAGE_TRIM=1alike.4. A note on headroom
In sessions with
--prefill autothe engine logsonly 459 MiB of VRAM free at the start of this request (below 512 MiB)and warns that decode can fall to a few tok/s (#2065), recommending--vram-reserve-mib 768.--prefill 1024avoids that entirely (2,042 MiB free). If the default is meant to keep ≥512 MiB, it may be worth either reserving more in--expert-cache autoor suggesting the smaller chunk in that warning.Validation
Passed — on this box with
--kv int8 --kv-resident 32768 --max-context 131072, MTP--spec 4 --spec-min-p 0.5:GET /health200 andGET /v1/modelsafter each start.filling the GPU's expert cache (N experts, X GiB); every VRAM figure isnvidia-smiright afterready:.engine started: …) for each session quoted, so the flags discussed were actually passed.--trim-stage-weights: 97.7 against 110.8 tok/s engine on the same 4-card config with the flag removed; on 2 cards the flag changed the cache by 0 slots."parallel": 2:GET /propstotal_slots2, clients 1 / 2 / 4 in one session.--trim-stage-weights, 96.00% with it. One question apart, one run each; at this model size that test is close to saturated, so it rules out a large quality change rather than a small one.Failed — none.
Not run — vision (
--vision nothroughout), context above 131,072, and the all-cards split engine, which refuses on four 16 GB cards witheach card needs about 21 GiB, has 15 GiB free(expected for this model size; noted only for completeness).Logs
1 card — GPU0 15,269 MiB
2 cards, split 24,
--trim-stage-weights— 15,231 / 15,361 MiB4 cards, split 12,24,36,
--trim-stage-weights,--prefill auto— 12,911 / 13,451 / 14,377 / 15,361 MiB4 cards,
--trim-stage-weights,--prefill 1024— 13,847 / 14,387 / 14,371 / 15,355 MiB4 cards,
"parallel": 2— same cache;total_slots2Happy to attach the complete logs, including the per-request
done:lines — say which.@udqe commented on GitHub (Nov 7, 2026):
Not a four-card story, but both mechanisms you flag run on a two-card pair and this box carries the same log lines; numbers below, verbatim where the engine prints them.
Our shape. 2x RTX 4090 (Ada, sm_89) Windows 11, main engine 0.1.57, fixed
--layer-split 22,--expert-cache auto,--prefill auto(chunk reads 8192), two quant arms on the same machine: UD-IQ4_XS-v31 and UD-Q4_K_XL. Different quants and cards from yours, so slot bytes differ - counts and lines, no GiB conversions across quants.Q2 first, because our box has a knob that settles half of it. The borrow mechanism is exactly present on two cards (IQ4_XS boot, engine's own lines):
and the Q4_K_XL arm on the same rig borrows 3.85 GiB per card (1316/1321 slots), free 1862/1024 MiB. Two facts this box can pin:
autodoes grow the cache into VRAM freed before sizing time. We run an explicit reserve (--vram-reserve-mib 2304down to2048was a deliberate experiment, one variable per boot): 2304 -> 2048 moved the expert cache 5,774 -> 5,867 slots on the IQ4 arm (+93), noWARNING: only ... slotsline, quality suite unaffected. So freed VRAM that exists when the search runs is taken - your observation that 2,042/1,502 MiB sit idle is therefore about when the buffer reservation is decided, not about the search being unable to grow at all.--prefill- chunk 8192 is tuned for our prompt rates (295K cold reads at 75.5 s, 3,908 t/s on this build), and your table shows what giving that up costs. On our box the buffers are paid for out of cache slots (the borrow above: 1,908 slots off CUDA0), so--prefill 1024would plausibly hand those slots straight back to the cache rather than create the idle-VRAM state you saw - the idle-with-everything-loaded lines look like a four-stage interaction, not a two-stage one.Q1, the per-card cache question, two-card analogue. Same machine, three fresh boots, only
--layer-splitvaried (20 / 22 / 24): 5,937 / 5,867 / 5,777 slots - a gentle, near-monotone drift of +/-1% per step with the weight balance, no cliff, and the borrow (27% of CUDA1's slots on IQ4) is symmetric across the two cards. So the super-linear fall you measured (8.37 -> 6.02 -> 2.71 GiB per card) has no two-stage counterpart at 16,311 MiB-class cards; whatever charges the stages their cache as cards are added, it looks like it scales with the stage count, not with the pair.Q3. Nothing to add - we are two-stage with
--pipeline-windows 2, a different knob; if a second stream on a two-stage split halves per-card latency headroom, our 1,704/1,060 MiB free would be the first place it shows, and it is already spent by design (that is our--vram-reserve-mib 2048+--vram-reserve-later-mib 972, adopted deliberately after a WARN-gated sweep).All quoted lines are from this box's engine logs (boots timestamped in our notes); the split sweep is three same-machine boots, one variable each.
(ai-assisted; all lines pinned in our notes; happy to rerun any arm)
@sean640112 commented on GitHub (Nov 7, 2026):
Retracting this report, and replacing it with a smaller one that is actually true.
Both questions came from an arithmetic error on my side. Two things I should have checked before filing:
expert cache N slots, X GiBline I quoted in §1/§2 is CUDA0's own figure, not a total — I divided it by the card count to get "per card";layer_split 12,24,36is a value I had set myself, not the project's default.setup.py:2424writescfg["layer_split"] = cfg.get("layer_split") or "auto".What was wrong
--prefill 1024frees 2.6 GiB per card and the cache ignores it--trim-stage-weights, and the cards are then at their layer allowance, with nothing left to placeThe arithmetic check that settles the first row: 21,144 / 24,576 = 86.0% and 24,175 / 24,576 = 98.4%, which are exactly the residency figures the engine prints on those boots. The allowance is the experts of the layers a card owns —
layers 12-23 … 6144 of its 6144 profiled pairson four cards islayers 24-47 … 12288 of its 12288on two, so 12 × 512 versus 24 × 512.What is left worth reporting
Four 5060 Ti 16 GB, IQ3_S, engine's own tok/s on one 320-token request, 5 requests per boot:
layer_split12,24,36(what I had set)auto(what setup writes)13,25,3714,26,3813,26,39(amd_four_card.LAYER_SPLIT)15,27,39The
12,24,36row is two separate boots (96.4 and 96.3) to rule out ordering or warm-up.autois 4.5% faster than the flat split I had been using. Whatever the search is doing, it is a good default and my report should have compared against it first.autostill ends with the last card at 528 MiB free while the first card has 1,248 MiB. The last card also carries the output head and the draft layer, andstrata_control/amd_four_card.pysays exactly that —LAYER_SPLIT = "13,26,39", commented "the last card also holds the output head, so it takes fewer layers" — but the profile is gated tobackend == "hip". Applying the same idea by hand (14/12/12/10) puts 1,646 MiB free on that card and is 2.1% faster thanautoon a single boot each, so I would treat that as a hint rather than a result.Questions
autothe intended path for four cards, and is 528 MiB free on the last stage expected given the head and the draft layer live there? It comes out the same for every split I tried, includingauto.amd_four_cardheuristic meant to be hardware-agnostic? On this rig the exact constant 13/13/13/9 is 3.1% slower thanautowhile 14/12/12/10 is 2.1% faster, which reads less like "the last card takes fewer layers" and more like "balance the free VRAM across the stages". If that is the real rule, is there a supported way to express it?What stands from the original report
--trim-stage-weights: expert residency 86% → 98.4%, engine 97.7 → 110.8 tok/s (+13.4%) on the 12/12/12/12 split."parallel": 2on a four-stage split: aggregate 86.0 → 130.2 → 140.6 tok/s at concurrency 1/2/4 (+63%), wheredocs/BATCHING.mdonly covers two stages on two GPUs.Apologies for the noise, and thanks to @udqe — their two-stage sweep in #5265 is what sent me back to the per-card lines, where the mistake was visible immediately. The rig is free on demand if any of the above is worth re-running.
@sean640112 commented on GitHub (Nov 7, 2026):
@udqe — replying to your two points directly; the report itself is corrected in the comment above.
Your reserve experiment holds up here.
--expert-cache 8000is refused per card on this rig:… leaves no room for the prompt path's buffers (0 MiB) and the 700 MiB reserve on CUDA0: 5380 slots instead, and5554with--vram-reserve-mib 256. Your +93 slots from 256 MiB and my +174 from the same move are the same effect, seen on four cards instead of two.But the freed-VRAM rule did not apply, for a boring reason: there was nothing left to place. The allowance per card is the experts of the layers that card owns —
6144 of its 6144 profiled pairson four cards is12288 of its 12288on two. With--trim-stage-weights, three of the four cards are already at that ceiling, so the ~2.5 GiB left free cannot become cache. My "2 GB idle" was real, but it was not the allocator declining to use it.Your 20/22/24 sweep was the control I was missing. It is what sent me back to the per-card lines, where the mistake turned out to be mine: the
expert cache N slots, X GiBline is CUDA0's own figure, not a total, and I had divided it by the card count. There is no per-card cliff — totals are 4,388 / 11,970 / 24,175 slots for 1 / 2 / 4 cards. You were right that the curve should not behave the way I described.One question I cannot answer from my side: on four cards, every split I tried — including
auto, which picks 11/13/13/11 — leaves the last stage at 528 MiB free while the first has 1,248 MiB, and that stage also carries the output head and the draft layer. If you know a line that prints the last stage's non-expert allocations, it would close the last gap. Thanks for the time you put into this.