invoke-ai/InvokeAI · error · ValueError

Could not determine Wan variant from model {config.name!r}:

Error message

Could not determine Wan variant from model {config.name!r}: variant is {variant!r}.

What it means

_resolve_variant reads the 'variant' attribute from the main model config behind the WanTransformerField and requires it to be a valid WanVariantType member. If the attribute is missing, None, or an unrecognized string, the Wan variant (14B vs TI2V-5B etc.) cannot be determined and the denoise invocation aborts.

Source

Thrown at invokeai/app/invocations/wan_denoise.py:83


def _get_wan_transformer_working_mem_bytes(device: torch.device, *, enabled: bool) -> int | None:
    """Reserve all but 2 GiB of VRAM so partial-load Wan weights target about 2 GiB resident."""
    if not enabled or device.type != "cuda":
        return None

    total_vram = torch.cuda.get_device_properties(device).total_memory
    if total_vram <= WAN_MAX_RESIDENT_TRANSFORMER_BYTES:
        return None
    return total_vram - WAN_MAX_RESIDENT_TRANSFORMER_BYTES


def _resolve_variant(context: InvocationContext, transformer_field: WanTransformerField) -> WanVariantType:
    """Look up the Wan variant from the main model config that produced this transformer."""
    config = context.models.get_config(transformer_field.transformer)
    variant = getattr(config, "variant", None)
    if not isinstance(variant, WanVariantType):
        raise ValueError(f"Could not determine Wan variant from model {config.name!r}: variant is {variant!r}.")
    return variant


def _validate_spatial_dimensions(variant: WanVariantType, width: int, height: int) -> None:
    if variant == WanVariantType.TI2V_5B and (width % 32 or height % 32):
        raise ValueError(
            f"TI2V-5B requires width and height to be multiples of 32 (got {width}x{height}). "
            "Wan 2.2-VAE 16x spatial * transformer patch_size 2 = pixel dims must divide by 32."
        )


def _validate_ref_condition_shape(
    condition: torch.Tensor,
    *,
    channels: int,
    frames: int,
    height: int,
    width: int,

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Re-convert/re-install the Wan model so its config includes a valid variant
  2. Set variant explicitly in the model config (e.g. '14b' or 'ti2v-5b') and restart
  3. Remove the model and re-import it via the Model Manager so defaults are applied
  4. Verify the transformer field points at an actual Wan model, not another architecture

Example fix

// before
# models.yaml
my-wan-model:
  variant:   # missing/None
// after
my-wan-model:
  variant: ti2v-5b
Defensive patterns

Strategy: validation

Validate before calling

config = context.models.get_config(transformer_field.transformer)
variant = getattr(config, 'variant', None)
if variant not in ('14b', 'ti2v-5b'):  # valid WanVariantType values
    # re-register / fix the model config before invoking

Type guard

def has_wan_variant(config) -> bool:
    from invokeai.backend.model_manager.taxonomy import WanVariantType
    return isinstance(getattr(config, 'variant', None), WanVariantType)

Try / catch

try:
    result = denoise.invoke(context)
except ValueError as e:
    if "Could not determine Wan variant" in str(e):
        # re-install the model so its config gains a valid variant, then retry
        model_manager.reinstall(model_key)
        result = denoise.invoke(context)
    else:
        raise

Prevention

When it happens

Trigger: Attaching a transformer whose model config has no 'variant' field (older/foreign model installs), a hand-edited models.yaml with variant: null, a model converted/imported before the variant field existed, or pointing the transformer field at a non-Wan model.

Common situations: Upgrading Invoke and running old model records lacking the variant key, models installed from third-party repos with incomplete config, manually copied model directories without proper registration.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/240525d5c46b2e8e. Report an issue: GitHub.