Skip to content

[ML] Evict old models from the cache before loading new#140844

Merged
davidkyle merged 4 commits intoelastic:mainfrom
davidkyle:refresh-cache
Jan 30, 2026
Merged

[ML] Evict old models from the cache before loading new#140844
davidkyle merged 4 commits intoelastic:mainfrom
davidkyle:refresh-cache

Conversation

@davidkyle
Copy link
Member

An issue was reported where the ML model cache was throwing a circuit breaker exception loading a model because the cache was full. Inspecting the code the CB check is done before old models are evicted from the cache to free up any space. Note this is the cache for DFA and tree ensemble models used in learning to rank and not related to the PyTorch NLP models even though the same trained models APIs are used.

The fix here is to refresh the cache evicting any models older than the expiration time, this frees memory from the circuit breaker allowing new models to be loaded. Otherwise the only work-around is to delete a model that is cached which invalidates the cache. An alternative would be to catch the circuit breaking exception and only then evict models from the cache.

@davidkyle davidkyle added >bug :ml Machine learning auto-backport Automatically create backport pull requests when merged v9.4.0 branch:9.3 labels Jan 16, 2026
@elasticsearchmachine elasticsearchmachine added Team:ML Meta label for the ML team v9.3.1 labels Jan 16, 2026
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

@elasticsearchmachine
Copy link
Collaborator

Hi @davidkyle, I've created a changelog YAML for you.

@davidkyle davidkyle enabled auto-merge (squash) January 30, 2026 10:05
@davidkyle davidkyle merged commit ff88e3a into elastic:main Jan 30, 2026
35 checks passed
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
9.3
davidkyle added a commit to davidkyle/elasticsearch that referenced this pull request Jan 30, 2026
Evict old models from the cache before loading new
elasticsearchmachine pushed a commit that referenced this pull request Jan 30, 2026
…41577)

Evict old models from the cache before loading new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged >bug :ml Machine learning Team:ML Meta label for the ML team v9.3.1 v9.4.0

3 participants