mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4065] [CLOSED] [Engine] Fill the startup expert profile with several threads (STRATA_FILL_THREADS) #4893
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#4893
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/4065
Author: @chenyb999-zhcn
Created: 10/25/2026
Status: ❌ Closed
Base:
main← Head:engine-fill-parallel📝 Commits (2)
0ee8937engine: fill the startup expert profile with several threads (STRATA_FILL_THREADS, default 8): admit every pair serially first, then run blob_stable and fill_slot_blocking over disjoint slots on workers (the decode-time refill already does this concurrently); the layer-split stages' fills get the advise-free-parallelism they never had, plus the timing line; the unbuffered tier and STRATA_FILL_THREADS=0/1 keep the sequential loop unchanged (#4064)0b2e1cdengine: the parallel profile fill also takes the unbuffered tier: the 64-pair batch loop is a serial reader (82 MB/s on the box of #4064, 503 s startup, against 1372 MB/s from the same parallel workers on the same O_DIRECT tier; startup 503 s -> 62 s, the stage fill 146.8 s -> 16.4 s), and RouterLookahead::warm stops hinting the mapping with MADV_WILLNEED when the reads bypass the page cache (one fill measured 728k hints, 3.7 GB of readahead for nobody, competing with the reads that matter); STRATA_FILL_THREADS<=1 still keeps the sequential batch loop unchanged (#4064)📊 Changes
4 files changed (+150 additions, -11 deletions)
View changed files
📝
docs/DETAILS.md(+3 -0)📝
include/strata/core/expert_cache.hpp(+4 -1)📝
src/core/expert_source.cpp(+2 -0)📝
src/program/generate.cpp(+141 -10)📄 Description
Closes #4064
Problem and result
A cold
--servestart of a 48-layer MoE (Qwen3.8-Flash-Next UD-Q4_K_XL, 108 GB of GGUF in four shards) on a2x Tesla V100 32 GB / 96 GB RAM box reads ~115 GiB: the PLE n-gram table (26.8 GiB), the dense weights (5.7 GiB),
the startup expert profile (48.6 GiB into the two GPU caches) and the 8-30 GiB page-locked RAM complement. Only
the expert fills read with a deep queue; everything else read as a single stream through the page cache, one
128 KiB window or one 4 KiB fault at a time.
A cold start before this PR (298 s wall clock,
drop_cachesin the launch script,--resident-budget-gib 32):--ple-io ram72% of that start sat in the first four rows: 34.5 GiB read through the page cache against a drive that does
813 MB/s for random 1 MiB reads at queue depth 1 and 1.4-1.9 GB/s with 8-63 requests in flight.
The same start after this series (same box, same config, no
drop_cachesin the script,--resident-budget-gib 8):What changed
Four independent fixes, each one turning a serialized read into the machine's real parallelism:
STRATA_FILL_THREADS, default 8) -parallel_profile_fillover disjoint slots,
blob_stable+fill_slot_blockingper worker, the shape the decode-time refill alreadyused.
STRATA_FILL_THREADS<=1keeps the old sequential loop. It also walks the pairs in (layer, expert)order instead of profile order: the profile is ranked by routing frequency, which turned the fill into a random
walk over the two 49 GiB shards (see the limits below).
RouterLookahead::warmstops hinting the mapping withMADV_WILLNEEDwhen the file tier readsO_DIRECT- the hint was feeding a page cache that the readsdeliberately bypass (728,160 hints / 3.7 GB in a 422 s strace window).
platform::advise_willneedasks for read-ahead in 4 MiB steps, not 128 KiB. Every step is one read-aheadwindow and the caller waits for it, so a 3.6 GiB projection load queued ~29k windows one after another. The
128 KiB walk is what turned a 1.4 GB/s drive into 60 MB/s (23.6 s -> 10.3 s on the pack's 1416 MiB alone).
platform::read_range_direct+populate_read: the dense weights, the token embedding, thehyper-connection Q8 matrices and the drafter's files are staged through 4 MiB O_DIRECT requests (one cached
descriptor per file - the projection loop used to open and close one 495 times) instead of being copied out of
the mapping one page fault at a time; and a tensor whose pages are already resident is copied straight from the
mapping (
resident_fraction, measured withmincore), so a warm start does no drive I/O for it at all.Validation
Same box, engine 0.1.50 built from this branch:
STRATA_UNBUFFERED_LOAD=1, cold: CUDA0 profile fill 329.0 s @82 MB/s ->19.6 s @1372 MB/s; CUDA1 stage fill 146.8 s -> 16.4 s @1544 MB/s; startup 503 s -> 62 s.
MADV_WILLNEEDhints during a fill: 728,160 (3.7 GB) -> 0.Limits
host memory buffer, firmware ZTA23001) the controller periodically drops its command service rate by ~25x for one
to seven minutes while reporting itself 100% busy. Measured with a per-second
/proc/diskstatsmonitor pluscontrast probes taken during an episode: read 59-61 MB/s, 480-490 completions/s (against ~12,500/s when
healthy),
io_ticks97-99%, average queue depth 78-241, and - the point - sequential and scattered reads areequally dead (1.9-10 MB/s sequential against 4-8 MB/s for 256 scattered 1 MiB reads), so it is the device, not
the access pattern. Controls: no host writes in the window (
Data Units Writtenflat), no other reader, no swap,APSTdisabled and the power state pinned to PS0 (the episode still happened), thermal management transitioncounts at 0 with the drive at 48-49 C against a 90 C warning threshold, and SMART/media errors unchanged. The
same start pattern immediately before and after runs at 1120-1300 MB/s mean and finishes in 138 s. In the same
start one phase can stall and the next run normally (one run: PLE 432 s @67 MB/s, then every later phase at full
speed). Also relevant:
max_hw_sectors_kbis 128 on this drive, so every 4 MiB read is 32 NVMe commands - ahealthy drive here answers ~12,500/s, an episode ~500/s. What remains is inside the drive; walking the fill in
file order (commit 1) removes the scatter that makes it worse, but it cannot remove a stall.
hold the model (26.8 GiB locked PLE + 8-30 GiB resident complement + 8 GiB conversation cache leave ~45 GiB for
108 GB of shards), so a start that drops the caches always re-reads everything. Keeping the caches (no
drop_caches) plus a small--resident-budget-gibis what makes the dense/embedding stage free; the expertfills stay unbuffered by design.
--resident-budget-gibtrades startup against decode, measured on the same box with one 7,878-token prompt(identical runs otherwise): 8 GiB -> 9 s of complement, decode 26.2 tok/s, 84.9 GB of experts read from the file
for that prompt; 24 GiB -> 27 s of complement (+18 s of startup), decode 56.6 tok/s, 65.3 GB read (23% less).
Prefill went the other way in the one clean pair (274 vs 104 tok/s), because at 8 GiB the file tier keeps a
15.1 GiB page cache that the prompt path streams from. So: 24 GiB for decode-heavy use, 8 GiB when restarts must
be as short as possible - the fills are at the drive's rate either way.
read_range_direct/populate_read(its copies go on faulting the mapping as before);the advising step applies to every platform.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.