mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1923] Engine-side expert-cache eviction policy (LRU / LFU-decay), opt-in; measured headroom on gfx906 #761
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#761
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?
Originally created by @phoenixclyde on GitHub (Oct 11, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1923
Context
ExpertCache::admitnever evicts.include/strata/core/expert_cache.hpp:143says: "it never evicts,because eviction policy is a measured question (R4.1's LFU-decay vs LRU sweep)".
tools/bench_eviction.pyis the harness for that measurement, and the policies it defines (fill-only, lru, lfu-decay, oracle) are
exactly the candidates.
Measurement
On a gfx906 / Radeon Instinct MI50 32GB, UD-IQ4_XS pack, engine 0.1.42, we replayed a
--dump-routingtrace (3,838 positions x 48 layers x k=10 = 1,842,240 (layer,expert) lookups) through
tools/bench_eviction.py, prefilled with the productionexpert-profile.bin:slots fill-only (today) lru lfu-decay oracle
9,761 (production) 0.7086 0.9751 0.9767 0.9890
64 0.0105 0.3931 0.0481 0.4221
At the production slot count the current policy leaves about 24-28 points of hit rate on the table, and
two policies that already exist in your own tool recover about 95% of the oracle bound. At small slot
counts the gap is far larger (slots=64: 0.0105 vs 0.4221), i.e. today's behaviour is mostly a function of
"are the slots big enough", not of any policy.
Caveat: these are hit-rate figures from offline replay, not wall-clock; the speed benefit depends on the
miss cost (PCIe / CPU pool share), which we have not measured live yet. The trace is one text-continuation
workload, not the full production distribution. Oracle reads the future and is not implementable; it is
only the upper bound.
Note on answers: an eviction policy changes WHICH experts are computed on the GPU (vs read from
RAM/files and computed on the CPU). The engine already documents that the GPU and the CPU round
differently and that a reply "can differ slightly" (bench/results/2026-09-27-cache-parity). So this
is NOT answer-neutral by construction; adoption would need a quality gate, the same way the other
answers-can-differ switches are handled.
Ask
Would an opt-in eviction policy for the VRAM expert cache be in scope? Concretely, a
STRATA_EXPERT_EVICT=lru|lfu-decayenvironment switch (default off = today's fill-only), with the policyimplemented to match
tools/bench_eviction.pyexactly so the offline prediction and the live engine staycomparable. We are happy to prepare the patch if that helps.
@phoenixclyde commented on GitHub (Oct 11, 2026):
A clarification on our own numbers (they are trace-scoped, not workload-scoped)
In the measurement above the 0.7086 fill-only figure comes from replaying a
--dump-routingtrace(3,838 positions, one text-continuation prompt) through
tools/bench_eviction.py. That is NOT thehit rate our production workload sees. On the same card, same slots (9,761), our live engine reports
decode expert cache hit rateof 95.4-98.0% on long runs (2.8-3.1M lookups) and 88-90% on short ones.So the "+24-28 points left on the table" applies to a trace-like, cold-cache workload. We do not know
yet how much of it survives on a workload that a learned expert profile already covers at ~96%. The
part that plausibly survives is whatever the engine's adaptive swaps bring back today (its cache has no
eviction to fall back on), and we have not measured that split.
We therefore do not claim a production gain here; the proposal stands as "an opt-in policy is missing
and the offline headroom is real for trace-like traffic". If you want a number for a specific
workload shape, we can measure the fill-only vs lru delta on that shape and post it.
@phoenixclyde commented on GitHub (Oct 11, 2026):
Correction to our own report above.
We measured
fill-only 0.7086withtools/bench_eviction.pyand read it as "the engine'scurrent admission, so this is today's hit rate". That was the wrong baseline.
ExpertCache::admitnever evicts, but the same startup path also builds the resident-RAM mode's adaptive tier, which
does move residents in and out. On our box the production log says:
Your own
tools/replay_cache_policy.pyis the model of that tier ("The simulated adaptive tier isgenerate.cpp's adapt()"). Replaying the SAME
--dump-routingtrace, from the SAME shippedexpert-profile.bin, at the same 9,761 slots:so the tier already recovers about 99% of what that trace allows, and 0.9564 sits right on the
95.4-98.0% decode hit rate our production engine reports. The five knobs match the engine's
defaults one for one:
adapt_every = 4(generate.cpp:577),adapt_decay = 0.7f(:578),adapt_swaps = 96(:607),adapt_min_gain = 1.5f(:581, compared at:8174), and thecandidate gate
u[e] >= 2.0f(:8165).So we withdraw the motivation "add an eviction policy to recover the 24-28 points". What is left
is narrower, and we are not asking for it here:
(a) machines that do NOT run the resident-RAM mode (there
adapt()does not run at all) maystill sit at the fill-only rate - that is a question about the tier's reach, not about
adding a second eviction policy;
(b) the
adapt_*knobs themselves: making them busier did not help on our trace(
--every 1-> 0.9556, a looser gate -> 0.9590, both within a point of 0.9564).Two small observations while we were in there:
generate.cpp:5008prints "expert cache %lld slots, %.2f GiB of VRAM; policy is\n" - thepolicy text is missing an argument, so the log line just ends with "policy is".
bench_eviction.pydescribesfill-onlyas "the engine's current admission: ... the baselinea policy has to beat". On a
--resident-*engine that reads as "the engine's current hitrate", which is what led us here. A word about
adapt()in that docstring would have savedus the round.
Reproduce (no GPU needed):
Trace: 16,211,712 B, md5 6b5f1e44788fc13fa598d4261d5cbcde (0.1.42, 48 layers x 512 experts,
3,838 positions x k=10). Profile: 196,632 B, md5 ff1bc6544d3f2f0013e3e376632d33a8 - byte-identical
to the image's
/src/data/expert-profile.bin.@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for taking the time to report this.
We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.