mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3060] [CLOSED] [Engine] STRATA_RAM_ADAPT: move experts out of their stage buffer, up to 4 pairs a layer #4428
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#4428
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/3060
Author: @SanghunYun
Created: 10/18/2026
Status: ❌ Closed
Base:
main← Head:ram-adapt-stage📝 Commits (1)
c06903cSTRATA_RAM_ADAPT: move incoming experts out of their stage buffer, up to 4 pairs a layer📊 Changes
5 files changed (+97 additions, -27 deletions)
View changed files
📝
docs/DETAILS.md(+17 -17)📝
include/strata/core/expert_source.hpp(+6 -1)📝
src/core/expert_source.cpp(+27 -0)📝
src/program/generate.cpp(+25 -9)📝
tests/core/file_expert_source_test.cpp(+22 -0)📄 Description
Problem and result
STRATA_RAM_ADAPTmoves experts the conversation keeps routing to into the RAM copy, but each move re-reads the incoming expert from the file, and only one pair per layer moves per window. The incoming expert was usually just read for the window before, and its blob is still in that read's stage buffer.With this change, a move copies the blob out of the stage buffer instead (no file read), and because that is cheap, a layer may move up to 4 pairs instead of 1.
nnow caps only the moves that still need a file read;STRATA_RAM_ADAPT=1is enough.RTX 3060 12 GB, 32 GB RAM, NVMe, 20.5 GiB RAM tier, v0.2.1, two models read in place: IQ2_XS and IQ3_XXS (only
--pack/--nativediffer). Each run is a fresh engine with the stock profile and the model's page cache dropped. 3 interleaved runs per setting; ± is the 95% CI of the difference. IQ3_XXS's expert cache holds 2791 VRAM slots instead of 3769, so more experts come from the file and the gain is larger.RAM_ADAPT=8(main)RAM_ADAPT2(main)=1Against main's
=8: IQ2_XS decode +5.5% (±1.0), prompt +2.9% (±1.9), storage reads −24.5%; IQ3_XXS decode +17.1% (±2.0), prompt +6.5% (±2.8), storage reads −35%. With both models the PR is ahead in every request block (1–10, 11–30, 31–60, 61–120).Each point is a 10-request window over the 3 runs per setting (window sums: tokens / time, reads / tokens). A column shares its y axis.
standard-v1(22 requests, no concurrency stage)=8RAM_ADAPT2Against
=8onstandard-v1, decode is +1.6% (±2.6) with IQ2_XS and +3.9% (±4.1) with IQ3_XXS, both within noise; prompt is unchanged. No case is worse beyond noise. Short requests (performance-short, IQ2_XS) go from 44.0 (off) to 49.0 tok/s (+11%).These runs are on v0.2.1. The branch is rebased on v0.2.2 (
011c9e60), which does not touch this path; a spot check there (IQ2_XS ShareGPT, one PR run between two=8runs within 0.7%) gives decode +6.5%, prompt +2.4%, storage reads −24.9%.Engine arguments, identical in every run (only the binary and the
STRATA_RAM_ADAPT*variables differ, and--pack/--nativebetween the models):Related discussion
#1838 (ported to main), the maintainer's comment there on the short-request cost, and this PR's earlier version.
Approach
replace_resident_stagedcopiesinout of its finished stage buffer understage_mu_, soclaim_stagecannot hand that buffer to another blob during the copy. It uses the same Foresight hold and between-window checks asreplace_resident. In the selection loop, each layer pairs its most-routed experts outside the copy with its least-routed unused ones inside it, up to 4 pairs. The pair thresholds (routed count 2 or more, unused below 0.5) are unchanged.The default path is unchanged when
STRATA_RAM_ADAPTis unset (checked byte for byte, see Validation).RAM_ADAPT2is untouched. The stats line also reports how many moves came out of a stage buffer.Validation
Passed:
file_expert_source_testand--rotation-gpupass, including a new staged-move case with exact bytes on pinned and pageable buffers.file_expert_source_testhost-side passes with GPUs hidden.STRATA_RAM_ADAPTunset, stock again (IQ2_XS,standard-v1, 22 requests, fresh engines): 22/22 equal outputs (server tool-call ids left out). Fixed so that stock equals stock, adaptive VRAM tier on:--adapt-async 0 --pcie-frac 0.10,STRATA_ADAPT_NOWAIT=0 STRATA_PREFILL_CPU_SHARE=0 STRATA_IQ_MT_MIN=1.=8. The moves change no computation, only which experts are in pinned RAM, and only those can go to the GPU in the PCIe share of a window's misses (expert_source.cpp); the GPU rounds slightly differently from the CPU. With--pcie-frac 0, stock, this PR (=1) and main's=8give 22/22 equal outputs.Failed: none observed.
Not run:
expert_source.cpp,generate.cppandexpert_source.hpp(sycl/CMakeLists.txt), so it is not affected.standard-v1throughstrata bench run: the request files and body were replayed throughserve/server.pywith--greedy, so this is not a submittable standard result.Limits
replay.py(also replaysstandard-v1from your checkout and records the engine's timings and storage reads),summarize.py(settings × runs, Welch intervals) and our per-run numbers for both models.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.