mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2964] [CLOSED] [Engine] decode: STRATA_ADAPT_FETCH=1|2 (opt-in) - the PCIe share's most-routed misses are admitted into the VRAM tier (-5.6% a round on the NVFP4 pack) #4366
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#4366
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/2964
Author: @sergqwer
Created: 10/17/2026
Status: ❌ Closed
Base:
main← Head:pr/adapt-fetch📝 Commits (1)
f8184f2decode: STRATA_ADAPT_FETCH=1|2 - the PCIe share's blobs are admitted into the VRAM tier (opt-in)📊 Changes
9 files changed (+256 additions, -35 deletions)
View changed files
📝
docs/DETAILS.md(+1 -0)📝
include/strata/core/expert_source.hpp(+23 -1)📝
include/strata/core/verify.hpp(+3 -1)📝
include/strata/kernels/verify_kernels.hpp(+7 -0)📝
metal/src/engine/stubs.cpp(+2 -2)📝
src/core/expert_source.cpp(+77 -6)📝
src/core/verify.cpp(+8 -3)📝
src/kernels/cuda/verify_kernels.cu(+24 -8)📝
src/program/generate.cpp(+111 -14)📄 Description
Problem and result
Decode reads expert blobs from host RAM three ways: the CPU pool, the PCIe share (
--pcie-fracof a layer's misses, staged into VRAM byfetch_blobs), and the adaptive tier's swaps. The PCIe share's blobs cross into VRAM anyway, and today they are dropped after the window. This opt-in lets the most useful of them stay there.STRATA_ADAPT_FETCH=2on the NVFP4 pack with a ~29% cache and--pcie-frac 0.25: 14.31 -> 13.51 ms a decode round (-5.6%), 169.8 -> 179.5 tok/s; every pair faster.Related discussion
None beyond this PR. It was #2964 before the 0.2.0-beta tracker reset. It is opt-in and changes no default. Since the reset it has one change besides the rebase: the SYCL and Metal builds are kept linking (see Approach, last bullet).
Approach
Opt-in,
STRATA_ADAPT_FETCH=1|2; unset changes nothing.STRATA_ADAPT_FETCH_MIN(1) andSTRATA_ADAPT_FETCH_MARGIN(0.5) more than the layer's least-routed resident expert that the window does not route,fetch_blobscopies it straight into that expert's slot (a new optionaldst2target per blob) instead of staging it, and it becomes resident: a swap with no RAM read of its own.=2leaves the tier's own swaps out of a layer where an admission ran since the tier's last round; the tier keeps the layers the share did not reach.=1runs beside them.host_resduring a window; the device table follows through #1517's pre-launch patch (3f2db5e2), whether the tier waits or not.mainthat is the multi-layer lookahead with 0.2.0's confidence scores, kept as they are).--batch,--pipeline-windows,--adapt-async, a layer split, peer or helper GPUs, the resident RAM mode,STRATA_ADAPT_OVERLAP=1, the foresight swap space,--pcie-mode dma|direct, or no PCIe share.STRATA_ADAPT_FETCH_VERIFY=1(strata generate) reads every admitted slot back and compares it with the experts' bytes.dst2), zero unless the opt-in writes them.fetch_blobs/rebase_ptrsget overloads withdst2; the old signatures stay, because the SYCL copy takesinclude/strata/kernels/verify_kernels.hppfrom the root and defines and calls those. The Metal stubs (metal/src/engine/stubs.cpp) follow the new overloads, written by hand ingen_stubs.py's form. (The first version of this PR gavedst2a default argument instead; a g++ stand-in for the SYCL link showed that breaks it:undefined reference to fetch_blobs(..., unsigned long long const*).)docs/DETAILS.md: one bullet next to #1517's.Validation
Revision: this branch, one commit
f8184f25onmaine88ee39d(v0.2.0-beta + 12 commits). RTX 5090, Ryzen 9 9950X3D, 128 GB, Windows 11; MSVC 2022 17.14, CUDA 13.3, release configure (-DSTRATA_PORTABLE=ON,75-real;86-real;89-real;120-real, ggml at the pinned 3cf03257). Model: the NVFP4 GPTQ pack (Maximilian228/Qwen3.8-Flash-Next-NVFP4-GPTQ-Strata, upstream setup's--family nvfp4 --model NVFP4files).Passed:
Unset =
main.strata --servewith setup's model files plus--expert-cache 3000 --prefill auto --spec 6 --spec-min-p 0.7 --max-context 262144 --kv int8 --gpu 0 --pcie-frac 0 --adapt-every 1000000, envSTRATA_PREFILL_CPU_SHARE=0 STRATA_PCIE_BALANCE=0 STRATA_IQ_MT_MIN=1 STRATA_DUMP_FIRST_LOGITS=<file>; a 2,100-token and a 32,037-token prompt, 32 greedy tokens each: first-token logits and tokens byte-identical to a build ofmaine88ee39d(2K1e9c612c, 32Kf5b2872c).Checks with it on.
strata generatewith setup's model files plus--expert-cache auto --vram-reserve-mib 1500 --pcie-frac 0.25 --prefill auto --spec 6 --spec-min-p 0.7 --kv int8 --max-context 262144 --stats, 600 tokens after a 45-token prompt,STRATA_ADAPT_FETCH=2 STRATA_ADAPT_FETCH_VERIFY=1 STRATA_ADAPT_CHECKRES=1: 6,511 admissions (23.2 a round); the read-back covered 6,189 of them and 0 differed. The residency check covered 281 windows: 0 with mismatches, 0 layer-windows with CPU experts and no activation published. The tier itself still swapped 1,357 experts in the layers the share did not reach.A/B. The same build in both arms,
strata --servewith setup's model files plus--expert-cache auto --vram-reserve-mib 1500 --pcie-frac 0.25 --prefill auto --spec 6 --spec-min-p 0.7 --kv int8 --max-context 262144; the adaptive tier on, as by default. 4 interleaved pairs (off f2 f2 off off f2 f2 off); each start: 4 decodes of up to 600 tokens after a 45-token prompt. "ms a round" = decode time / (tokens - accepted drafts), which does not depend on how many drafts a run accepts.STRATA_ADAPT_FETCH=2The cache got 7,205-7,275 slots, about 29% of the 24,576 experts. On
477ac13c(0.1.45) the same A/B gave 16.00 -> 15.16 ms a round (-5.3%);maindecodes faster in both arms now.The SYCL and Metal link shapes, without those toolchains: g++ stand-ins that include the new header. A SYCL-like unit (the old signatures defined and called, as in
sycl/src/kernels/cuda/verify_kernels.dp.cppandsycl/src/core/verify.cpp) links and calls them; a Metal-like unit (the two stub lines fromstubs.cpp, called the waysrc/core/verify.cppcalls them) links and reaches the stubs.Failed: none observed on this revision. (With the PR's first header, the SYCL-like stand-in failed to link, as said above.)
Not run:
STRATA_ADAPT_FETCH=1on this pack, other cache sizes, Linux.Limits
--pcie-frac 0.25): chat -9.1% and 32K explain -6.8% a round. That model is no longer on this PC.--pcie-frac 0) or with--pcie-mode dma|directit is off, and the start log says why.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
[PR #2964] [Engine] decode: STRATA_ADAPT_FETCH=1|2 (opt-in) - the PCIe share's most-routed misses are admitted into the VRAM tier (-5.6% a round on the NVFP4 pack)to [PR #2964] [CLOSED] [Engine] decode: STRATA_ADAPT_FETCH=1|2 (opt-in) - the PCIe share's most-routed misses are admitted into the VRAM tier (-5.6% a round on the NVFP4 pack)