{"record":{"id":"67ebfb3ed938ad4a","repo":"huggingface/transformers","slug":"the-audio-source-is-a-filetype-file-which-lib","errorCode":null,"errorMessage":"The audio source is a '{filetype}' file, which librosa cannot decode. {_NEEDS_TORCHCODEC}","messagePattern":"The audio source is a '(.+?)' file, which librosa cannot decode\\. (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/transformers/audio_utils.py","lineNumber":245,"sourceCode":"        )\n\n    # torchcodec handles audio/video; librosa only plain audio. `backend` lets callers pin one.\n    if backend == \"auto\":\n        resolved_backend = (\n            \"torchcodec\" if is_torchcodec_available() and version.parse(\"0.3.0\") <= TORCHCODEC_VERSION else \"librosa\"\n        )\n    elif backend in (\"torchcodec\", \"librosa\", \"torchaudio\"):\n        resolved_backend = backend\n    else:\n        raise ValueError(f\"Unknown backend {backend!r}; expected 'auto', 'torchcodec', 'librosa', or 'torchaudio'.\")\n    # soundfile-based backends (librosa / torchaudio) cannot decode the video-ish formats below.\n    use_torchcodec = resolved_backend == \"torchcodec\"\n\n    # 1. Identify the format from the source string (extension / `data:` media type), without fetching.\n    filetype = _format_from_source(audio)\n    # 2. With librosa as the only backend, fail fast and clearly on a format it cannot decode.\n    if not use_torchcodec and filetype in TORCHCODEC_ONLY_FILETYPES:\n        raise RuntimeError(\n            f\"The audio source is a '{filetype}' file, which librosa cannot decode. {_NEEDS_TORCHCODEC}\"\n        )\n\n    # 3. Resolve to local path or bytes; sniff format for raw base64 payloads before passing to librosa.\n    source = _resolve_audio_source(audio, timeout=timeout)\n    if not use_torchcodec and filetype is None and isinstance(source, bytes):\n        try:\n            filetype = get_audio_filetype(source)\n        except ValueError:\n            filetype = None\n        if filetype in TORCHCODEC_ONLY_FILETYPES:\n            raise RuntimeError(\n                f\"The audio source is a '{filetype}' file, which librosa cannot decode. {_NEEDS_TORCHCODEC}\"\n            )\n\n    # 4. Decode with the selected backend (`requires_backends` raises a clear error if it is missing).\n    if use_torchcodec:\n        requires_backends(load_audio, [\"torchcodec\"])","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/audio_utils.py#L227-L263","documentation":"The Mega MoE forward is a Blackwell FP4-only fused path: it requires expert weights packed as FP4 stored in int8 (`gate_up_proj.dtype == torch.int8`). A non-int8 dtype means the checkpoint is not NVFP4-quantized (misconfigured or an FP8 checkpoint), so it raises `NotImplementedError` pointing you at the regular 'deepgemm' dispatch for FP8 experts. The `_assert_sm100_requirements` call just before doubles as the SM100 gate since Mega MoE weights are always FP4.","triggerScenarios":"Running `experts_implementation='deepgemm_megamoe'` on an FP8-quantized model (weights float8_e4m3fn) or an unquantized bf16 model, instead of an NVFP4 checkpoint.","commonSituations":"Copy-pasting the megamoe dispatch flag from a B200 FP4 recipe onto an FP8 DeepSeek model; config-driven scripts that set experts_implementation globally across a fleet of differently-quantized models.","solutions":["Use an NVFP4-quantized checkpoint (int8-packed weights) with `deepgemm_megamoe` on SM100+","For FP8 experts, use `set_experts_implementation('deepgemm')` as the message suggests","Fix config scripts so experts_implementation is chosen per checkpoint quantization format"],"exampleFix":"# before\n# FP8 checkpoint\nmodel.set_experts_implementation(\"deepgemm_megamoe\")  # -> NotImplementedError\n\n# after\nmodel.set_experts_implementation(\"deepgemm\")  # FP8 experts on SM100\n# or run an NVFP4 checkpoint with \"deepgemm_megamoe\"","handlingStrategy":"validation","validationCode":"gate_w = next(m.parameters() for n, m in model.named_modules() if \"gate_up_proj\" in n)\nif gate_w.dtype != torch.int8:  # not NVFP4-packed\n    impl = \"deepgemm\" if gate_w.dtype == torch.float8_e4m3fn else \"grouped_mm\"\n    # set impl accordingly; megamoe is FP4-only","typeGuard":"def is_fp4_packed(t: torch.Tensor) -> bool:\n    return t.dtype == torch.int8","tryCatchPattern":"try:\n    out = model(input_ids)\nexcept NotImplementedError as e:\n    if \"FP4-packed expert weights\" in str(e):\n        model.set_experts_implementation(\"deepgemm\")\n        out = model(input_ids)\n    else:\n        raise","preventionTips":["Choose experts_implementation from the checkpoint's quantization format, not a global default","Reserve deepgemm_megamoe for NVFP4 checkpoints on SM100+"],"tags":["deepgemm","megamoe","fp4","checkpoint-config","moe"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}