mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#2835
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/796
Author: @j-luwierski
Created: 10/4/2026
Status: ❌ Closed
Base:
main← Head:fix/765-startup-vram-plan📝 Commits (7)
744e039generate: one startup VRAM plan before the expert cache is committed (#765)0cb61d2generate: review pass on the startup VRAM plan (#765)1da36a2generate: the WDDM post-touch correction revalidates the prompt plan (#765 review)d3a22c9generate: the prompt loan's residency map outlives the token graph (#765 review)5b6cb2fgenerate: refuse the unsafe owned chunk before WDDM can page it (#765, Enky's measurements)af2cdd4generate: the accepted EffectivePrefillPlan is the runtime's contract (#765 review)65e1581serve: the accepted borrowed loan carries its request-time bookkeeping (#765 review)📊 Changes
8 files changed (+1986 additions, -241 deletions)
View changed files
📝
CMakeLists.txt(+11 -1)📝
docs/DETAILS.md(+15 -0)📝
include/strata/prefill/prefill.hpp(+10 -2)➕
include/strata/prefill/vram_plan.hpp(+237 -0)📝
src/prefill/prefill.cpp(+65 -12)➕
src/prefill/vram_plan.cpp(+579 -0)📝
src/program/generate.cpp(+464 -226)➕
tests/core/vram_plan_test.cpp(+605 -0)📄 Description
Closes #765
Problem
At very large contexts, individually reasonable VRAM decisions combined into an
unworkable whole. Startup sized the expert cache from
cudaMemGetInfoand aone-line prefill estimate (
160 + chunk * 680 / 1024, ~7x high at a24576-token chunk), and only found out at the first prompt whether the chunk it
had committed to could still be served - the reported 524K failure: an int8 KV
of ~3.7 GiB, a cache that shrank around it, and a
--prefill 24576whosebuffers no longer fit anywhere, so the engine died between the model load and
READY.
Enky's measurements on a 5080 (Windows/WDDM) sharpened this: an allocation that
does not fit does not necessarily fail - under default WDDM the driver pages it
into shared system memory (+9.25 GiB of Shared Usage, prefill collapsed to
~105 tok/s), so "cudaMalloc succeeded" proves nothing about the configuration
being safe.
What this does
strata/prefill/vram_plan.{hpp,cpp}): the promptpath is priced with the exact
Prefill::bytes_needed()BEFORE the expertcache is committed; expert residency is the elastic consumer and gives way
first; an impossible configuration is refused at startup with its budget and
the knobs that make room, instead of dying at the first prompt.
plan_lend_chunks): the #583bisection with its ring what-ifs, 0.1.39's list, a fixed chunk's halving -
shared by the startup plan, the WDDM post-touch revalidation and the runtime
loans.
EffectivePrefillPlan+check_runtime_prefill_use()): generate and single-GPU serve consume theaccepted chunk/loan/ring directly and refuse - before any prompt allocation -
on a mode or size departure. The runtime may run less (a shorter prompt),
never more.
revalidated; a shrink re-prices the prompt path against the final physical
cache (a borrowed plan that lost its loan is repriced as owned); the retry
limit bounds shrinking, never validation. The loan's request-time
bookkeeping (
PfPart) is built from the accepted plan, so lend/refill keepthe cache residency contract.
prefill_borrow_available): the residency mapis built whenever the prompt path may borrow, token graph or not, and
startup and runtime read the same flag.
--prefill autoowned fallbacks are logged (planned vsunexpected); the serve pre-check refuses when no owned chunk through 512
fits instead of handing the allocation to WDDM (with a Windows sysmem
warning); owned fallbacks reduce on the 256-token grid; budget hints name
--kv-residentas a lever where the model supports KV streaming.Measured (RTX 4070 Ti SUPER 16 GB, Linux)
--prefill auto(IQ3_XXS, int8 KV)--prefill 24576--prefill 24576(the WDDM-paged config)Tests
vram_plan_test(new, no GPU): the planner's budget cases, the sharedchunk/loan policy, the runtime contract, Enky's fallback reductions (E1–E5)
and the runtime-mode cases (R19–R34) - all pass.
ctest: same results as main (the 9 pre-existing environment failures areunchanged);
prefill_fused_iq_testpasses.STRATA_RING_BYTES,STRATA_PREFILL_RING,STRATA_PREFILL_LEND_PCT, the 128-slot loan floor,--expert-cache-per-layer,--vram-elastic, the reserve adaptation on small cards (#496), and multi-GPUstage planning (untouched by design - the planner does not model stage caches
yet).
Not covered
available); the planner decides from arithmetic before any allocation, so
the fallback setting has nothing to change - but the issue's 16-GiB
Blackwell arm deserves a re-run on the original rig.
(sessions for later stages do not exist at planning time); their per-stage
serve logic is unchanged.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.