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
chore(deps): bump diffusers to 0.41.0 (#9774)
Alexander Eichhorn9d30e6a14886
diff --git a/invokeai/backend/hidiffusion/hidiffusion.py b/invokeai/backend/hidiffusion/hidiffusion.pyindex 3343785321..bd611be676 100644--- a/invokeai/backend/hidiffusion/hidiffusion.py+++ b/invokeai/backend/hidiffusion/hidiffusion.py@@ -9,8 +9,8 @@ import torch.nn.functional as Ffrom diffusers.image_processor import PipelineImageInputfrom diffusers.models import ControlNetModelfrom diffusers.models.attention import _chunked_feed_forward+from diffusers.models.controlnets.multicontrolnet import MultiControlNetModelfrom diffusers.pipelines import auto_pipeline-from diffusers.pipelines.controlnet.multicontrolnet import MultiControlNetModelfrom diffusers.pipelines.stable_diffusion_xl.pipeline_output import StableDiffusionXLPipelineOutputfrom diffusers.utils import USE_PEFT_BACKEND, deprecate, scale_lora_layers, unscale_lora_layersfrom diffusers.utils.torch_utils import apply_freeu, is_compiled_module, is_torch_versiondiff --git a/pyproject.toml b/pyproject.tomlindex 94b7c46c4b..5dd3e63151 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -36,7 +36,7 @@ dependencies = ["accelerate","bitsandbytes; sys_platform!='darwin'","compel>=2.4.0,<3",- "diffusers[torch]==0.40.0",+ "diffusers[torch]==0.41.0","gguf","mediapipe==0.10.14", # needed for "mediapipeface" controlnet model"mistral-common>=1.5.4,<2", # canonical Tekken tokenizer for FLUX.2 [dev] Mistral encoder; thediff --git a/tests/backend/model_manager/load/test_diffusers_040_compatibility.py b/tests/backend/model_manager/load/test_diffusers_041_compatibility.pysimilarity index 67%rename from tests/backend/model_manager/load/test_diffusers_040_compatibility.pyrename to tests/backend/model_manager/load/test_diffusers_041_compatibility.pyindex 2b254280d9..357d861722 100644--- a/tests/backend/model_manager/load/test_diffusers_040_compatibility.py+++ b/tests/backend/model_manager/load/test_diffusers_041_compatibility.py@@ -1,4 +1,7 @@+import ast+import importlibfrom inspect import signature+from pathlib import Pathfrom types import SimpleNamespaceimport accelerate@@ -7,11 +10,81 @@ import pytestimport torchfrom packaging.version import Version+import invokeaifrom invokeai.backend.model_manager.load.model_loaders.generic_diffusers import GenericDiffusersLoader+_DiffusersImport = tuple[str, str, str] # module, name, location+++def _is_diffusers_import(node: ast.AST) -> bool:+ return isinstance(node, ast.ImportFrom) and node.level == 0 and (node.module or "").split(".")[0] == "diffusers"+++def _is_version_gate(node: ast.If) -> bool:+ return any("version" in getattr(n, "id", getattr(n, "attr", "")) for n in ast.walk(node.test))+++def _imports_in(statements: list[ast.stmt], path: Path) -> list[_DiffusersImport]:+ return [+ (node.module, alias.name, f"{path}:{node.lineno}")+ for statement in statements+ for node in ast.walk(statement)+ if _is_diffusers_import(node)+ for alias in node.names+ ]+++def _collect_diffusers_imports(+ node: ast.AST, path: Path, plain: list[_DiffusersImport], gated: list[list[list[_DiffusersImport]]]+) -> None:+ """Collects `from diffusers... import X`, including function-local ones.++ A branch on a diffusers version only has to resolve on one side, so its two sides are kept as alternatives.+ """+ for child in ast.iter_child_nodes(node):+ if isinstance(child, ast.If) and _is_version_gate(child):+ gated.append([_imports_in(child.body, path), _imports_in(child.orelse, path)])+ continue+ if _is_diffusers_import(child):+ plain.extend(_imports_in([child], path))+ _collect_diffusers_imports(child, path, plain, gated)+++def _unresolved(imports: list[_DiffusersImport]) -> list[str]:+ failures = []+ for module_name, name, location in imports:+ try:+ module = importlib.import_module(module_name)+ if name != "*" and not hasattr(module, name):+ importlib.import_module(f"{module_name}.{name}")+ except ImportError as e:+ failures.append(f"{location}: from {module_name} import {name} ({e})")+ return failures+++def test_every_diffusers_import_in_invokeai_resolves() -> None:+ # Most loaders import diffusers inside functions, so a module that moves upstream only fails when a user+ # loads that model. Resolving every import here catches it at the next bump instead.+ package_dir = Path(invokeai.__file__).parent+ plain: list[_DiffusersImport] = []+ gated: list[list[list[_DiffusersImport]]] = []+ for path in sorted(package_dir.rglob("*.py")):+ if "node_modules" in path.parts:+ continue+ tree = ast.parse(path.read_text(encoding="utf-8"))+ _collect_diffusers_imports(tree, path.relative_to(package_dir), plain, gated)+ assert plain++ unresolved = _unresolved(plain)+ for branches in gated:+ failures = [_unresolved(branch) for branch in branches]+ if all(failures):+ unresolved.extend(failure for branch_failures in failures for failure in branch_failures)+ assert not unresolved, "\n".join(unresolved)+def test_pinned_diffusers_exposes_existing_and_krea_model_contracts() -> None:- assert Version(diffusers.__version__) == Version("0.40.0")+ assert Version(diffusers.__version__) == Version("0.41.0")expected_symbols = ("AutoencoderKLFlux2",diff --git a/uv.lock b/uv.lockindex 9016d30fa1..11102acdf0 100644--- a/uv.lock+++ b/uv.lock@@ -574,11 +574,10 @@ wheels = [[[package]]name = "diffusers"-version = "0.40.0"+version = "0.41.0"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "filelock" },- { name = "httpx" },{ name = "huggingface-hub" },{ name = "importlib-metadata" },{ name = "numpy" },@@ -587,9 +586,9 @@ dependencies = [{ name = "requests" },{ name = "safetensors" },]-sdist = { url = "https://files.pythonhosted.org/packages/59/32/b9c6a198812e2a7d2c2828a850dba384306f9af285eac23e35e89d5b008a/diffusers-0.40.0.tar.gz", hash = "sha256:49f112ce52ff6d332ab68afec01f79a53e6489b42cb69104444c98b4a2f64af8", size = 4886420, upload-time = "2026-08-20T14:30:40.923Z" }+sdist = { url = "https://files.pythonhosted.org/packages/a8/bc/34a91d366fe8e546637d702403e4d8cd5dbdf705a15fb3725d34a7ab3416/diffusers-0.41.0.tar.gz", hash = "sha256:69dcced7230b6bc0b70b5c6cfdff1aa62da487ab52ae74b642e46b1b9bfacc47", size = 5026281, upload-time = "2026-10-06T06:24:14.884Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/db/df/ffb593ebed2a068d2d6be44261283f39a6b809c0fcdfdcafbd448cbeec77/diffusers-0.40.0-py3-none-any.whl", hash = "sha256:5b5da7c3ddb62152fa4afc577f02e050af688c797375c34fb2d01006da3f3541", size = 5911654, upload-time = "2026-08-20T14:30:38.422Z" },+ { url = "https://files.pythonhosted.org/packages/fe/c4/5bf8afd1ff3a8d99da7a18b1067ae0b4e2a037c38f3851890a989c511fd3/diffusers-0.41.0-py3-none-any.whl", hash = "sha256:ea8918b7dfd92ce793b6db689a551b8cd25d52c6c0fcd3ade0706a5fd2a25990", size = 6063887, upload-time = "2026-10-06T06:24:12.455Z" },][package.optional-dependencies]@@ -868,7 +867,7 @@ wheels = [[[package]]name = "huggingface-hub"-version = "1.30.0"+version = "1.33.0"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "click" },@@ -881,9 +880,9 @@ dependencies = [{ name = "tqdm" },{ name = "typing-extensions" },]-sdist = { url = "https://files.pythonhosted.org/packages/35/97/2eb4abaa5b969ed385066a0496a3823b3ff467fc1082e2202955f1867d60/huggingface_hub-1.30.0.tar.gz", hash = "sha256:e6a6120bc8c8e2723d03648434ee247088cceb55ba7067e7d34d692cad5fdb57", size = 964291, upload-time = "2026-09-03T10:05:14.053Z" }+sdist = { url = "https://files.pythonhosted.org/packages/25/2a/484d112c0d8fc5f665d7b65137ac9cdb2953c982391598c3597968a12ee7/huggingface_hub-1.33.0.tar.gz", hash = "sha256:367be21a201db9523eddf8aeac7048f2602c1b308691c97640d5e72ed188007e", size = 1043548, upload-time = "2026-09-24T09:49:29.971Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/c3/0e/3e45bbe0dd48f4e56b1d46649d342de853cd1c7e815323472ab62687f153/huggingface_hub-1.30.0-py3-none-any.whl", hash = "sha256:96ae0a8e99a234374a6fe43e989ebd21c04640b91ab2927e7e5773ba1131ca59", size = 796795, upload-time = "2026-09-03T10:05:12.21Z" },+ { url = "https://files.pythonhosted.org/packages/fc/16/963096d224b80909432dc16561a615fd33d2d13beef3ce4c63fa25e40867/huggingface_hub-1.33.0-py3-none-any.whl", hash = "sha256:04e434b06e100eddbce9a6e817d72693a7884b10a79bd67ab48080d5c07eb899", size = 846435, upload-time = "2026-09-24T09:49:28.059Z" },][[package]]@@ -1218,7 +1217,7 @@ requires-dist = [{ name = "blake3" },{ name = "compel", specifier = ">=2.4.0,<3" },{ name = "deprecated" },- { name = "diffusers", extras = ["torch"], specifier = "==0.40.0" },+ { name = "diffusers", extras = ["torch"], specifier = "==0.41.0" },{ name = "dnspython" },{ name = "dynamicprompts" },{ name = "einops" },