Add endpoint for emptying the model cache #7602
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a backend endpoint that can be used to empty the model cache (to free RAM / VRAM). 'Locked' models that are actively being used will not be dropped.
Locking was added to
ModelCache
to make it thread-safe. But, I suspect that it might be possible to trigger #7513 with an ill-timed request to empty the cache (in the middle of graph execution). Even if this does happen, the current graph execution would fail, but subsequent graph executions should recover smoothly.QA Instructions
I tested that the new endpoint successfully empties the model cache with
curl -X POST 127.0.0.1:9090/api/v2/models/empty_model_cache
.I tried to break things by hitting the endpoint throughout graph execution. Nothing broke, which is a good sign. Of course, this is far from testing the thread interactions thoroughly.
Merge Plan
No special instructions.
Checklist
What's New
copy (if doing a release after this PR)