mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1581] [CLOSED] CUDA prefill VRAM loans and SM75 Q4/native-IQ opt-ins #3542
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#3542
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/1581
Author: @c3c
Created: 10/8/2026
Status: ❌ Closed
Base:
main← Head:feature/optimizations📝 Commits (7)
be38741prefill: add opt-in SM75 Q4 attention path1be0d8aprefill: add opt-in SM75 native IQ experts9574b80prefill: add manual prompt VRAM loans910b541Fix deferred verifier logit bias initialization27a019fpeer: initialize CUDA context before arena registration69bad8fpeer: cap WDDM arena pinning in peer modeb7d7081prefill: stage unpinned experts for peer GPU📊 Changes
17 files changed (+843 additions, -138 deletions)
View changed files
📝
CMakeLists.txt(+7 -0)📝
docs/DETAILS.md(+26 -0)📝
docs/SECOND_GPU.md(+9 -0)📝
docs/VRAM_ELASTIC.md(+18 -0)📝
include/strata/core/mtp.hpp(+14 -1)📝
include/strata/core/native_head.hpp(+6 -0)📝
include/strata/core/verify.hpp(+4 -0)📝
include/strata/prefill/moe_fused_iq.hpp(+7 -2)📝
src/core/mtp.cpp(+98 -26)📝
src/core/native_head.cpp(+40 -0)📝
src/core/verify.cpp(+43 -0)📝
src/kernels/cuda/qsa_prompt_attn.cu(+8 -2)📝
src/kernels/qsa_prompt_attn_parity.cpp(+32 -10)📝
src/prefill/moe_fused_iq.cu(+143 -43)📝
src/prefill/prefill.cpp(+82 -22)📝
src/program/generate.cpp(+303 -31)📝
tests/cuda/prefill_fused_iq_test.cpp(+3 -1)📄 Description
CUDA prefill VRAM loans and SM75 Q4/native-IQ opt-ins
tldr; massive PP speed win on my 8GB VRAM laptop GPU
Summary
This branch adds two manual Turing prompt-compute paths and one manual,
request-scoped CUDA memory feature:
STRATA_PROMPT_ATTN_Q4_TC=1and compiled with the qualified 64-cell tile.STRATA_PF_FUSED_NATIVE_SM75=1. The separately manualSTRATA_PF_FUSED_NATIVE_SM75_ADAPTIVE=1enables the per-format SM75 shapeprobe; unsupported layers remain on the existing path.
They temporarily use decode-only VRAM for the expert cache during prefill,
then restore the verifier, native head and MTP resources before generation.
A repeat-prefill option applies the same transaction to later long messages.
The Q4-attention and native-IQ paths are SM75-specific. The VRAM-loan feature
does not require SM75: it can apply to other NVIDIA CUDA GPUs with virtual
memory management and the supported single-GPU server configuration. The
compute-path measurements below use an RTX 2080 Super Max-Q; the loan is also
qualified separately on an RTX 4070 Ti.
All switches are off when absent. Existing behavior is therefore unchanged for
users who do not opt in.
Benchmark platform
--spec 4, same draft model and profile in each matched armThe long-prompt qualification used approximately 31,258 fresh prompt tokens
and a 512-token completion cap. Each run was serialized, started with a fresh
engine, and checked for normal completion. No parallel Strata servers were
used.
Results
End-to-end results
Each row is the median of three fresh-engine runs over 31,258 prompt tokens and
512 generated tokens. Baseline and opt-in runs use the same v0.1.41 source
revision, model, prompt and runtime settings.
The Q4_0 result is +104.8% PP with effectively unchanged TG. The INT8
result is +96.1% PP and -7.4% TG; its TG range was 21.1--23.1 and stayed
within the 10% guardrail. These are complete-stack results, not percentages for
individual features: the opt-ins also change prompt chunk, staging-ring and
expert-cache geometry.
The Q4_0 opt-in runs used:
STRATA_PREFILL_REPEAT_LOAN=1is used only for the subsequent-messagequalification below; it does not participate in a fresh engine's first prompt.
For subsequent messages,
STRATA_PREFILL_REPEAT_MIN_TOKENSsets the minimumnumber of uncached prompt tokens that triggers releasing and reloading the
decode-only resources. It defaults to
1024and is clamped to a minimum of256. The threshold does not govern the first prompt: the startup MTP/headloan is an engine-start on/off choice because those resources are deferred
before the first request length is known.
Individual feature evidence
held constant, enabling only this path changed the three-run median from
613.6 to 849.8 PP (+38.5%). QSA attention fell from about 19.2 to 5.1
seconds.
native path measured 829.4 PP (+10.7%). This comparison also changed the
plan from 5,376/227 to 4,864/512, so it is not a pure kernel-only percentage.
comparison, so this PR does not assign the loan a percentage. Its observable
effect is enabling the larger cache/chunk geometry and restoring all deferred
decode resources before generation.
The existing
STRATA_SELECT_SIMT=1option can compound with these changes: anexact full-stack A/B changed 849.8 to 879.9 PP (+3.54%). SIMT is not part of
this PR.
Subsequent-message loan
One serialized-session qualification used INT8 KV, a 131,072-token context and
128-MiB VRAM segments. After a 60-token warm-up, a 32,458-token
subsequent prompt selected 3,328/512 and completed at 787.0 PP / 23.1 TG
with 512 generated tokens. The request released and restored the verifier,
native output head, MTP experts and draft head without a CUDA/runtime error.
For example, a configuration that only takes repeat loans when at least 50,000
new prompt tokens remain after prompt-cache reuse can use:
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 and
the same 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.
Correctness and safety
STRATA_SELECT_SIMT=1is also prompt-only, but uses a different FP32 tiledscorer and summation order; it can change selected cells and reasoning text.
kernel; unsupported formats fall back to MMQ/previous behavior.
changed by these features.
--serve,--vram-elastic, CUDA virtual memory management, one GPU and aVRAM segment of at least 64 MiB.
layer-split or multi-GPU configurations, helper caches, peer-device mode and
HIP.
passed at 4,096/512 and 1,500/512. The native
IQ3_XXS/IQ4_NL test retained a fused-vs-rounded RMS of
4.811e-05. Thefocused validation set passed 10/10, and the Release SM75 build completed
without an error.
native head, MTP routed experts and draft head, then completed 512 generated
tokens without a CUDA/runtime error.
capture for native shape selection had identical bounded reasoning and draft
acceptance. A separate SIMT quality pair returned the same visible control
line and normal stop, but reasoning differed, as expected from the changed
scorer arithmetic. A full unrestricted answer-parity sweep remains future
work.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.