{"record":{"id":"9cc9e5d99f1189bf","repo":"invoke-ai/InvokeAI","slug":"lora-lora-key-targets-wan-lora-variant-value","errorCode":null,"errorMessage":"LoRA '{lora_key}' targets Wan {lora_variant.value.upper()} models, but the transformer is a {main_variant.value} model. A14B and 5B LoRAs are not interchangeable.","messagePattern":"LoRA '(.+?)' targets Wan (.+?) models, but the transformer is a (.+?) model\\. A14B and 5B LoRAs are not interchangeable\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/wan_lora_loader.py","lineNumber":70,"sourceCode":"            f\"base={getattr(config_base, 'value', config_base)}).\"\n        )\n\n\ndef _assert_lora_variant_matches_main(lora_config: object, main_config: object, lora_key: str) -> None:\n    \"\"\"Reject an A14B LoRA wired against a 5B main (and vice versa).\n\n    A mismatch otherwise crashes deep in the layer patcher mid-denoise with an opaque\n    tensor-shape error, after minutes of model loading. Skips silently when either\n    variant is unrecorded (e.g. a LoRA whose targeted layers don't pin the inner dim).\n    \"\"\"\n    lora_variant = getattr(lora_config, \"variant\", None)\n    main_variant = getattr(main_config, \"variant\", None)\n    if lora_variant is None or main_variant is None:\n        return\n    lora_is_5b = lora_variant == WanLoRAVariantType.Wan5B\n    main_is_5b = main_variant == WanVariantType.TI2V_5B\n    if lora_is_5b != main_is_5b:\n        raise ValueError(\n            f\"LoRA '{lora_key}' targets Wan {lora_variant.value.upper()} models, but the \"\n            f\"transformer is a {main_variant.value} model. A14B and 5B LoRAs are not interchangeable.\"\n        )\n\n\ndef _correct_inert_low_routing(\n    context: InvocationContext, main_config: object, lora_key: str, to_primary: bool, to_low_noise: bool\n) -> tuple[bool, bool]:\n    \"\"\"Re-point a low-only routing at the primary list when the main is TI2V-5B.\n\n    TI2V-5B is single-transformer: the denoise path only ever reads the primary LoRA\n    list, so a LoRA routed low-only has no effect at all and the node still reports\n    success. There is no ambiguity about what to do instead — the model has exactly one\n    transformer — so correct the routing rather than merely warning about it.\n\n    This is the backstop for the probe-side pin in ``LoRA_LyCORIS_Wan_Config``, which\n    can only suppress the expert tag when it managed to detect the variant.\n    ``detect_wan_lora_variant`` reads the inner dim off an ``attn1.to_q`` LoRA pair, so","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/wan_lora_loader.py#L52-L88","documentation":"_assert_lora_variant_matches_main compares the LoRA's variant against the main transformer's variant and rejects mixes between 5B (TI2V-5B) and A14B lineages, because their architectures (and thus LoRA weight shapes) are not interchangeable. When both variants are known and one is 5B while the other is not, a ValueError naming both variants is raised.","triggerScenarios":"Loading a Wan 5B LoRA into an A14B transformer, or an A14B LoRA into a TI2V-5B transformer, via wan_lora_loader.invoke(), when both configs expose variant fields.","commonSituations":"Downloading a LoRA trained for Wan 2.2 TI2V-5B and applying it to Wan 2.1 A14B; ambiguous LoRA names like 'wan-lora' hiding the variant; collections mixing 2.1 and 2.2 LoRAs.","solutions":["Use a LoRA whose variant matches the transformer: 5B LoRA only with TI2V-5B, A14B LoRA only with A14B.","Check the LoRA card/README for the target Wan variant before downloading.","If variant metadata is missing (check silently passes), verify compatibility manually or retrain/export the LoRA for the right variant.","Keep separate workflows for Wan 2.1 A14B and Wan 2.2 TI2V-5B so LoRA lists don't mix."],"exampleFix":"// before\ntransformer = load(\"wan2.1-a14b\")\nlora = load_lora(\"wan22-ti2v-5b-lora\")\nout = wan_lora_loader(loras=[lora], transformer=transformer)  # ValueError\n// after\ntransformer = load(\"wan2.2-ti2v-5b\")\nlora = load_lora(\"wan22-ti2v-5b-lora\")\nout = wan_lora_loader(loras=[lora], transformer=transformer)","handlingStrategy":"validation","validationCode":"lora_cfg = get_lora_config(key)\nmain_cfg = get_main_config(transformer)\nlv, mv = getattr(lora_cfg, 'variant', None), getattr(main_cfg, 'variant', None)\nif lv is not None and mv is not None:\n    l5, m5 = (lv == WanLoRAVariantType.Wan5B), (mv == WanVariantType.TI2V_5B)\n    if l5 != m5:\n        raise ValueError(f\"LoRA variant {lv} incompatible with transformer variant {mv}\")","typeGuard":"def lora_matches_main(lora_variant, main_variant) -> bool:\n    if lora_variant is None or main_variant is None:\n        return True\n    return (lora_variant == WanLoRAVariantType.Wan5B) == (main_variant == WanVariantType.TI2V_5B)","tryCatchPattern":"try:\n    out = node.invoke(context)\nexcept ValueError as e:\n    if \"not interchangeable\" in str(e):\n        loras = filter_loras_by_variant(loras, main_variant)\n        out = replace(node, loras=loras).invoke(context)\n    else:\n        raise","preventionTips":["Check LoRA cards for target Wan variant before downloading.","Maintain separate workflows for A14B and TI2V-5B.","Prefer LoRAs with explicit variant metadata.","Verify variant fields in the Model Manager when downloads are ambiguous."],"tags":["wan","lora","variant-mismatch","model-config"],"backgroundTag":"incompatible-lora-variant","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}