mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4433] [CLOSED] [Engine] Fit a 512K context: give the prompt loan back to the K/V, keep big chunks staged #5042
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#5042
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/4433
Author: @xvcezrqpbxtpzblrt
Created: 10/28/2026
Status: ❌ Closed
Base:
main← Head:engine/loan-release-027📝 Commits (1)
60f4ab3[Engine] Give the prompt path's loan back to the K/V before asking for new VRAM (#3998 follow-up)📊 Changes
3 files changed (+125 additions, -1 deletions)
View changed files
📝
include/strata/prefill/prefill.hpp(+4 -0)📝
src/prefill/prefill.cpp(+6 -0)📝
src/program/generate.cpp(+115 -1)📄 Description
## Problem
A 512K context on a 16 GB card could not fit in one run. The prompt path borrows part of the expert cache as a staging buffer (the loan), and the K/V's ceiling stopped at the loan's first slot: the borrowed region was excluded from the cache for the whole run. When the K/V needed those slots, the engine asked the driver for new VRAM, and on a card that has none left the request ended with
and new VRAM, the cache being at its floor.Result (measured)
k8v4, 16 GB RTX 3080 Ti Laptop,
--max-context 524288, 510K prompt, 1.5 GiB reserve,--prefill 6144, staged chunks:K/V grownline has noand new VRAM)The loan shrinks from 6,144 to 4,608 tokens and the freed slots become K/V cells; nothing is requested from the driver. 128K on a cool card: 1463.5 tok/s (previous build 1514.5, within run-to-run heat).
What changed
kvg_ensure, at its floor and before any new VRAM: asks the prompt path to re-lay out in the largest chunk whose freed granules cover the K/V's need, then unmaps the tail into the cache (kvg_fit_loan).--prefill-stream-min N: chunks of N tokens or more stream every expert instead of staging the routed ones; an explicit value wins over the CPU share's own limit. Default behaviour is unchanged (the built-in 1,024 threshold).remainis 0), so their behaviour is the same as before.Validation
K/V grownwithoutand new VRAM).Limits
--kv-grow(the elastic K/V path).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.