invoke-ai/InvokeAI · error · RuntimeError

Provided model was not a diffusers model/pipeline, as…

Error message

Provided model was not a diffusers model/pipeline, as expected.

What it means

apply_hidiffusion (hidiffusion.py:2063) requires the target to be a diffusers DiffusionPipeline or ModelMixin (checked via isinstance_str) because it relies on pipeline attributes like `.unet` and `name_or_path`. Passing anything else — a bare torch module that is not a diffusers ModelMixin, a dict, a wrapper, or None — raises this RuntimeError before any patching.

Solutions

  1. Pass the diffusers pipeline object itself (e.g. StableDiffusionXLPipeline instance), not an inner component or wrapper.
  2. Apply HiDiffusion before torch.compile/DDP/accelerate wrapping so isinstance checks still match.
  3. Verify the argument is not None — check the from_pretrained call succeeded.
  4. If you only have a bare UNet, wrap/load it via a diffusers pipeline, or use a diffusers ModelMixin subclass.

Example fix

// before
apply_hidiffusion(pipe.unet, apply_raunet=True)
// after
apply_hidiffusion(pipe, apply_raunet=True, apply_window_attn=True)
Defensive patterns

Strategy: type-guard

Validate before calling

def is_diffusers_model(model) -> bool:
    from invokeai.backend.util import isinstance_str
    return isinstance_str(model, "DiffusionPipeline") or isinstance_str(model, "ModelMixin")

if not is_diffusers_model(model):
    raise TypeError("Pass the diffusers pipeline, not a wrapped/inner module")
apply_hidiffusion(model, apply_raunet=True)

Type guard

def is_hidiffusion_target(model) -> bool:
    from invokeai.backend.util import isinstance_str
    return model is not None and (
        isinstance_str(model, "DiffusionPipeline") or isinstance_str(model, "ModelMixin")
    )

Try / catch

try:
    apply_hidiffusion(model, apply_raunet=True, apply_window_attn=True)
except RuntimeError as e:
    if "not a diffusers model" in str(e):
        logger.error("apply_hidiffusion requires the raw diffusers pipeline (pre-compile, pre-wrap)")
    else:
        raise

Prevention

When it happens

Trigger: Calling hidiffusion_patch/apply_hidiffusion with a raw torch.nn.Module UNet that is not a diffusers ModelMixin subclass, a compiled (torch.compile) or DDP-wrapped model whose type no longer reports as DiffusionPipeline/ModelMixin, a None value from a failed pipeline load, or the InvokeAI modular denoise passing an unexpected object.

Common situations: Applying HiDiffusion inside custom inference code where the model was already unwrapped/compiled; wrapping the pipeline in a accelerator/distributed wrapper first; typos passing scheduler or text_encoder instead of the pipeline.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at invokeai/backend/hidiffusion/hidiffusion.py:2063

    generator: torch.Generator | None = None,
    has_controlnet: bool = False,
    is_controlnet_text_to_image: bool = False,
):
    """
    model: diffusers model. We support SD 1.5, 2.1, XL, XL Turbo.

    apply_raunet: whether to apply RAU-Net

    apply_window_attn: whether to apply MSW-MSA.
    """

    # Make sure the module is not currently patched
    remove_hidiffusion(model)

    is_diffusers = isinstance_str(model, "DiffusionPipeline") or isinstance_str(model, "ModelMixin")

    if not is_diffusers:
        raise RuntimeError("Provided model was not a diffusers model/pipeline, as expected.")
    else:
        # Check if the pipeline is a ControlNet pipeline. InvokeAI's modular
        # denoise passes a bare UNet, so it reports ControlNet separately.
        has_controlnet = has_controlnet or hasattr(model, "controlnet")
        is_sdxl_controlnet = hasattr(model, "controlnet") and isinstance_str(
            model, "StableDiffusionXLControlNet", prefix=True
        )
        is_sd_controlnet = hasattr(model, "controlnet") and isinstance_str(
            model, "StableDiffusionControlNet", prefix=True
        )

        # Check for ControlNet Inpaint pipelines
        is_sdxl_controlnet_inpaint = is_sdxl_controlnet and isinstance_str(model, "Inpaint", contains=True)
        is_sd_controlnet_inpaint = is_sd_controlnet and isinstance_str(model, "Inpaint", contains=True)

        if is_sdxl_controlnet_inpaint or is_sd_controlnet_inpaint:
            # For ControlNet Inpaint pipelines, we don't patch the pipeline class
            # because they already have all the necessary inpainting logic

View on GitHub (pinned to 0b6a024f2f)