mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #604] Resident expert placement on a layer split, for mixed or older GPUs: where I think it helps, plus some doc notes, and an offer to test #285
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#285
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 @paulhothersall on GitHub (Oct 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/604
Hi, and thanks for Strata. I'm posting because I started with one idea, found most of it was already built or planned, and want to offer hardware time for the part that isn't. Everything below is from reading
main(99f3dbd), the docs,bench/results/and issues #364, #384, #395 and #498. I have not run Strata yet and none of my numbers below are measurements.Disclosure: I used Claude (Anthropic's CLI) to read the repo and cross-check my reasoning. I checked the quoted file/line claims against
mainbefore posting. I'm not asking you to review a patch. There isn't one.Why I looked
I have older, cheaper cards: [Tesla P40s (I can run 1, 2 or 3 of them, 24 GB each), 64 GB host RAM, Ryzen 3900x, and sometimes a P40 beside a 3070. For this class of machine the question is: can VRAM + RAM together hold a bigger quant than RAM alone could, with each expert in one place instead of two?
What I found is already there (credit where due)
--resident-expertsand--resident-budget-gibdo this, and a swap copies the evicted expert back into the host slot of its replacement (resident_stage_swapsingenerate.cpp,stage_exchange/commit_exchangesinexpert_source.cpp).--dump-routing, and--expert-profile-save.So I'm not proposing a new swap design.
The parts I think might still be useful
1. Resident mode across a split, for predictable RAM. From #384 the gain looks like RAM safety rather than speed: about 42 GB stayed available with
--mmap-expertsvs about 0.5 GB without it, at similar tokens/s. That matters most where the quant is bigger than RAM allows but VRAM + RAM is enough. My estimate for P40-class 24 GB cards + 64 GB RAM (formula calibrated against your 3090 IQ3_XXS run, which it reproduces within 2%; each card carries its own dense copy and session, so only about 17-18 GB of a 24 GB card is left for experts):IQ3_S (50 GB) already fits in 64 GB in the default mode, and on 3 cards it fits entirely in VRAM, so single-copy only changes anything for Q4-class quants on 2-3 cards. That is the case I'd aim at. Treat the numbers as estimates: the Q4 non-expert VRAM is back-solved from the doc's 1,280 slots on the 5070.
These per-card figures are before #390 (the per-stage weight carve, which reclaims about 2.3-2.8 GiB per card in its measurements). With it, each card would hold more experts, so the RAM column would shrink a little more. I don't know how the two changes would interact; that's a question for you.
2. Card speed in the split cost model. The cost model in
generate.cpp(~2414) fits per-layer time to SMs x clock on a 5080 + 3090. A mixed pair like P40 + 3070 differs in memory bandwidth, FP16/BF16 capability and PCIe, none of which that term sees. I don't know if it changes the chosen split in practice. That's a question for a test, not a claim.3. A small mechanical detail, only if measured. Today a swap is D2H into an exchange buffer, a stream sync, H2D, then a CPU
memcpyat the flip: about 4 blob-sized DRAM transfers, vs 2 with a pre-reserved pinned spare slot and two streams. I'd only mention it ifcommit_exchangesshows up in a profile. I don't have one.Things I noticed while reading (low-risk doc fixes, all re-checked on
main)docs/MODELS.md:74says RAM >= "shard 1 + about 10 GB".setup.py:2030uses experts + 10 (arena_gb). Shard 1 includes 3.6-4.5 GB of dense weights that live in VRAM.docs/DETAILS.md:890says the n-gram table is read "through the OS cache".direct_file.hppsays it is unbuffered and must never use the file cache.docs/DETAILS.md:895("How it works") still says 2,048-token chunks; the same page documents 8,192 elsewhere.docs/DETAILS.md:280says a "~40 GB" Q2_0 repack;expert_source.hpp:378givesexperts.bin= 33,973,862,400 B. (The 40 may be a disk budget, in which case ignore this.)expert_cache.hpp:19-25still says the cache "does not yet compute anything";generate.cppcalls that comment false.What I can run
I'm happy to be a test rig for anything useful here, especially the awkward hardware:
--stats, expert tiers, hit rates andSTRATA_TRACE_ADAPToutput, and run--dump-routingon 3 workloads (code, chat, random-text/needle). Your own data shows hit rate moves 15-20 points by workload at the same resident fraction.Questions:
--dump-routingenough?I'm not claiming a speedup. Without measurements I only claim that a configuration some of us have becomes possible.
@gopinath87607 commented on GitHub (Oct 3, 2026):
Thanks — this is the closest read of the split code I've seen from outside the project. I wrote the carve in your Part 1, and the placement search that came after it. Two notes, both from runs on my own box.
Part 1: what the carve changes.
Measured on my 4-GPU rig (2× RTX 3060 + 2× RTX 5060), IQ3_S pack, everything on auto:
Both runs picked the same split, so the extra VRAM is the only thing that changed. Per card that is 2.33–2.78 GiB freed, the same range you worked out.
Where does the freed VRAM go? Into that card's own expert cache. So it doesn't add to your RAM saving, it competes with it — it means more experts can live in VRAM, which helps your idea rather than hurting it.
How much comes back? That depends on the model's dense weights, not on the card. Every stage used to load the whole model's dense copy — 3,485.66 MiB on this pack. Now it loads only its own layers. Your Q4-class packs have bigger dense weights than IQ3_S, so you should get at least this much per card. But I have not run a P40, so that part is arithmetic, not a measurement. It is the first number I would want from your rig.
One caveat, and it hits mixed cards. The prompt chunk is one number for the whole run, and it is picked so that every stage has room for its buffers — the code takes the smallest card's answer. So a small card sets the chunk for everyone: put a 6 GB card next to a 24 GB one and the 6 GB card decides, while the 24 GB card's spare VRAM buys nothing there. Slots are not like that — each stage sizes its own cache from its own free VRAM, so a small card holds fewer experts without shrinking the others. Your P40 + 3070 pair is exactly this case, so it is worth measuring before deciding the pair is a good idea(btw i will work on different formula for mixed vram available cards) .
Part 2: the cost model.
You are right that it is built around two specific cards. We hit the same problem. The per-card speed term is fitted to a 5080 + 3090, and so is the mass curve next to it. On my four 3060/5060 cards that curve was badly wrong: it says the top 5,805 pairs hold 94.9% of the traffic, but the rig measures 69.2%, over four boots and 14.9M decode lookups. No exponent fixes it, because the curve comes from how the model routes tokens, and the profile file only stores a ranking — no counts — so it cannot be read off the data. #584 replaces it with a formula that matches both rigs, and scores all 15,180 four-card placements instead of using a rule of thumb. That gained +419 slots (+3.0%).
So your point is real, and it is the same kind of problem we hit. Your P40 + 3070 test — auto split against forced splits — is exactly the test that shows whether the speed term decides anything. If it does, the fix goes in the same code #584 touches. I would run it before the resident work, because a split that is chosen wrong changes every number above it.
@paulhothersall commented on GitHub (Oct 3, 2026):
I ran this on a P40 + 3070 box (Ryzen 3900X, 60 GB DDR4-2400, P40 power-capped at 130 W, PCIe 3.0 x8 to the P40, IQ3_XXS, main + #395's gemm path + STRATA_EXPERIMENTAL_SM60, CUDA 12.9). Four short prompts, one run each, about +-10% noise: treat it all as relative.
Single P40: loads and generates correctly on sm_61. 10,921 expert slots, decode about 30 tok/s with MTP, prefill 235-323 tok/s, hit rate 84-92%. Main vs #584 on one card: identical (same slots, same hit counts, same speed).
P40 + 3070, main's auto split: it gives the 3070 46-47 of 48 layers (cost model: 0.91 vs 1.58 ms per layer), about 2.4k slots in total, chunk 512, prefill about 130 tok/s. With the P40 first, 18 GiB of it sat unused. A forced split (3070 layers 0-19) got 12k slots, chunk 4096, prefill 231 tok/s.
With #584: auto picks a split close to my best forced one: about 15k slots, chunk 6144-8192, prefill 240-250 tok/s, hit rate 90-97%. With the same forced split on both builds, the carve alone took the 3070's cache from 1,063 to 2,441 slots and the chunk from 1024 to 6144. Decode was 34-37 tok/s in every two-card config, about 13-22% over the P40 alone.
Where decode time goes (single P40, one-shot
--stats, ms per verify round):At a full cache the CPU pool is 8% of the round and the GPU phase 73%; the two phases add up rather than overlap. Taking every expert off the GPU costs about 25% of decode, not more. The 3070 alone (985 slots, 33% hits) decoded faster than the P40 alone, so on this model the card's dense/attention speed seems to matter more for decode than how many experts it holds. Slots mostly changed prefill and the chunk.
For #584's search: a per-card dense-speed term may matter more than the slot count for decode, while slots decide the chunk and prefill. I have only tested two cards so far, so I can't say how far that generalises.
Next I can run two P40s, and two P40s plus the 3070 (one card on a chipset x4 slot, so the PCIe probe will differ per card), on this same prompt set and on #584 if that is still the useful target. Tell me which configs and flags you would rather see.
I have not tested a low-RAM host (my attempt to emulate one in a memory-capped cgroup was not faithful, so I'm leaving it out) or anything bigger than IQ3_XXS. Logs and configs are available if useful.
@gopinath87607 commented on GitHub (Oct 4, 2026):
hi check out this pr for me https://github.com/Niko1221/Strata/pull/761 and share your thoughts
@Niko1221 commented on GitHub (Oct 4, 2026):
Thank you for the careful reading and the offer to test. The doc notes are fixed in 0.1.39. MODELS.md now gives the RAM rule as the experts + ~10 GB (with the sizes). DETAILS.md says the n-gram table is read unbuffered (
--ple-io direct, for SSDs), that prompts are read in chunks of up to 8,192 tokens, and that the ~40 GB Q2_0 pack is 34 GB of experts plus the dense weights. The README's speed table says which engine measured which row, and the stale expert_cache.hpp comment is gone. Resident mode on a layer split is tracked in #642. The most useful run from your rig now is a P40 + 3070 with"layer_split": "auto"against a few forced splits (--statsand the hit rates), which shows whether the split's speed term matters for mixed cards.