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(lora): reject diffusers LoRAs of other DiTs by Anima's attention widths (#10223)

Alexander Eichhornebf2bd4ccfd9
diff --git a/docs/src/content/docs/Users Guide/03.Models/03.model-format-support.mdx b/docs/src/content/docs/Users Guide/03.Models/03.model-format-support.mdx
index 6300e306fc..3dd0329e72 100644
--- a/docs/src/content/docs/Users Guide/03.Models/03.model-format-support.mdx
+++ b/docs/src/content/docs/Users Guide/03.Models/03.model-format-support.mdx
@@ -267,5 +267,10 @@ On Z-Image, Qwen-Image, Anima and MOSS-Image, DoRA in the `lora_A`/`lora_B` layo
`lora_magnitude_vector`, ai-toolkit `.magnitude`) applies with its magnitude. DoRA works wherever the transformer weight can be dequantized (GGUF, SDNQ, int8/int4-convrot, nvfp4, fp8), but not
on bitsandbytes NF4/LLM.int8 bases.
+Anima's Diffusers PEFT LoRAs share their layer names with other transformers (LTX-2, LTX-Video, CogView4, PixArt,
+Sana and others). A file whose attention widths are not Anima's is not recognized as Anima. If no other supported
+model family matches, it installs as an unknown model. LTX-Video LoRAs without cross-attention key and value layers
+have Anima's widths and still install as Anima; see the [family page](/users-guide/models/local-models/anima/#lora).
+
[PiD decoders](/users-guide/image-generation/advanced-topics/pid-decode/) load for FLUX.1, FLUX.2, SD 3, SDXL and
Qwen-Image (v1 and v1.5, bf16 and int8 builds). FLUX.3 and MOSS-Image use the FLUX.2 decoders.
diff --git a/docs/src/content/docs/Users Guide/03.Models/Local Models/anima.mdx b/docs/src/content/docs/Users Guide/03.Models/Local Models/anima.mdx
index bf4ca39f49..052b6ed90a 100644
--- a/docs/src/content/docs/Users Guide/03.Models/Local Models/anima.mdx
+++ b/docs/src/content/docs/Users Guide/03.Models/Local Models/anima.mdx
@@ -169,6 +169,13 @@ includes text-encoder layers, to the Qwen3 encoder. In the workflow editor use *
DoRA LoRAs apply with their magnitudes in the `lora_A`/`lora_B` layout (LyCORIS `dora_scale`, PEFT
`lora_magnitude_vector`, ai-toolkit `.magnitude`) as well as in the kohya layout. DoRA runs on the GGUF, int8 and fp8 builds, but not on bitsandbytes NF4 or LLM.int8 weights.
+Diffusers LoRAs of other transformers that use the same layer names (for example LTX-2, CogView4, PixArt, Sana)
+are not recognized as Anima, because their attention widths do not match Anima's. If no other supported model family
+matches, they install as unknown models.
+LTX-Video is the exception: its attention layers are as wide as Anima's, except the cross-attention key and value
+layers (`attn2.to_k`, `attn2.to_v`), which read a wider text embedding. An LTX-Video LoRA that trains those layers is
+not recognized as Anima; one without them installs as Anima.
+
## Character reference (IP-Adapter)
The **Anima IP-Adapter (Character Reference)** starter model, by LuciferTC (~500 MB), carries a character
diff --git a/invokeai/backend/model_manager/configs/lora.py b/invokeai/backend/model_manager/configs/lora.py
index 55e83b2255..ca47323efe 100644
--- a/invokeai/backend/model_manager/configs/lora.py
+++ b/invokeai/backend/model_manager/configs/lora.py
@@ -44,6 +44,9 @@ from invokeai.backend.model_manager.taxonomy import (
)
from invokeai.backend.model_manager.util.model_util import lora_token_vector_length
from invokeai.backend.patches.lora_conversions.anima_lora_constants import (
+ ANIMA_CROSS_ATTENTION_CONTEXT_SIZE,
+ ANIMA_HIDDEN_SIZE,
+ DIFFUSERS_ANIMA_PROJECTION_RE,
has_cosmos_dit_kohya_keys,
has_cosmos_dit_kohya_keys_strict,
has_cosmos_dit_peft_keys,
@@ -1298,31 +1301,46 @@ _LOKR_FACTOR = re.compile(r"\.(lokr_w[12])(?:_b)?$")
_INPUT_WIDTH_PARAMS = (".lora_A.weight", ".lora_down.weight", ".hada_w1_b", ".hada_w2_b", ".diff")
-def _block_attention_in_features(state_dict: dict[str | int, Any]) -> tuple[set[int], set[int]]:
- """The input widths of the block-attention projections a LoRA targets: those its layers state directly, and
- those of its LoKR layers.
+def _attention_in_features(
+ state_dict: dict[str | int, Any], projection: re.Pattern[str] = _BLOCK_ATTENTION_PROJECTION
+) -> tuple[dict[str, int], dict[str, int]]:
+ """The input width of each attention projection a LoRA targets (those whose key `projection` finds), by layer
+ path: the widths its layers state directly, and those of its LoKR layers.
A low-rank, LoHA or full layer carries the width on one of its matrices; a LoKR weight is the Kronecker product
of two factors, so its input width is the product of theirs (each given whole, or as the second matrix of a
- pair).
+ pair). A layer that carries no width (a lone DoRA magnitude, half a pair) is absent.
"""
- direct: set[int] = set()
- factored: set[int] = set()
+ direct: dict[str, int] = {}
lokr: dict[str, dict[str, int]] = {}
for key, value in state_dict.items():
- if not isinstance(key, str) or _BLOCK_ATTENTION_PROJECTION.search(key) is None:
+ if not isinstance(key, str) or projection.search(key) is None:
continue
shape = getattr(value, "shape", ())
if len(shape) != 2:
continue
- if key.endswith(_INPUT_WIDTH_PARAMS):
- direct.add(shape[1])
+ if suffix := next((s for s in _INPUT_WIDTH_PARAMS if key.endswith(s)), None):
+ direct[key[: -len(suffix)]] = shape[1]
elif factor := _LOKR_FACTOR.search(key):
lokr.setdefault(key[: factor.start()], {})[factor.group(1)] = shape[1]
- factored.update(f["lokr_w1"] * f["lokr_w2"] for f in lokr.values() if len(f) == 2)
+ factored = {layer: f["lokr_w1"] * f["lokr_w2"] for layer, f in lokr.items() if len(f) == 2}
return direct, factored
+def _anima_width_violation(state_dict: dict[str | int, Any]) -> str | None:
+ """Why a diffusers-layout LoRA cannot be Anima's, or None: an attention projection whose input width is not
+ Anima's. Other transformers share these layer names (LTX-2, LTX-Video, CogView4, PixArt, Sana, ...)."""
+ direct, factored = _attention_in_features(state_dict, DIFFUSERS_ANIMA_PROJECTION_RE)
+ for layer, width in {**direct, **factored}.items():
+ match = DIFFUSERS_ANIMA_PROJECTION_RE.match(f"{layer}.")
+ assert match is not None
+ reads_context = match.group(1) == "attn2" and match.group(2) in ("to_k", "to_v")
+ expected = ANIMA_CROSS_ATTENTION_CONTEXT_SIZE if reads_context else ANIMA_HIDDEN_SIZE
+ if width != expected:
+ return f"{layer} reads {width} features; Anima's reads {expected}"
+ return None
+
+
def _has_qwen_image21_lora_keys(state_dict: dict[str | int, Any]) -> bool:
"""True if the state dict is a Qwen-Image-2.1 LoRA, whose module names otherwise overlap Qwen-Image's.
@@ -1338,10 +1356,10 @@ def _has_qwen_image21_lora_keys(state_dict: dict[str | int, Any]) -> bool:
"""
if any(isinstance(key, str) and any(m in key for m in _QWEN_IMAGE21_MLP_MARKERS) for key in state_dict):
return True
- direct, factored = _block_attention_in_features(state_dict)
- if _QWEN_IMAGE21_HIDDEN_SIZE in direct:
+ direct, factored = _attention_in_features(state_dict)
+ if _QWEN_IMAGE21_HIDDEN_SIZE in direct.values():
return True
- return _QWEN_IMAGE21_HIDDEN_SIZE in factored and not any(
+ return _QWEN_IMAGE21_HIDDEN_SIZE in factored.values() and not any(
isinstance(key, str) and QWEN_IMAGE_ONLY_MODULE_RE.search(key) for key in state_dict
)
@@ -1707,9 +1725,11 @@ class LoRA_LyCORIS_Anima_Config(LoRA_LyCORIS_Config_Base, Config_Base):
},
)
- # Diffusers' Cosmos layout (`transformer_blocks.N.attn1` / `attn2`) is also SD 3.5 Medium's; the width tells them
- # apart.
+ # Diffusers' Cosmos layout (`transformer_blocks.N.attn1` / `attn2`) is shared with other transformers; the
+ # projections' widths tell them apart.
if has_cosmos_keys and has_lora_suffix and not has_ltx2_lora_keys(str_keys) and not is_sd3_lora(state_dict):
+ if violation := _anima_width_violation(state_dict):
+ raise NotAMatchError(f"model does not match Anima LoRA heuristics: {violation}")
return
raise NotAMatchError("model does not match Anima LoRA heuristics")
@@ -1730,6 +1750,8 @@ class LoRA_LyCORIS_Anima_Config(LoRA_LyCORIS_Config_Base, Config_Base):
and not has_ltx2_lora_keys(str_keys)
and not is_sd3_lora(state_dict)
):
+ if violation := _anima_width_violation(state_dict):
+ raise NotAMatchError(f"model does not look like an Anima LoRA: {violation}")
return BaseModelType.Anima
raise NotAMatchError("model does not look like an Anima LoRA")
diff --git a/invokeai/backend/patches/lora_conversions/anima_lora_constants.py b/invokeai/backend/patches/lora_conversions/anima_lora_constants.py
index a22d125371..f034452fe8 100644
--- a/invokeai/backend/patches/lora_conversions/anima_lora_constants.py
+++ b/invokeai/backend/patches/lora_conversions/anima_lora_constants.py
@@ -35,10 +35,20 @@ _PEFT_ANIMA_RE = re.compile(
# module uses ``blocks.N.self_attn`` / ``cross_attn``. These names are distinct from Qwen-Image's
# ``transformer_blocks.N.attn`` and Wan's ``blocks.N.attn1`` layouts. ``ff.net`` is not a signature because FLUX
# uses the same path; it is converted only after another layer has identified the file as Anima.
-_DIFFUSERS_ANIMA_RE = re.compile(
- r"^(?:transformer\.|base_model\.model\.(?:transformer\.)?)?transformer_blocks\.\d+\.(?:attn1|attn2)\."
+_DIFFUSERS_PREFIX = r"(?:transformer\.|base_model\.model\.(?:transformer\.)?)?"
+_DIFFUSERS_ANIMA_RE = re.compile(rf"^{_DIFFUSERS_PREFIX}transformer_blocks\.\d+\.(?:attn1|attn2)\.")
+
+# The attention projections of that layout whose input width is checked against Anima's. Other transformers use the
+# same names, so the names alone do not make a LoRA Anima's. Group 1 is the attention, group 2 the projection.
+DIFFUSERS_ANIMA_PROJECTION_RE = re.compile(
+ rf"^{_DIFFUSERS_PREFIX}transformer_blocks\.\d+\.(attn1|attn2)\.(to_q|to_k|to_v|to_out\.0)\."
)
+# Input widths of the projections above; the same in every Anima variant (base, 2.9B, 3.8B). `attn2.to_k` and
+# `attn2.to_v` read the text context, every other projection the hidden state.
+ANIMA_HIDDEN_SIZE = 2048
+ANIMA_CROSS_ATTENTION_CONTEXT_SIZE = 1024
+
# Subcomponents *uniquely* identifying Anima/Cosmos DiT: the DiT block MLP (``mlp.layer_0`` / ``mlp_layer1``)
# and ``adaln_modulation`` (Wan calls those ``ffn`` and ``modulation`` respectively), plus the Cosmos
diff --git a/tests/backend/model_manager/configs/test_anima_diffusers_lora_config.py b/tests/backend/model_manager/configs/test_anima_diffusers_lora_config.py
index 8ff1fa369b..12643e34c9 100644
--- a/tests/backend/model_manager/configs/test_anima_diffusers_lora_config.py
+++ b/tests/backend/model_manager/configs/test_anima_diffusers_lora_config.py
@@ -9,28 +9,150 @@ from invokeai.backend.model_manager.configs.lora import LoRA_LyCORIS_Anima_Confi
from invokeai.backend.model_manager.model_on_disk import ModelOnDisk
from invokeai.backend.model_manager.taxonomy import BaseModelType
+PREFIXES = ["", "transformer.", "base_model.model.", "base_model.model.transformer."]
+PREFIX_IDS = ["bare", "diffusers", "peft", "peft-transformer"]
- "model_prefix",
- ["", "transformer.", "base_model.model.", "base_model.model.transformer."],
- ids=["bare", "diffusers", "peft", "peft-transformer"],
-)
-def test_diffusers_cosmos_lora_identifies_as_anima(tmp_path, model_prefix: str) -> None:
+
+def _lora_layers(prefix: str, layers: dict[str, tuple[int, int]], block: int = 0) -> dict[str, torch.Tensor]:
+ """Rank-4 low-rank layers of `transformer_blocks.<block>`, each given as (input width, output width)."""
state_dict: dict[str, torch.Tensor] = {}
- for name in ("attn1.to_q", "attn2.to_k", "ff.net.0.proj"):
- prefix = f"{model_prefix}transformer_blocks.0.{name}"
- state_dict[f"{prefix}.lora_A.weight"] = torch.randn(4, 2048)
- state_dict[f"{prefix}.lora_B.weight"] = torch.randn(2048, 4)
+ for name, (in_features, out_features) in layers.items():
+ layer = f"{prefix}transformer_blocks.{block}.{name}"
+ state_dict[f"{layer}.lora_A.weight"] = torch.zeros(4, in_features)
+ state_dict[f"{layer}.lora_B.weight"] = torch.zeros(out_features, 4)
+ return state_dict
+
- path = tmp_path / "anima_diffusers_lora.safetensors"
+def _identify(tmp_path, state_dict: dict[str, torch.Tensor]):
+ path = tmp_path / "lora.safetensors"
save_file(state_dict, path)
+ return ModelConfigFactory.from_model_on_disk(path, allow_unknown=True).config
+
+
+# Anima: 2048 wide, text context 1024.
+ANIMA_LAYERS = {
+ "attn1.to_q": (2048, 2048),
+ "attn1.to_out.0": (2048, 2048),
+ "attn2.to_q": (2048, 2048),
+ "attn2.to_k": (1024, 2048),
+ "attn2.to_v": (1024, 2048),
+ "attn2.to_out.0": (2048, 2048),
+ "ff.net.0.proj": (2048, 8192),
+}
+
- config = ModelConfigFactory.from_model_on_disk(path, allow_unknown=False).config
[email protected]("model_prefix", PREFIXES, ids=PREFIX_IDS)
+def test_diffusers_cosmos_lora_identifies_as_anima(tmp_path, model_prefix: str) -> None:
+ config = _identify(tmp_path, _lora_layers(model_prefix, ANIMA_LAYERS))
assert isinstance(config, LoRA_LyCORIS_Anima_Config)
assert config.base == BaseModelType.Anima
[email protected]("model_prefix", PREFIXES, ids=PREFIX_IDS)
+def test_video_only_ltx2_lora_is_not_identified_as_anima(tmp_path, model_prefix: str) -> None:
+ """LTX-2's video stream (4096 wide) names its layers as Anima's diffusers layout does."""
+ layers = {
+ "attn1.to_q": (4096, 4096),
+ "attn1.to_out.0": (4096, 4096),
+ "attn2.to_q": (4096, 4096),
+ "attn2.to_k": (4096, 4096),
+ "ff.net.0.proj": (4096, 16384),
+ }
+
+ config = _identify(tmp_path, _lora_layers(model_prefix, layers))
+
+ assert config.base == BaseModelType.Unknown
+
+
+# Widths read from the released models' configs: (attn1 width, attn2 width or None, attn2 text context).
+FOREIGN_TRANSFORMERS = {
+ "cogview4": (4096, None, None),
+ "mochi": (3072, None, None),
+ "cogvideox-2b": (1920, None, None),
+ "cogvideox-5b": (3072, None, None),
+ "pixart-sigma": (1152, 1152, 1152),
+ "sana-600m": (1152, 1152, 1152),
+ "sana-1600m": (2240, 2240, 2240),
+ # Self-attention is as wide as Anima's; only the text context tells them apart.
+ "ltx-video": (2048, 2048, 2048),
+}
+
+
+def _foreign_layers(hidden: int, attn2_hidden: int | None, context: int | None) -> dict[str, tuple[int, int]]:
+ layers = {"attn1.to_q": (hidden, hidden), "attn1.to_out.0": (hidden, hidden)}
+ if attn2_hidden is not None and context is not None:
+ layers |= {
+ "attn2.to_q": (attn2_hidden, attn2_hidden),
+ "attn2.to_k": (context, attn2_hidden),
+ "attn2.to_out.0": (attn2_hidden, attn2_hidden),
+ }
+ return layers
+
+
[email protected]("model_prefix", PREFIXES, ids=PREFIX_IDS)
[email protected]("family", FOREIGN_TRANSFORMERS)
+def test_diffusers_lora_of_another_transformer_is_not_identified_as_anima(
+ tmp_path, family: str, model_prefix: str
+) -> None:
+ layers = _foreign_layers(*FOREIGN_TRANSFORMERS[family])
+
+ config = _identify(tmp_path, _lora_layers(model_prefix, layers))
+
+ assert config.base == BaseModelType.Unknown
+
+
+def test_attention_that_reads_the_wrong_width_names_the_layer(tmp_path) -> None:
+ """LTX-Video's `attn1` is Anima's width; its `attn2.to_k` reads a 2048 context instead of 1024."""
+ path = tmp_path / "ltx_video.safetensors"
+ save_file(_lora_layers("transformer.", _foreign_layers(*FOREIGN_TRANSFORMERS["ltx-video"])), path)
+
+ with pytest.raises(NotAMatchError, match=r"attn2\.to_k reads 2048 features; Anima's reads 1024"):
+ LoRA_LyCORIS_Anima_Config._validate_looks_like_lora(ModelOnDisk(path))
+ with pytest.raises(NotAMatchError, match=r"attn2\.to_k"):
+ LoRA_LyCORIS_Anima_Config._get_base_or_raise(ModelOnDisk(path))
+
+
+def test_sd35_medium_lora_is_identified_as_sd3_not_anima(tmp_path) -> None:
+ layers = {"attn.to_q": (1536, 1536), "attn2.to_q": (1536, 1536), "attn2.to_k": (1536, 1536)}
+
+ config = _identify(tmp_path, _lora_layers("transformer.", layers))
+
+ assert config.base == BaseModelType.StableDiffusion3
+
+
+def _lokr_layers(prefix: str, layers: dict[str, int]) -> dict[str, torch.Tensor]:
+ """LoKR layers whose input width is the product of two factors (2 * width // 2)."""
+ state_dict: dict[str, torch.Tensor] = {}
+ for name, width in layers.items():
+ layer = f"{prefix}transformer_blocks.0.{name}"
+ state_dict[f"{layer}.lokr_w1"] = torch.zeros(8, 2)
+ state_dict[f"{layer}.lokr_w2"] = torch.zeros(8, width // 2)
+ return state_dict
+
+
+def test_lokr_whose_factors_multiply_to_anima_widths_identifies_as_anima(tmp_path) -> None:
+ config = _identify(tmp_path, _lokr_layers("transformer.", {"attn1.to_q": 2048, "attn2.to_k": 1024}))
+
+ assert isinstance(config, LoRA_LyCORIS_Anima_Config)
+
+
+def test_lokr_whose_factors_multiply_to_another_width_is_not_identified_as_anima(tmp_path) -> None:
+ config = _identify(tmp_path, _lokr_layers("transformer.", {"attn1.to_q": 4096, "attn2.to_k": 4096}))
+
+ assert config.base == BaseModelType.Unknown
+
+
+def test_attention_layers_without_a_width_do_not_reject_an_anima_lora(tmp_path) -> None:
+ """A DoRA magnitude carries no input width, so it neither confirms nor refutes one."""
+ state_dict = _lora_layers("transformer.", {"attn2.to_k": (1024, 2048), "ff.net.0.proj": (2048, 8192)})
+ state_dict["transformer.transformer_blocks.0.attn1.to_q.dora_scale"] = torch.zeros(1, 2048)
+
+ config = _identify(tmp_path, state_dict)
+
+ assert isinstance(config, LoRA_LyCORIS_Anima_Config)
+
+
def test_sd_unet_transformer_block_is_not_identified_as_anima(tmp_path) -> None:
prefix = "base_model.model.down_blocks.0.attentions.0.transformer_blocks.0.attn1.to_q"
state_dict = {
@@ -71,3 +193,15 @@ def test_transformer_prefixed_ltx2_lora_is_not_identified_as_anima(tmp_path) ->
with pytest.raises(NotAMatchError):
LoRA_LyCORIS_Anima_Config._validate_looks_like_lora(ModelOnDisk(path))
+
+
+def test_kohya_anima_lora_still_identifies_as_anima(tmp_path) -> None:
+ """Kohya keys name `blocks_N`, not the diffusers layout the width check applies to."""
+ state_dict = {
+ "lora_unet_blocks_0_cross_attn_q_proj.lora_down.weight": torch.zeros(4, 2048),
+ "lora_unet_blocks_0_cross_attn_q_proj.lora_up.weight": torch.zeros(2048, 4),
+ "lora_unet_blocks_0_mlp_layer1.lora_down.weight": torch.zeros(4, 2048),
+ "lora_unet_blocks_0_mlp_layer1.lora_up.weight": torch.zeros(8192, 4),
+ }
+
+ assert isinstance(_identify(tmp_path, state_dict), LoRA_LyCORIS_Anima_Config)
diff --git a/tests/backend/model_manager/configs/test_ltx2_lora_probe_independence.py b/tests/backend/model_manager/configs/test_ltx2_lora_probe_independence.py
index 6b186463be..b47f90cdad 100644
--- a/tests/backend/model_manager/configs/test_ltx2_lora_probe_independence.py
+++ b/tests/backend/model_manager/configs/test_ltx2_lora_probe_independence.py
@@ -21,7 +21,7 @@ import torch
from invokeai.backend.model_manager.configs.base import Config_Base
from invokeai.backend.model_manager.configs.identification_utils import NotAMatchError
-from invokeai.backend.model_manager.configs.lora import LoRA_LyCORIS_LTX2_Config
+from invokeai.backend.model_manager.configs.lora import LoRA_LyCORIS_Anima_Config, LoRA_LyCORIS_LTX2_Config
from invokeai.backend.model_manager.taxonomy import BaseModelType
@@ -177,6 +177,17 @@ def test_another_familys_lora_is_rejected_by_the_ltx2_probe(name: str, keys) ->
assert not matched
[email protected]("prefix", ["", "transformer.", "base_model.model.", "base_model.model.transformer."])
+def test_a_video_only_ltx2_lora_is_rejected_by_the_anima_probe(prefix: str) -> None:
+ """Without the audio tower nothing in the key names tells it from Anima's diffusers layout; the 4096-wide
+ attention does."""
+ video_tower = {k: v for k, v in _ltx2_distilled_keys(prefix).items() if ".attn1." in k}
+
+ matched, _ = _probe(LoRA_LyCORIS_Anima_Config, video_tower)
+
+ assert not matched
+
+
def test_the_ltx2_probe_requires_a_lora_suffix() -> None:
"""LTX-2 module names alone are the base checkpoint, not a LoRA."""
sd = {
diff --git a/tests/backend/model_manager/configs/test_sd3_lora_probe_independence.py b/tests/backend/model_manager/configs/test_sd3_lora_probe_independence.py
index 5cd35ef6c7..e73fe9e939 100644
--- a/tests/backend/model_manager/configs/test_sd3_lora_probe_independence.py
+++ b/tests/backend/model_manager/configs/test_sd3_lora_probe_independence.py
@@ -158,11 +158,8 @@ def test_a_qwen_image_lora_is_still_claimed_by_qwen_image_alone(family: str) ->
@pytest.mark.parametrize("spelling", ["diffusers", "kohya"])
def test_a_cogview4_lora_is_no_longer_taken_for_qwen_image(spelling: str) -> None:
- """CogView4 keeps its blocks under `transformer_blocks.N.attn1`; neither Qwen-Image nor SD 3 may claim it.
-
- Except Anima for the diffusers spelling: diffusers' Cosmos layout uses the same `transformer_blocks.N.attn1` names.
- That match is a known misidentification that predates SD 3 support and is outside it.
- """
+ """CogView4 keeps its blocks under `transformer_blocks.N.attn1`; no LoRA probe may claim it. Anima's diffusers
+ layout uses the same names, but its attention is 2048 wide and CogView4's 4096."""
keys: dict[str, list[int]] = {}
for proj in ("to_q", "to_k", "to_v", "to_out.0"):
layer = (
@@ -174,8 +171,7 @@ def test_a_cogview4_lora_is_no_longer_taken_for_qwen_image(spelling: str) -> Non
keys[f"{layer}.{down}.weight"] = [16, 4096]
keys[f"{layer}.{up}.weight"] = [4096, 16]
- expected = ["LoRA_LyCORIS_Anima_Config"] if spelling == "diffusers" else []
- assert _accepting_lora_configs(_state_dict(keys), f"cogview4-{spelling}") == expected
+ assert _accepting_lora_configs(_state_dict(keys), f"cogview4-{spelling}") == []
def _clip_layers(prefix_l: str, prefix_g: str) -> dict[str, list[int]]: