Comfy-Org/ComfyUI · error · ValueError

Unknown attention type: {attn_type}

Error message

Unknown attention type: {attn_type}

What it means

Raised by make_attention's final match case when attn_type is not VANILLA, NONE, or LINEAR. Since the parameter is expected to be an AttentionType enum, this only occurs when a foreign value (wrong enum class, raw string on an unvalidated path, or a post-hoc mutation) reaches the factory.

Source

Thrown at comfy/ldm/lightricks/vae/causal_audio_autoencoder.py:415

def make_attn(in_channels, attn_type="vanilla", norm_type="group"):
    # Convert string to enum if needed
    attn_type = AttentionType.str_to_enum(attn_type)

    if attn_type != AttentionType.NONE:
        logging.info(f"making attention of type '{attn_type.value}' with {in_channels} in_channels")
    else:
        logging.info(f"making identity attention with {in_channels} in_channels")

    match attn_type:
        case AttentionType.VANILLA:
            return AttnBlock(in_channels, norm_type=norm_type)
        case AttentionType.NONE:
            return nn.Identity(in_channels)
        case AttentionType.LINEAR:
            raise NotImplementedError(f"Attention type {attn_type.value} is not supported yet.")
        case _:
            raise ValueError(f"Unknown attention type: {attn_type}")


class Encoder(nn.Module):
    def __init__(
        self,
        *,
        ch,
        out_ch,
        ch_mult=(1, 2, 4, 8),
        num_res_blocks,
        attn_resolutions,
        dropout=0.0,
        resamp_with_conv=True,
        in_channels,
        resolution,
        z_channels,
        double_z=True,
        attn_type="vanilla",

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Convert the config value with AttentionType(value) before calling make_attention
  2. Pass the enum member directly: AttentionType.VANILLA, AttentionType.NONE, or AttentionType.LINEAR
  3. Import AttentionType from comfy/ldm/lightricks/vae/causal_audio_autoencoder.py so only one enum class is in play

Example fix

# before
attn = make_attention(ch, attn_type="vanilla")

# after
attn = make_attention(ch, attn_type=AttentionType.VANILLA)
Defensive patterns

Strategy: type-guard

Validate before calling

assert isinstance(attn_type, AttentionType), f"expected AttentionType, got {type(attn_type).__name__}"

Type guard

def is_attention_type(v) -> bool:
    return isinstance(v, AttentionType)

Prevention

When it happens

Trigger: Passing a value that is not an AttentionType member, e.g. a string 'vanilla' on a path that does not run enum conversion, or a similarly-named enum from another module.

Common situations: Calling make_attention directly from custom code without converting the config string first; duplicated enum definitions across copied lightricks modules.

Related errors


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