mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3105] [CLOSED] Add request-scoped prefill VRAM loans #4457
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#4457
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/3105
Author: @c3c
Created: 10/18/2026
Status: ❌ Closed
Base:
main← Head:feature/vram-loans📝 Commits (4)
610c507prefill: add manual prompt VRAM loans66bc331Fix deferred verifier logit bias initializationb736bffprefill: integrate VRAM loans with current serve pathae874a2prefill: keep repeat loans free of decode guard📊 Changes
9 files changed (+520 additions, -58 deletions)
View changed files
📝
docs/DETAILS.md(+14 -0)📝
docs/VRAM_ELASTIC.md(+17 -0)📝
include/strata/core/mtp.hpp(+14 -1)📝
include/strata/core/native_head.hpp(+5 -0)📝
include/strata/core/verify.hpp(+4 -0)📝
src/core/mtp.cpp(+99 -27)📝
src/core/native_head.cpp(+31 -0)📝
src/core/verify.cpp(+43 -0)📝
src/program/generate.cpp(+293 -30)📄 Description
This the rebased version of https://github.com/Niko1221/Strata/pull/1581 for the VRAM loaning part of the PR.
Summary
This PR adds a manually enabled, request-scoped VRAM loan for prompt prefill.
It temporarily lends decode-only allocations to the prompt path, then restores
the verifier, native output head, MTP experts and draft head before generation.
The repeat-prefill option applies the same transaction to later long messages.
The default path is unchanged when the flags are absent.
What changed
Enable the feature with:
All six
STRATA_PREFILL_*variables above are introduced by this PR, but theyare not six independent requirements:
STRATA_PREFILL_ELASTIC_LOANis themaster switch; MTP/head loans are staged sub-options; and the retain/repeat
flags apply only when later prompts should repeat the transaction. A minimal
startup experiment needs only the master switch. The existing upstream
--vram-elasticcommand-line option is required as the segmented-cachebackend; it is not part of this PR.
STRATA_PREFILL_ELASTIC_LOANSTRATA_PREFILL_MTP_LOANSTRATA_PREFILL_HEAD_LOANSTRATA_PREFILL_RETAIN_STARTUP_CHUNKSTRATA_PREFILL_REPEAT_LOANSTRATA_PREFILL_REPEAT_MIN_TOKENS--vram-elastic,--serve,--mtp,--specSTRATA_PREFILL_REPEAT_MIN_TOKENSapplies only to subsequent prompts. It isclamped to a minimum of 256 tokens and defaults to 1,024. Startup loans are
controlled by the startup flags because the first request length is not known
when the engine initializes.
The implementation is in the serve/prefill lifecycle (
src/program/generate.cpp)and the verifier, native-head and MTP resource transactions
(
src/core/verify.cpp,src/core/native_head.cppandsrc/core/mtp.cpp).As mentioned in the original PR: benefit depends on prompt length and whether the released VRAM
crosses a useful planner threshold.
Extra Notes
Test system and method
7.5.
12.2 GB/s.
477ac13c) plus this PR.enabled with
--spec 4, and the experimental speed projection held constant.cap. Runs were serialized with a fresh engine; PP/TG are the engine-reported
timing-line rates.
Guarding and supported configurations
The feature is restricted at startup to the serialized, one-GPU NVIDIA CUDA
server path. It requires
--serve,--vram-elastic, CUDA virtual-memorysegments of at least 64 MiB, and rejects batch slots, pipeline windows, layer
split, helper/remote/peer caches, HIP and
--prefill-head-alias. MTP/headloans require
--mtpwith--spec >= 2; the head loan additionally requiresa native output head.
Invalid combinations fail before any decode resource is deferred.
CPU worker count does not change the ownership model. Multiple conversations
can use one server sequentially, but concurrent batch sessions are rejected.
Separate Strata processes sharing one GPU are not coordinated and must not run
concurrently with loans enabled.
Measurements
The fixed-planner A/B isolates the transaction when geometry is held constant:
This is effectively neutral (+0.1% PP, within run noise). The feature is not a
same-kernel speedup; its purpose is to make a larger prompt geometry fit.
With automatic planning (
--prefill auto), the loan-only run selected a larger geometry:The combined configuration is 11.5% faster in PP than loans alone in this
screen. The planner also changes the chunk/ring geometry, so this is reported
as an end-to-end combined benefit rather than a loan-only percentage.
A repeat-prefill test released and reloaded the verifier, native head, MTP
experts and draft head without a CUDA/runtime error. The loan-only follow-up
completed at 742.9 PP / 30.4 TG.
This PR is intentionally incompatible with
--prefill-head-alias; startupfails before a loan is taken. Use head-alias mode by itself, or remove it when
using the loan transaction.
Cross-GPU VRAM-loan qualification
The loan is not SM75-specific. A separate test used an RTX 4070 Ti
(12 GiB, SM89), INT8 KV, a 196,608-token context, a 512-slot staging ring - but an older v0.1.41 source revision. Loan-off and loan-on runs were interleaved,
serialized, and started from a fresh engine. The 36k result is a three-run
median and the 72k result is a five-run median; both used a 512-token
completion cap.
The larger loan-backed chunk reduced median GPU prompt work by 6.0% at 36k
tokens and 5.5% at 72k. Loading the deferred output-head and MTP resources is
a fixed boundary cost, so the 36k request was 0.9% slower by the engine's
end-to-end PP rate while the 72k request was 2.4% faster. The five-run 72k PP
ranges were 2,604.3--2,633.7 off and 2,501.1--2,696.3 on; four of five loan-on
runs were 2,673.5 PP or higher, with one retained slow outlier. This is evidence
that the general CUDA loan works beyond Turing, but also that it should remain a
manual opt-in: benefit depends on prompt length and whether the released VRAM
crosses a useful planner threshold.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.