mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2201] [CLOSED] --vram-elastic with --kv-grow: VRAM takes its chunks where the K/V grows into #3919
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#3919
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/2201
Author: @i-Vladimir-i
Created: 10/13/2026
Status: ❌ Closed
Base:
main← Head:kvgrow-elastic📝 Commits (1)
7408f56--vram-elastic with --kv-grow: VRAM takes its chunks where the K/V grows into📊 Changes
3 files changed (+121 additions, -26 deletions)
View changed files
📝
docs/DETAILS.md(+2 -1)📝
docs/VRAM_ELASTIC.md(+11 -0)📝
src/program/generate.cpp(+108 -25)📄 Description
--vram-elasticwith--kv-grow: VRAM takes its chunks where the K/V grows intoToday the two switches exclude each other: with
--vram-elasticthe engine says--kv-grow is offand puts the wholeK/V in VRAM, because #533's cache is cut into segments and
--kv-growneeds one VMM range of chunks. On our R9700 thatcost 1,413 cache slots for a 262K context (9,405 instead of 10,818) - more than the VRAM a game or an image encoder would
borrow. This lets both run.
What it changes (
src/program/generate.cpp; docs inDETAILS.mdandVRAM_ELASTIC.md)--kv-grow's arena (one range of 2 MiB chunks), andVRAMworks on the regionthe K/V grows into: slots
[lo, top), just below the prompt path's loan.first), now
kvg_take, split out ofkvg_ensureunchanged; the chunks go to the driver instead of to the K/V.now
kvg_give_back, split out ofkvg_trimunchanged. So after a grow the cache holds what a K/V trim would leave,not necessarily the experts the shrink took (the segments put the same ones back); the docs say so.
slots, not from the reserve. A small counter keeps the chunks given to the driver; it is settled against the arena's
empty places, because the K/V's first cells are new VRAM and a trim below them maps those chunks into the arena too
(without that the count drifted by ~100 MiB and a grow reported "no VRAM" for chunks that had no place).
What it leaves alone: either switch alone.
kvg_ensureandkvg_trimdo the same steps through the two helpers;without
--kv-grow,VRAMkeeps the segments. The default path does not reach any of it.Checked (on top of #2189 for HIP; the change itself does not depend on it)
ple_parityas before; CUDA:this branch alone builds and links with nvcc 13.4.92, sm_120, 0 errors. Not run on an NVIDIA GPU.
--kv-grow --vram-elastic, 262K context, a needle at 3/5of each prompt and a 320-token answer:
reserve 4000reserve 8000reserve 0reserve 4000,reserve 0The driver's own counter followed (31.5 -> 30.5 -> 28.0 GiB at 4000, 24.1 GiB at 8000 with the 156K K/V, back to
31.4); the engine's "MiB with the driver" went back to 0 at each full grow.
--kv-growalone with this build: 78K, a short request (trim), 156K, a short one, 78K - every needle found, the K/Vgrew and trimmed as before.
VRAMkeep 2 GiB free(52 ms) and the encoder started in 3.1 s; a 156K prompt then grew the K/V to 163,840 cells while the encoder held its
share (needle found); after 60 s without a picture the encoder stopped and the cache was whole again (10,888 of
10,888 slots, 0 MiB with the driver); a second cycle the same.
Not tested: NVIDIA at run time, Windows, more than one shrink-grow cycle with a parked conversation held by the K/V.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.