Skip to content

telemetry: split expert hit counter into pin vs ecache (LRU) (#336)#367

Closed
KingIcyCreamProjects wants to merge 1 commit into
JustVugg:devfrom
KingIcyCreamProjects:telemetry/pin-vs-ecache-hits
Closed

telemetry: split expert hit counter into pin vs ecache (LRU) (#336)#367
KingIcyCreamProjects wants to merge 1 commit into
JustVugg:devfrom
KingIcyCreamProjects:telemetry/pin-vs-ecache-hits

Conversation

@KingIcyCreamProjects

Copy link
Copy Markdown
Contributor

What

Splits the single m->hits expert-cache counter into hit_pin (HOT-STORE / pinned experts, never evicted) and hit_ecache (per-layer LRU). By construction hit_pin + hit_ecache == hits at every increment β€” the two m->hits++ sites in moe() each gain a 1:1 tier-specific bump, so the total is preserved with no double-count. Resolves #336.

Why

Today hits lumps together two very different events: a pin-tier hit (free, the expert is wired in RAM) and an ecache/LRU hit (subject to the eviction policy). That makes eviction-policy changes unmeasurable β€” you can't tell whether a policy "won" because it improved LRU reuse or because the pin tier simply absorbed everything.

This directly unblocks the evaluation of #223 (cloxcache/SLRU): the maintainer's gating question there β€” "the lowest cap at which cloxcache starts to win" β€” is unanswerable while hits conflates the tiers. With the split, a cap sweep shows whether a flat A/B is "pin tier absorbed all the traffic" vs. a genuine LRU-policy floor.

Surface

  • glm.c only, +19/βˆ’14. New fields on Model; snapshot/reset updated in lockstep at both counter-reset sites; windowed deltas added.
  • Split is surfaced in the three interactive/offline report paths: emit_stream (lru%), [PROF] (X pin + Y lru / Z load), and REPLAY (pin X% + lru Y%).
  • Zero cost β€” two increments on paths that already increment hits. Cannot change model output (telemetry only).

Notes for the reviewer

  • The serve-mux [PROF] protocol line is intentionally left untouched β€” openai_server.py parses it positionally, so the pin/ecache breakdown is surfaced only in the human-facing report paths above.
  • Two-line textual overlap with Nearly double the hit-rateΒ #223 on the moe() lookup branches (both add to the pin/ecache lookup lines). No semantic conflict β€” this only reads/writes new counters, Nearly double the hit-rateΒ #223 only changes victim selection β€” so whichever lands second is a trivial keep-both merge.

m->hits counted a pin-tier hit and an LRU-ecache hit identically, which
makes every cache-policy question unanswerable from logs: the pin tier is
checked first and (with a warm usage profile) absorbs most hot experts,
so the ecache may serve anywhere from ~0% to a large share of hits β€”
prefill-pollution effects, eviction-policy A/Bs (JustVugg#223), and PILOT_REAL
eviction pressure all need that split before any measurement means much.

Two new counters (hit_pin, hit_ecache) bumped at the two Phase C lookup
branches, surfaced in:
- the periodic serve stats line: hit N% (lru M%)  β€” pin share = N-M
- run_replay summary: expert hit N% (pin X% + lru Y%)
- prof_report: hit N% (X pin + Y lru / Z load)
The serve-mux PROF protocol line is untouched (openai_server.py parses it
positionally). Both reset sites clear the new counters; model_init's
memset zeroes them at start. Zero cost: two increments on paths that
already increment m->hits.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@KingIcyCreamProjects

Copy link
Copy Markdown
Contributor Author

Superseded by @JustVugg's direct implementation on dev (679c074) β€” same design (hit_pin/hit_ecache at both lookup branches, all three summary surfaces). Verified working on the 9950X3D in #336. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant