mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1223] [CLOSED] generate: allow the elastic K/V with --peer-device (VMM ranges keep their memory on the owning GPU) #3320
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#3320
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/1223
Author: @chimpera
Created: 10/6/2026
Status: ❌ Closed
Base:
main← Head:vmm-peer-series📝 Commits (4)
adc580dvmm: create each range's chunks on the device that is current at reserve(), not the one captured by the once-only api() init991fd6eexpert cache: only the primary cache maps its arena through VMM; a peer tier's is one cudaMalloc againda593fdpeer: create the peer device's context before the arena's whole-range pinc48ec73generate: allow the elastic K/V with --peer-device📊 Changes
5 files changed (+56 additions, -23 deletions)
View changed files
📝
include/strata/core/expert_cache.hpp(+4 -2)📝
include/strata/core/vmm.hpp(+3 -2)📝
src/core/expert_cache.cpp(+1 -7)📝
src/core/vmm.cpp(+33 -8)📝
src/program/generate.cpp(+15 -4)📄 Description
--kv-growturns itself off whenever a second GPU is present — the gate readso.peer_device < 0— so adding a peer tier costs the primary its elastic K/V.Nothing in the machinery requires the exclusion; what it protected against is
fixed here directly, and the two now run together.
Why the gate was there.
set_vmmwas static: enabling it mapped everyexpert cache's arena through a
vmm.cpprange — including the peer tier's.And a range's physical chunks were created with the device id captured at the
once-only
api()init (the primary's device), not the device that owns therange, so a second card's mapping failed while that card sat nearly empty.
Reproduced on this PR's base with only the gate line removed: with
--kv-grow --peer-device 1, startup ends inon a card with ~20 GiB free — the peer's chunks were being allocated on the
primary. (First seen on the strata-nvfp4 fork's 2× RTX 3090 pair; the same
vmm.cppships here with the elastic K/V.)The three fixes:
vmm_chunk_newtakes the device; a range creates its chunks on the devicecurrent at
reserve(), not the one captured at init. Device 0 is grantedaccess to a peer range only when
cudaDeviceCanAccessPeersays a pathexists, with an owner-only fallback (
cuMemSetAccessrejects an unreachableremote location outright, failing the whole map).
set_vmmis per-instance: only the cache the K/V borrows from maps throughVMM; a peer tier's cache is one plain
cudaMalloc. This is what makes thegate unnecessary.
(
cuMemMap/cuMemSetAccesson a peer range need it to already exist).Measured on mainline (2× RTX 3090,
01:00.0+61:00.0, no P2P, IQ3_S,262K context, 16,399-token prompt, both cards capped at 19 GiB; the second
card also carries desktop processes):
Peer attach: 9488 experts, 18.06 GiB, filled in 0.8 s. Prefill is parity — at
this shape the prompt path is bound on the primary either way. Decode medians
15% apart with overlapping spreads (pair 41.7–93.0, solo 30.8–71.7): the
second card's 3.3× residency removes per-token misses, but the spread is
dominated by the MTP draft-acceptance swing of greedy prose and this
machine's other tenants, so the honest claim is at-or-above, not a speedup.
The elastic K/V is the part the gate was blocking, working under load,
quoted from the run log:
The single-GPU path is byte-identical: a range on the current device creates
its chunks exactly as before, and
vmm_testand the conversation-cache suitespass unchanged. Layer splits,
--batchand--vram-elasticstill turn theelastic K/V off, as before. Layer-split smoke, same two cards through the
serve (
--gpu 0,2 --layer-split auto): this PR and its base pick the sameK=30 split (layers 0–29 / 30–47, session [30, 48)), print no elastic-K/V and
no peer lines, and answer normally — the only startup differences are the
free-VRAM readings (the second card carries desktop processes), which size
its cache 3733 vs 3764 slots run to run.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.