{"record":{"id":"0a5d03cb40bcf005","repo":"Comfy-Org/ComfyUI","slug":"error-audio-encoder-file-is-invalid-or-unsupporte","errorCode":null,"errorMessage":"ERROR: audio encoder file is invalid or unsupported embed_dim: {}","messagePattern":"ERROR: audio encoder file is invalid or unsupported embed_dim: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"comfy/audio_encoders/audio_encoders.py","lineNumber":76,"sourceCode":"                \"num_layers\": 24,\n                \"conv_norm\": True,\n                \"conv_bias\": True,\n                \"do_normalize\": True,\n                \"do_stable_layer_norm\": True\n                }\n        elif embed_dim == 768: # base\n            config = {\n                \"model_type\": \"wav2vec2\",\n                \"embed_dim\": 768,\n                \"num_heads\": 12,\n                \"num_layers\": 12,\n                \"conv_norm\": False,\n                \"conv_bias\": False,\n                \"do_normalize\": False, # chinese-wav2vec2-base has this False\n                \"do_stable_layer_norm\": False\n            }\n        else:\n            raise RuntimeError(\"ERROR: audio encoder file is invalid or unsupported embed_dim: {}\".format(embed_dim))\n    elif \"model.encoder.embed_positions.weight\" in sd:\n        sd = comfy.utils.state_dict_prefix_replace(sd, {\"model.\": \"\"})\n        config = {\n            \"model_type\": \"whisper3\",\n        }\n    else:\n        raise RuntimeError(\"ERROR: audio encoder not supported.\")\n\n    audio_encoder = AudioEncoderModel(config)\n    m, u = audio_encoder.load_sd(sd)\n    if len(m) > 0:\n        logging.warning(\"missing audio encoder: {}\".format(m))\n    if len(u) > 0:\n        logging.warning(\"unexpected audio encoder: {}\".format(u))\n\n    return audio_encoder\n","sourceCodeStart":58,"sourceCodeEnd":93,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/audio_encoders/audio_encoders.py#L58-L93","documentation":"load_audio_encoder detects wav2vec2-family checkpoints by state-dict keys and then switches on the encoder's embed_dim (e.g. 1024 for large, 768 for base). Any other embed_dim has no known config, so it raises RuntimeError rather than guessing an architecture and producing garbage. The file is treated as invalid-or-unsupported for this code path.","triggerScenarios":"Loading a wav2vec2 checkpoint with an unusual hidden size (small/large variants fine-tuned with a projection, e.g. 1024-projected or custom distills); a partially exported or re-saved checkpoint; a non-wav2vec2 file whose keys happen to match the wav2vec2 signature.","commonSituations":"Using a community fine-tune with modified projection layers; loading a HuBERT/Data2Vec-ish checkpoint with overlapping key names; wrong file downloaded (half-converted safetensors).","solutions":["Use one of the supported checkpoints (wav2vec2-large or base-family encoders, e.g. the ones referenced by ComfyUI audio nodes).","Re-download the model in case of corruption, and verify it loads in transformers with AutoModel.","If it is a custom fine-tune, export with the original architecture dims or patch load_audio_encoder locally to add a config for your embed_dim."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"sd = comfy.utils.load_torch_file(path)\nkey = \"model.encoder.layers.0.self_attn.q_proj.weight\"  # adjust per checkpoint\nembed_dim = sd[key].shape[0] if key in sd else None\nif key in sd and embed_dim not in (768, 1024):\n    raise SystemExit(f\"unsupported embed_dim {embed_dim}; use a supported wav2vec2 checkpoint\")","typeGuard":"def is_supported_embed_dim(sd: dict) -> bool:\n    for k, v in sd.items():\n        if k.endswith(\"self_attn.q_proj.weight\"):\n            return v.shape[0] in (768, 1024)\n    return False","tryCatchPattern":"try:\n    enc = load_audio_encoder(sd)\nexcept RuntimeError as e:\n    if \"embed_dim\" in str(e):\n        raise SystemExit(\"Use a supported wav2vec2 base/large encoder checkpoint\")\n    raise","preventionTips":["Stick to the encoder checkpoints referenced by the audio nodes.","Verify fine-tunes keep the original hidden size before exporting."],"tags":["audio","model-loading","wav2vec2"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}