Skip to content

Commit deb1984

Browse files
fix(mm): disable new model probe API
There is a subtle change in behaviour with the new model probe API. Previously, checks for model types was done in a specific order. For example, we did all main model checks before LoRA checks. With the new API, the order of checks has changed. Check ordering is as follows: - New API checks are run first, then legacy API checks. - New API checks categorized by their speed. When we run new API checks, we sort them from fastest to slowest, and run them in that order. This is a performance optimization. Currently, LoRA and LLaVA models are the only model types with the new API. Checks for them are thus run first. LoRA checks involve checking the state dict for presence of keys with specific prefixes. We expect these keys to only exist in LoRAs. It turns out that main models may have some of these keys. For example, this model has keys that match the LoRA prefix `lora_te_`: https://civitai.com/models/134442/helloyoung25d Under the old probe, we'd do the main model checks first and correctly identify this as a main model. But with the new setup, we do the LoRA check first, and those pass. So we import this model as a LoRA. Thankfully, the old probe still exists. For now, the new probe is fully disabled. It was only called in one spot. I've also added the example affected model as a test case for the model probe. Right now, this causes the test to fail, and I've marked the test as xfail. CI will pass. Once we enable the new API again, the xfail will pass, and CI will fail, and we'll be reminded to update the test.
1 parent 814406d commit deb1984

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

invokeai/app/services/model_install/model_install_default.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
AnyModelConfig,
3939
CheckpointConfigBase,
4040
InvalidModelConfigException,
41-
ModelConfigBase,
4241
)
4342
from invokeai.backend.model_manager.legacy_probe import ModelProbe
4443
from invokeai.backend.model_manager.metadata import (
@@ -647,10 +646,14 @@ def _probe(self, model_path: Path, config: Optional[ModelRecordChanges] = None):
647646
hash_algo = self._app_config.hashing_algorithm
648647
fields = config.model_dump()
649648

650-
try:
651-
return ModelConfigBase.classify(model_path=model_path, hash_algo=hash_algo, **fields)
652-
except InvalidModelConfigException:
653-
return ModelProbe.probe(model_path=model_path, fields=fields, hash_algo=hash_algo) # type: ignore
649+
return ModelProbe.probe(model_path=model_path, fields=fields, hash_algo=hash_algo)
650+
651+
# New model probe API is disabled pending resolution of issue caused by a change of the ordering of checks.
652+
# See commit message for details.
653+
# try:
654+
# return ModelConfigBase.classify(model_path=model_path, hash_algo=hash_algo, **fields)
655+
# except InvalidModelConfigException:
656+
# return ModelProbe.probe(model_path=model_path, fields=fields, hash_algo=hash_algo) # type: ignore
654657

655658
def _register(
656659
self, model_path: Path, config: Optional[ModelRecordChanges] = None, info: Optional[AnyModelConfig] = None

tests/test_model_probe.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def test_minimal_working_example(datadir: Path):
137137
assert config.fun_quote == "Minimal working example of a ModelConfigBase subclass"
138138

139139

140+
@pytest.mark.xfail(reason="Known issue with 'helloyoung25d_V15j.safetensors'.", strict=True)
140141
def test_regression_against_model_probe(datadir: Path, override_model_loading):
141142
"""Verifies results from ModelConfigBase.classify are consistent with those from ModelProbe.probe.
142143
The test paths are gathered from the 'test_model_probe' directory.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:0f0547f89bdcbb0dfd8b6ff1d8de63336df20107e9a27afc0934e8d3cce584d7
3+
size 308563

0 commit comments

Comments
 (0)