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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(mm): estimate standalone-root submodel size instead of zero (#9405)
Alexander Eichhorn01a8315ab61c
diff --git a/invokeai/backend/model_manager/load/model_util.py b/invokeai/backend/model_manager/load/model_util.pyindex 0c6c8f7f4a..217918f6f7 100644--- a/invokeai/backend/model_manager/load/model_util.py+++ b/invokeai/backend/model_manager/load/model_util.py@@ -113,7 +113,21 @@ def calc_model_size_by_fs(model_path: Path, subfolder: Optional[str] = None, varreturn model_path.stat().st_sizeif subfolder is not None:- model_path = model_path / subfolder+ subfolder_path = model_path / subfolder+ if subfolder_path.exists():+ model_path = subfolder_path+ elif (model_path / "config.json").is_file() and not (model_path / "model_index.json").is_file():+ # Standalone single-component install: the loader reads the weights directly from the model+ # root (a flat `config.json` + weights folder), not from a `<subfolder>/` dir — e.g. a+ # mix-and-match Qwen3-VL / Z-Image Qwen3 / Wan T5 encoder, or a flat Wan VAE. Estimate from+ # the root so the cache reserves the right amount before the cold load; otherwise it+ # under-reserves to 0 and evicts nothing, spiking transient RAM (the transformer stays+ # resident while the encoder is constructed). A real diffusers pipeline that merely lacks+ # this subfolder (e.g. an undownloaded safety_checker) still has `model_index.json` at the+ # root, so it keeps returning 0 below.+ pass # keep model_path at the root+ else:+ return 0# this can happen when, for example, the safety checker is not downloaded.if not model_path.exists():diff --git a/tests/backend/model_manager/load/test_krea2_loader_boundaries.py b/tests/backend/model_manager/load/test_krea2_loader_boundaries.pyindex cb8dfe21d7..ba618ab03b 100644--- a/tests/backend/model_manager/load/test_krea2_loader_boundaries.py+++ b/tests/backend/model_manager/load/test_krea2_loader_boundaries.py@@ -146,3 +146,15 @@ def test_directory_encoder_loader_reaches_transformers_from_pretrained(monkeypatlow_cpu_mem_usage=True,local_files_only=True,)+++def test_directory_encoder_loader_estimates_standalone_root_weights(tmp_path) -> None:+ (tmp_path / "config.json").write_text("{}")+ weight_size = 4096+ (tmp_path / "model.safetensors").write_bytes(b"\0" * weight_size)+ config = Qwen3VLEncoder_Qwen3VLEncoder_Config.model_construct(path=str(tmp_path))+ loader = object.__new__(Qwen3VLEncoderLoader)++ estimated_size = loader.get_size_fs(config, tmp_path, SubModelType.TextEncoder)++ assert estimated_size == weight_size