{"record":{"id":"d3d4c22e7d74637e","repo":"Comfy-Org/ComfyUI","slug":"unknown-attention-type-attn-type","errorCode":null,"errorMessage":"Unknown attention type: {attn_type}","messagePattern":"Unknown attention type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/lightricks/vae/causal_audio_autoencoder.py","lineNumber":415,"sourceCode":"\ndef make_attn(in_channels, attn_type=\"vanilla\", norm_type=\"group\"):\n    # Convert string to enum if needed\n    attn_type = AttentionType.str_to_enum(attn_type)\n\n    if attn_type != AttentionType.NONE:\n        logging.info(f\"making attention of type '{attn_type.value}' with {in_channels} in_channels\")\n    else:\n        logging.info(f\"making identity attention with {in_channels} in_channels\")\n\n    match attn_type:\n        case AttentionType.VANILLA:\n            return AttnBlock(in_channels, norm_type=norm_type)\n        case AttentionType.NONE:\n            return nn.Identity(in_channels)\n        case AttentionType.LINEAR:\n            raise NotImplementedError(f\"Attention type {attn_type.value} is not supported yet.\")\n        case _:\n            raise ValueError(f\"Unknown attention type: {attn_type}\")\n\n\nclass Encoder(nn.Module):\n    def __init__(\n        self,\n        *,\n        ch,\n        out_ch,\n        ch_mult=(1, 2, 4, 8),\n        num_res_blocks,\n        attn_resolutions,\n        dropout=0.0,\n        resamp_with_conv=True,\n        in_channels,\n        resolution,\n        z_channels,\n        double_z=True,\n        attn_type=\"vanilla\",","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/lightricks/vae/causal_audio_autoencoder.py#L397-L433","documentation":"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.","triggerScenarios":"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.","commonSituations":"Calling make_attention directly from custom code without converting the config string first; duplicated enum definitions across copied lightricks modules.","solutions":["Convert the config value with AttentionType(value) before calling make_attention","Pass the enum member directly: AttentionType.VANILLA, AttentionType.NONE, or AttentionType.LINEAR","Import AttentionType from comfy/ldm/lightricks/vae/causal_audio_autoencoder.py so only one enum class is in play"],"exampleFix":"# before\nattn = make_attention(ch, attn_type=\"vanilla\")\n\n# after\nattn = make_attention(ch, attn_type=AttentionType.VANILLA)","handlingStrategy":"type-guard","validationCode":"assert isinstance(attn_type, AttentionType), f\"expected AttentionType, got {type(attn_type).__name__}\"","typeGuard":"def is_attention_type(v) -> bool:\n    return isinstance(v, AttentionType)","tryCatchPattern":null,"preventionTips":["Convert strings with AttentionType(value) before calling make_attention","Use a single imported AttentionType class everywhere"],"tags":["attention","enum","audio-vae"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}