You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add option for LRU eviction on memory pressure / load #9375
Is your feature request related to a problem? Please describe.
Usecase is that i have limited memory but want to test multiple models while still need to maintain certain smaller models always in memory.
Describe the solution you'd like
New Setting: LRU eviction on model load:
LRU eviction that fires whenever a new model /backend is about to be loaded, Triggers if the to be loaded model would not fit in memory (same calculation as on the model gallery). eviction target(s) are biggest models first, keep smaller ones in memory.
Note for anyone hitting this: the feature is actually already implemented as the memory_reclaimer (added in #7583, Dec-16-2025). You can enable it via LOCALAI_MEMORY_RECLAIMER=true and LOCALAI_MEMORY_RECLAIMER_THRESHOLD=0.95 (or via the runtime-settings JSON / Settings UI). When GPU usage exceeds the threshold, the watchdog evicts LRU models.
However, there's a sharp corner that makes it unusable on llama-cpp setups today. Surfaced cleanly on a single-GPU AMD Strix Halo (gfx1151, 96 GB unified VRAM, ROCm 7.x, current master @ f53577… llama-cpp pin) with 4 preloaded models pushing usage to ~92 %:
The reclaimer logs eviction complete but the llama-cpp gRPC backend's Free() returns Unimplemented, so VRAM is never actually released. Every 5 s tick the watchdog sees usage still >90 %, picks the next LRU victim, repeats. After all four preloaded models have been "evicted in name only", the next chat-completion that needs a freshly-loaded model crashes the backend on load:
WARN Backend process exited unexpectedly id="qwen3.6-35b-a3b-apex" exitCode="-1"
A few things that would make the feature actually safe to enable:
Implement Free() in backend/cpp/llama-cpp/grpc-server.cpp so eviction physically releases the model + KV cache. This is the real fix.
Until (1): in the reclaimer, when Free() returns Unimplemented, don't mark eviction as complete — fall back to the next-largest victim and add an exponential backoff before re-firing, otherwise the watchdog spins for nothing while load operations queue up behind it.
The new feat: Log backend exit code (feat: Log backend exit code #9581, just merged) will help here — combined with surfacing the Unimplemented warning to the UI/logs as an error rather than warn would let users immediately see the misconfiguration.
Workaround for anyone hitting this on llama-cpp today: set memory_reclaimer_enabled: false in runtime_settings.json, restart, pin the models you need via LOCALAI_LOAD_TO_MEMORY. Tracked separately in our memory as a regression to watch on every upstream sync.
Activity
[-]Add option for LRU eviction on memory pressure[/-][+]Add option for LRU eviction on memory pressure / load[/+]feat(watchdog): add size-aware LRU eviction mode
walcz-de commentedon Apr 28, 2026
Note for anyone hitting this: the feature is actually already implemented as the
memory_reclaimer(added in #7583, Dec-16-2025). You can enable it viaLOCALAI_MEMORY_RECLAIMER=trueandLOCALAI_MEMORY_RECLAIMER_THRESHOLD=0.95(or via the runtime-settings JSON / Settings UI). When GPU usage exceeds the threshold, the watchdog evicts LRU models.However, there's a sharp corner that makes it unusable on llama-cpp setups today. Surfaced cleanly on a single-GPU AMD Strix Halo (gfx1151, 96 GB unified VRAM, ROCm 7.x, current
master @ f53577…llama-cpp pin) with 4 preloaded models pushing usage to ~92 %:The reclaimer logs
eviction completebut the llama-cpp gRPC backend'sFree()returnsUnimplemented, so VRAM is never actually released. Every 5 s tick the watchdog sees usage still >90 %, picks the next LRU victim, repeats. After all four preloaded models have been "evicted in name only", the next chat-completion that needs a freshly-loaded model crashes the backend on load:A few things that would make the feature actually safe to enable:
Free()inbackend/cpp/llama-cpp/grpc-server.cppso eviction physically releases the model + KV cache. This is the real fix.Free()returnsUnimplemented, don't mark eviction as complete — fall back to the next-largest victim and add an exponential backoff before re-firing, otherwise the watchdog spins for nothing while load operations queue up behind it.feat: Log backend exit code(feat: Log backend exit code #9581, just merged) will help here — combined with surfacing theUnimplementedwarning to the UI/logs as an error rather than warn would let users immediately see the misconfiguration.Workaround for anyone hitting this on llama-cpp today: set
memory_reclaimer_enabled: falseinruntime_settings.json, restart, pin the models you need viaLOCALAI_LOAD_TO_MEMORY. Tracked separately in our memory as a regression to watch on every upstream sync.feat(watchdog): add size-aware LRU eviction mode
feat(watchdog): add size-aware LRU eviction mode (mudler#9527)