Skip to content

Handle small moe caches better - #30848

Closed
eapache wants to merge 2 commits into
ggml-org:masterfrom
eapache:ehuus/moe-small-cache-fixes
Closed

eapache wants to merge 2 commits into
ggml-org:masterfrom
eapache:ehuus/moe-small-cache-fixes

Conversation

@eapache

@eapache eapache commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Overview

cont #30637

Warn for caches too small to hold a single token, which thrash and provide no benefit except in very unusual hardware configurations.

Fall back to plain LRU (vs SLRU) Ramp down the protected set below 1.8x a token's experts. Different models and workloads have different crossover points, but performance craters if a full token's experts don't fit in the unprotected set. 1.8x is a conservative upper bound based on testing the cross-over point of a few different models.

Additional information

Mostly fixes the regression reported in #30637 for small caches. There is now a small band of caches and models (e.g. Gemma4-26B-A4B with a cache about 1.5x a single token) where we choose not to use SLRU even when it would provide a few % of benefit. But trying to choose the threshold dynamically would be impossible to predict.

edit: I had a brainwave and this makes more sense / works better - instead of hard cutover, gradually increase the protected percentage (from 0% at 1x a token to 50% at 1.8x a token). Everybody wins. In the second commit.

Requirements

@eapache
eapache force-pushed the ehuus/moe-small-cache-fixes branch from a11fac5 to 449d77b Compare October 21, 2026 00:36
@eapache
eapache marked this pull request as ready for review October 21, 2026 00:39
@eapache
eapache requested a review from ggerganov as a code owner October 21, 2026 00:39
@eapache

eapache commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@am17an

@eapache

eapache commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Per #30637 (comment) this now fixes the regression and provides a small improvement over the previous baseline for small caches.

Warn for caches too small to hold a single token, which thrash and
provide no benefit except in vary unusual hardware configurations.

Fall back to plain LRU (vs SLRU) below about 1.8x a token. Different
models and workloads have different crossover points, but plain LRU is
more reliable for small caches, where SLRU performance can crater. 1.8x
is a very rough upper bound.
@eapache
eapache force-pushed the ehuus/moe-small-cache-fixes branch from da05b46 to 092e05b Compare October 25, 2026 21:10
@eapache

eapache commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Putting this in draft temporarily so I can open #31162 which is more important, given the limit on open PRs.

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