mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #237] [CLOSED] Use a second GPU's VRAM as an opt-in expert store for the prompt path #2521
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#2521
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/237
Author: @lukmanfauzie
Created: 9/30/2026
Status: ❌ Closed
Base:
main← Head:pr-vram-experts-0128📝 Commits (1)
85370afUse a second GPU's VRAM as an opt-in expert store for the prompt path📊 Changes
6 files changed (+534 additions, -5 deletions)
View changed files
📝
include/strata/core/expert_source.hpp(+118 -0)📝
serve/server.py(+11 -2)📝
serve/test_server.py(+30 -0)📝
src/core/expert_source.cpp(+173 -0)📝
src/prefill/prefill.cpp(+78 -3)📝
src/program/generate.cpp(+124 -0)📄 Description
Supersedes the
--vram-expertspart of #151, per @Niko1221's request to split thethree changes. Rebased as a single commit onto
main= v0.1.29 (d6708a4) andopt-in.
On a machine whose RAM cannot cache the 31.6 GiB expert set, every prompt re-reads the experts from the SSD and that read is the whole cost of the prompt (measured: 27.4 GiB re-read, 214.7 s for a 22,266-token prompt). A second card's VRAM holds the same bytes and hands them to the CPU ~19x faster than the engine's fault path can (0.334 ms against 6.31 ms per expert, measured on this box), while computing nothing.
--vram-experts(opt-in, needs--mmap-experts) uploads whole layers of routed experts into the second card's VRAM and serves the prompt path from there.VramExpertStore(src/core/expert_source.{hpp,cpp}) owns complete layers on one device and uploads them straight out of the mapped file, one blob at a time, so it needs NO host allocation at all - the host is the scarce resource on the machine this exists for. The layer set is chosen by routing frequency (the profile) until the card is full, greedily by each layer's OWN extent: a native pack's blobs differ layer to layer (1.5-2.3 MB across the Coder's 48), so one average would waste room or over-commit.ExpertSourcegainsvram_held/vram_fetch(defaulting to false), so every other source and caller is unchanged and a store is an ACCELERATOR, not a dependency: a fetch that misses falls back to the file.prefill.cppfetches into a small ring of pinned handoff buffers and DMAs from there into the ring slot the H2D already reads, so--vram-expertscosts no new device memory and ~5 MB of host RAM. Both prompt paths are wired: the staged path AND the streamed path (--prefill 8192is >= the stream gate, so a low-RAM run takes the streamed one for every expert - wiring only the staged path left the card filled, reported as holding whole layers, and never read).--vram-expert-layers Ncaps the layer count and--vram-expert-device Dpicks the card (default 1); both default to what the machine can hold.Nothing here runs unless
--vram-expertsis given. The pinned handoff buffers are only allocated when the source actually has a store, and every store call site is guarded by that allocation, so a machine without the flag - or with one GPU - takes the previous code path unchanged. With one GPU, or without--mmap-experts, the flag warns and the run continues without a store.serve/server.pyno longer adds--layer-split autoto a config that already names--vram-experts. That flag wants the second card's whole VRAM as a copy store, while the split puts compute layers there and the two compete for the same memory;--layer-splitis also refused by the engine unless it was started with--serveand can put a distinct GPU behind every K, so the generated line left the server waiting for a READY that never came. A config that wants the split is unchanged, and the newGpuChoicetest pins all three cases.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.