mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3281] [Engine] add request-scoped prefill VRAM loans #4544
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#4544
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/3281
Author: @c3c
Created: 10/19/2026
Status: 🔄 Open
Base:
main← Head:feature/vram-loans📝 Commits (5)
605e930prefill: add manual prompt VRAM loans2512dc1Fix deferred verifier logit bias initialization6b82923prefill: integrate VRAM loans with current serve path08a3e00prefill: keep repeat loans free of decode guardcf14700prefill: restore verifier state after loans📊 Changes
9 files changed (+535 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(+308 -30)📄 Description
This the rebased version of https://github.com/Niko1221/Strata/pull/1581 for the VRAM loaning part of the PR.
Reopened PR of https://github.com/Niko1221/Strata/pull/3105 as I couldn't use /reopen.
Problem and result
Current main can borrow expert-cache storage for prompt buffers, and
--prefill-head-aliascan reuse the native output-head allocation. On a tight8 GiB serve configuration, however, verifier, native-head, and MTP decode
resources still prevent the automatic planner from selecting a large prompt
geometry.
This PR adds a manual request-scoped transaction that releases those
decode-only resources during prefill, grows the elastic expert cache, and
restores all resources and runtime state before generation. It also supports
repeating the transaction for later long messages.
On an RTX 2080 Super Max-Q, enabling the loan in the same binary changed the
automatic plan from a 2,304-token chunk to 5,376 and increased median prefill
from 513.6 to 774.8 tokens/s (+50.9%). Median generation was 30.9 tokens/s in
both arms. The default path is unchanged when the master switch is absent.
Approach
Example full configuration:
All six variables are introduced here, but they are not six independent
requirements:
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,--specThe existing
--vram-elasticoption supplies the segmented expert-cachebackend. Startup loans cannot use a prompt-length threshold because the first
request is not known at initialization; the repeat threshold applies only to
later prompts.
Current main already loans expert-cache slots to prompt workspace. This PR
extends the lifetime transaction to resources that are needed only for decode:
the verifier arena/graphs, native output head, MTP routed experts, and MTP draft
head. Reload restores PCIe balancing, adaptive-overlap gating, residency
pre-launch synchronization, logit bias, and MTP draft sampling before decode.
Safety and supported configurations
The feature is admitted only on the serialized, one-GPU NVIDIA CUDA serve path.
It requires
--serve,--vram-elastic, and CUDA virtual-memory segments of atleast 64 MiB. Startup rejects batch slots, pipeline windows, layer split,
helper/remote/peer caches, HIP, and
--prefill-head-alias. MTP/head loansrequire
--mtpwith--spec >= 2; the head loan also requires a native outputhead. Invalid combinations fail before resources are deferred.
Multiple conversations are supported when requests are processed sequentially
by one server. Concurrent batch sessions are deliberately rejected. Separate
Strata processes sharing a GPU are not coordinated and must not take loans
concurrently.
The transaction does not change the routing algorithm. A larger cache and a
different chunk geometry can change which experts execute on GPU and the order
of floating-point operations, so generated tokens are not promised to be
bit-identical to a loan-off run.
Validation
Tested revision:
cf14700f, based on upstreame88ee39d(0.2.0-beta). Thecombined build used this branch plus the separate SM75 native-IQ branch at
db02a533.Passed
SASS.
machine. The production server was stopped during each run and restored and
health-checked afterward.
rebased binary with every new flag absent measured 513.6 PP median versus
514.6 PP for current main (-0.2%, within the run ranges), and selected the
same 2,304/226 plan.
prompt released verifier, native-head, and MTP resources; retried smaller
geometries when necessary; restored all resources; and generated all 256
requested tokens without a CUDA/runtime failure.
Failed
upstream
src/kernels/gdn_chunk_parity.cppcalls POSIXsetenv. Theproduction target compiles and the end-to-end loan paths run; that unrelated
current-main test compile failure remains.
Not run
the feature rejects these configurations at startup.
reasoning cap, so these runs validate lifecycle and rates, not complete
answer equivalence.
Benchmark configuration
7.5.
--spec 4,--short-read 0, experimental speed projection,STRATA_BF16_TC=1, andSTRATA_PROMPT_ATTN_Q4_TC=1held constant.every repetition. Values below are medians of three engine timing lines.
Results
The same-binary isolated loan effect in this workload is +50.9% PP. The
combined row is included to show composition, not attributed to this PR alone;
the SM75 native-IQ PR adds a
separate +10.9% over loans, and the combined gain over current main is +67.0%.
For comparison, current main with
--prefill-head-aliasselected a1,536-token chunk and measured 370.3 PP median on this exact workload. That is
not a general claim against head alias; it explains why its existing narrower
loan did not replace this transaction on this memory-constrained setup.
The later-message lifecycle run selected 4,352 tokens after bounded retries,
completed prefill at 841.0 PP, restored the deferred resources, and generated
at 28.0 TG. Compared with the 30.9 TG fresh-request median, that is a 9.4%
reduction and remains inside the 10% decode-regression limit used for this
experiment.
Additional qualification evidence
Fixed-geometry mechanism check
A matched 2,304/227 experiment held prompt geometry constant to distinguish
the transaction cost from the planner benefit:
The +0.1% PP difference is noise. The loan is not a faster kernel; its value is
allowing a larger cache/chunk geometry to fit. Benefit therefore depends on
prompt length and on whether releasing the decode resources crosses a useful
planner threshold.
Cross-GPU loan qualification
The transaction is not SM75-specific. An earlier qualification used an RTX
4070 Ti (12 GiB, SM89), INT8 KV, a 196,608-token context, and a 512-slot staging
ring. These measurements were made on an older v0.1.41 source revision, so they
support the cross-GPU mechanism but are not current-main performance numbers.
Loan-off and loan-on runs were interleaved, serialized, and used fresh engine
processes. The 36k result is a three-run median and the 72k result is a five-run
median; completions were capped at 512 tokens.
At 36k, loans reduced GPU prompt work by 6.0%, but the fixed resource-reload
cost left engine PP 0.9% lower. At 72k, they reduced GPU prompt work by 5.5%
and improved engine PP by 2.4%. The five-run 72k PP ranges were
2,604.3--2,633.7 off and 2,501.1--2,696.3 on; four of the five loan-on runs
were at least 2,673.5 PP, with one retained slow outlier. This crossover is why
the feature remains a manual opt-in rather than a default.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.