Repository navigation
refactor(model-manager): apply model record changes in the model manager service - #9941
Open
joshistoast wants to merge 4 commits into
Open
joshistoast wants to merge 4 commits into
joshistoast wants to merge 4 commits into
Conversation
…pdating records Rewriting a model's path between its models-relative and absolute forms no longer evicts the cached model or rejects in-flight loads.
…ger service The load service applies a record change as one operation: the edit bracket, the store write, one comparison and the cache drop under the load lock. The model manager owns update and re-identification; the router only claims the key and maps errors to HTTP.
The record store rejects an update whose key differs from the record's, so service callers cannot write a record that reports a key nothing can look it up by.
JPPhoto
self-requested a review
October 19, 2026 10:44
JPPhoto
requested changes
Oct 19, 2026
JPPhoto
left a comment
Collaborator
There was a problem hiding this comment.
Pre-existing issues that you can fix:
invokeai/app/services/model_load/model_load_default.py:221-225: If a write commits then raises, cache eviction is skipped; later loads can reuse the old model. The base router had the same behavior, and the new test covers only a cold load. Suggested issue: test this failure with a warm cache and evict if the stored record changed.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Editing a model record has to bracket the write so that loads which overlap it are rechecked. It also has to compare the old and new records, and drop cached instances under the model load lock when the change affects loading.
The load service owned that fence, but the model manager router carried out the steps itself. Its comparison also omitted
models_path. So rewriting a model's path between its models-relative and absolute forms evicted the cached model and rejected in-flight loads, while the load service treated it as no change.Commits:
apply_record_change): the edit bracket, the store write, one comparison, and the drop from each distinct cache under the load lock.update_model_recordandreidentify_model, including the fields kept on re-identification.distinct_cachesrule replaces the per-call-site handling of device-aliased caches.QA Instructions
uv run --no-sync pytest tests/app/routers/test_model_manager.py tests/app/services/model_manager tests/app/services/model_load tests/app/services/model_records tests/app/services/image_indexpasses.Full suite (
-n 4): 14980 passed. The failures were the 112 model-identification and model-path tests, which need git-lfs fixtures that were not installed on the test machine, and fail the same way onmain.New:
tests/app/services/model_manager/test_model_record_changes.pyuses a real SQLite store, two realModelCaches and real identification of small synthetic files, and covers:Threaded fence tests drive the real
apply_record_changewith a load queued on the lock, including a write that commits and then raises.Mutation checks: each of these makes at least one test fail:
models_path;The OpenAPI schema generated from this branch is identical to the committed
openapi.json.Review
Resolved:
No remaining material findings. The router's per-key claims staying in the router is deliberate; moving them is a separate change.
Compatibility / Rollout
ModelLoadServiceBase.record_editis removed from the base interface. No caller remains.ModelRecordServiceSQL.update_modelnow raisesValueErrorwhen given a different key. No in-repo caller does this.Checklist
What's Newcopy (if doing a release after this PR)Need help on this PR? Tag
@codesmith-botwith what you need.