Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(models): resolve relocated submodels from loaded root

wunianze666-netizen51cbddaa8d0a
diff --git a/invokeai/backend/model_manager/load/load_default.py b/invokeai/backend/model_manager/load/load_default.py
index 506cc5f1b1..f590d19031 100644
--- a/invokeai/backend/model_manager/load/load_default.py
+++ b/invokeai/backend/model_manager/load/load_default.py
@@ -73,7 +73,9 @@ def resolve_submodel_path(config: AnyModelConfig, submodel_type: SubModelType, f
Remote installs discover components inside a ``tmpinstall_*`` directory before moving the
pipeline into its permanent model directory. Existing records may therefore carry a discovered
path whose root no longer exists. Discovery only records direct children of the pipeline, so in
- that case rebase the recorded component name onto the current model root.
+ that case rebase the recorded component name onto the current model root. Use the resolved
+ fallback's parent for that root because managed model records persist ``config.path`` relative
+ to the models directory.
`fallback` is used when the config carries no such entry — configs persisted before submodel
discovery existed, and the layouts where the component folder *is* the model path.
@@ -83,7 +85,7 @@ def resolve_submodel_path(config: AnyModelConfig, submodel_type: SubModelType, f
return fallback
discovered_path = Path(discovered.path_or_prefix)
- relocated_path = Path(config.path) / discovered_path.name
+ relocated_path = fallback.parent / discovered_path.name
if not discovered_path.exists() and relocated_path.exists():
return relocated_path
return discovered_path
diff --git a/tests/backend/model_manager/load/test_load_default_helpers.py b/tests/backend/model_manager/load/test_load_default_helpers.py
index 4e9d26d168..64da7900a3 100644
--- a/tests/backend/model_manager/load/test_load_default_helpers.py
+++ b/tests/backend/model_manager/load/test_load_default_helpers.py
@@ -70,7 +70,9 @@ class TestResolveSubmodelPath:
installed_root.parent.mkdir()
staging_root.rename(installed_root)
config = SimpleNamespace(
- path=installed_root.as_posix(),
+ # Managed model records store paths relative to the models directory. The loader's
+ # fallback carries the resolved absolute model root.
+ path=installed_root.name,
submodels={SubModelType.TextEncoder: SimpleNamespace(path_or_prefix=discovered_component.as_posix())},
)