mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1089] [CLOSED] tools: bench_eviction — the R4.1 sweep: compulsory-miss vs LRU vs LFU-decay vs oracle on real routing traces #3014
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#3014
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/1089
Author: @ZhongUncle
Created: 10/6/2026
Status: ❌ Closed
Base:
main← Head:feat/expert-cache-eviction-bench📝 Commits (1)
7cd5eb9tools: bench_eviction replays --dump-routing traces against candidate eviction policies📊 Changes
2 files changed (+570 additions, -0 deletions)
View changed files
➕
tools/bench_eviction.py(+405 -0)➕
tools/test_bench_eviction.py(+165 -0)📄 Description
Repost of #991, which GitHub closed automatically when the repository's history was cleaned up — not a rejection, per the maintainer's note there. Same content, rebuilt on the new
main.ExpertCache::admit"never evicts, because eviction policy is a measured question (R4.1's LFU-decay vs LRU sweep) and a placeholder policy would set the hit rate that everything downstream is then sized against" (expert_cache.hpp:133-135, repeated atexpert_source.hpp:259-261). This PR is that measurement. It adds the harness and reports the sweep on real routing traces — it deliberately does not implement an eviction policy; what Phase 3 puts in place of the current object (expert_source.hpp:411) stays the maintainer's call, now with numbers.TL;DR
What it adds
Two new files, no engine changes:
tools/bench_eviction.py— replays--dump-routingtraces through simulated slot pools. A policy's hit rate depends only on the order(layer, expert)pairs were routed, which the trace records, so the replay needs no GPU. Policies: compulsory-miss (the engine's current behaviour;fill-onlyin the CLI), lru, lfu-decay (tunable window), oracle (Belady's MIN, the upper bound). Global scope or R4.2g per-layer admission matchingExpertCache::layer_slot_range; any slot count; optional--expert-profileprefill; per-window rates so a topic shift shows up as a dip.tools/test_bench_eviction.py— 14 cases, no GPU: each policy's victim choice, the per-layer quota arithmetic, the windows split, profile prefill order.Measured results
Traces collected on:
--spec 4 --spec-min-p 0.5All traces are decode-phase (
--dump-routingwrites no prefill records; with--specon, a trace position is a verify-window candidate, rejected drafts included — the true expert load).Workloads:
Session hit rate by slots (cold start), in % (100 = every lookup resident):
(10377 ≈ what
--expert-cache autopicks on the 20 GB card.)LFU-decay window sweep (session, cold):
R4.2g per-layer scope (slots split evenly across 48 layers, session, cold):
The two reference points quoted in
expert_cache.hpp:153-154are consistent with these traces:Memory/cache_allocation.pyFindings
--expert-cache autopicks on this card.Design checks
All pass:
--windows 4per-window rates; the routing shift is real)Validation against the engine's own counters
tools/bench_eviction.py("the sim" below — it is this PR's tool, the engine is untouched) was reconciled against--statson matched runs. The engine counts per-token entries — the sim's basis — but its reported lookups (hits + refused) exclude the misses it serves over PCIeexpert_source.cpp:2030-2209): distinct misses ranked by first occurrence per window-layer, the lastm = (nmiss × 79) >> 8fetched via PCIe asoffload_entries; 79/256 = this host's measured pcie_frac 0.31All sim policies share one accounting basis, so the policy comparisons are unaffected by these differences.
Limits
--dump-routingwrites nothing during prefill)ExpertCachewith one policy: no adaptive tier, no PCIe offload, no pack-size variation. Measured on the two static arms, the engine's h reads 2.9 and 4.8 hit-rate points higher than the raw sim rate (0.1333 vs 0.1044 @ 2000 slots; 0.2361 vs 0.1878 @ 4105); most of that is the PCIe-offload denominator, and under 1 point remains once that rule is appliedReproduce
Per-task, conversation, and single-task sweep tables
japan-travel single-task LFU-decay window sweep @ 4105 slots, cold (supports finding 3; lru for reference):
Per-layer LFU-decay window sweep, session, cold (supports finding 6; lru for reference):
Per-task @ 4105 slots, cold:
conv1 (10-turn, single topic) / conv2 (12-turn, travel→code→math), cold:
Session @ 4105 slots with
--expert-profileprefill (supports finding 5; cold-start numbers in the headline table): compulsory-miss 30.18 (vs 24.32 cold, +5.9), lru 79.87 (vs 79.86, +0.0), lfu-decay (w=65536) 67.39, oracle 90.64.Work with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.