Comfy-Org/ComfyUI · error · TypeError

ar_video sampler requires a Causal-WAN compatible model whos

Error message

ar_video sampler requires a Causal-WAN compatible model whose diffusion_model exposes init_kv_caches() and init_crossattn_caches(). The loaded checkpoint does not support this interface — choose a different sampler.

What it means

Raised by sample_ar_video after the latent-shape check: the sampler drives autoregressive generation via the loaded diffusion model's init_kv_caches() / init_crossattn_caches() interface, which only Causal-WAN checkpoints expose. If the loaded model is any other architecture, those attributes are absent and a TypeError is raised telling you the checkpoint does not support AR sampling.

Source

Thrown at comfy/k_diffusion/sampling.py:1871

    All AR-loop parameters are passed via the SamplerARVideo node, not read
    from the checkpoint or transformer_options.
    """
    extra_args = {} if extra_args is None else extra_args
    model_options = extra_args.get("model_options", {})
    transformer_options = model_options.get("transformer_options", {})

    if x.ndim != 5:
        raise ValueError(
            f"ar_video sampler requires 5-D video latents [B,C,T,H,W], got {x.ndim}-D tensor with shape {x.shape}. "
            "This sampler is only compatible with autoregressive video models (e.g. Causal-WAN)."
        )

    inner_model = model.inner_model.inner_model
    causal_model = inner_model.diffusion_model

    if not (hasattr(causal_model, "init_kv_caches") and hasattr(causal_model, "init_crossattn_caches")):
        raise TypeError(
            "ar_video sampler requires a Causal-WAN compatible model whose diffusion_model "
            "exposes init_kv_caches() and init_crossattn_caches(). The loaded checkpoint "
            "does not support this interface — choose a different sampler."
        )

    seed = extra_args.get("seed", 0)

    bs, c, lat_t, lat_h, lat_w = x.shape
    frame_seq_len = -(-lat_h // 2) * -(-lat_w // 2) # ceiling division
    num_blocks = -(-lat_t // num_frame_per_block)   # ceiling division
    device = x.device
    model_dtype = inner_model.get_dtype()

    kv_caches = causal_model.init_kv_caches(bs, lat_t * frame_seq_len, device, model_dtype)
    crossattn_caches = causal_model.init_crossattn_caches(bs, device, model_dtype)

    output = torch.zeros_like(x)
    s_in = x.new_ones([x.shape[0]])

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Load a Causal-WAN checkpoint whose transformer implements init_kv_caches / init_crossattn_caches
  2. Or switch the sampler to a standard one (dpmpp_2m_sde, euler, etc.) for the loaded model
  3. If using a re-converted checkpoint, re-export it so the causal cache interface is preserved
Defensive patterns

Strategy: type-guard

Validate before calling

dm = model.inner_model.inner_model.diffusion_model
if not (hasattr(dm, 'init_kv_caches') and hasattr(dm, 'init_crossattn_caches')):
    raise TypeError('load a Causal-WAN checkpoint or pick a non-AR sampler')

Type guard

def is_causal_wan(model) -> bool:
    dm = model.inner_model.inner_model.diffusion_model
    return hasattr(dm, 'init_kv_caches') and hasattr(dm, 'init_crossattn_caches')

Try / catch

try:
    out = sample_ar_video(model, x, sigmas, ...)
except TypeError:
    out = sample_dpmpp_2m_sde(model, x, sigmas)  # fallback sampler

Prevention

When it happens

Trigger: Selecting the ar_video sampler while a non-Causal-WAN diffusion model (SD, Flux, standard Wan 2.x, etc.) is loaded. The hasattr probe on model.inner_model.inner_model.diffusion_model fails before any step runs.

Common situations: Switching sampler in a workflow without swapping the checkpoint; loading a Wan variant that was converted without the causal cache methods; older checkpoints against a newer ComfyUI where ar_video was newly added.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/8d6f309f3365d22d. Report an issue: GitHub.