{"record":{"id":"ea81f5891fe3b52f","repo":"huggingface/transformers","slug":"decompose-multimodal-failed-for-type-model-nam","errorCode":null,"errorMessage":"decompose_multimodal failed for {type(model).__name__}. Inputs passed: {list(inputs.keys())}.","messagePattern":"decompose_multimodal failed for (.+?)\\. Inputs passed: (.+?)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/transformers/exporters/utils.py","lineNumber":883,"sourceCode":"\n    Raises:\n        `ValueError`: if no known multi-modal submodules are found on the model.\n    \"\"\"\n    submodules = _find_multimodal_submodules(model)\n    if not submodules:\n        raise ValueError(\n            f\"decompose_multimodal found no multi-modal submodules on {type(model).__name__}. \"\n            f\"Expected an image/audio encoder + language model, found neither.\"\n        )\n\n    try:\n        with contextlib.ExitStack() as stack, torch.no_grad():\n            submodule_inputs = {\n                name: stack.enter_context(_capture_forward(module)) for name, module in submodules.items()\n            }\n            model(**copy.deepcopy(inputs))\n    except Exception as e:\n        raise RuntimeError(\n            f\"decompose_multimodal failed for {type(model).__name__}. Inputs passed: {list(inputs.keys())}.\"\n        ) from e\n\n    return {\n        name: (module, submodule_inputs[name][-1])\n        for name, module in submodules.items()\n        if submodule_inputs[name]  # skip submodules not called (e.g. lm_head on base models)\n    }\n\n\ndef decompose_for_generation(\n    model: PreTrainedModel, inputs: dict[str, Any], generation_config: Any = None, multi_token_decode: bool = False\n) -> dict[str, tuple[torch.nn.Module, dict]]:\n    \"\"\"Decompose a generative model into independently exportable `(model, forward_inputs)` pairs.\n\n    Runs `decompose_prefill_decode` to capture prefill and decode forward kwargs from a real\n    `model.generate(**inputs, max_new_tokens=2)`. If the prefill is multi-modal (per `is_multimodal`),\n    further splits it into one entry per submodule (vision/audio encoder, projector, language model,","sourceCodeStart":865,"sourceCodeEnd":901,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/exporters/utils.py#L865-L901","documentation":"After multimodal submodules are found, decompose_multimodal runs a full model(**inputs) pass with forward-capture hooks attached to each submodule. If that forward pass raises for any reason (bad inputs, device/dtype mismatch, hook incompatibility), the utility wraps it in this RuntimeError naming the model class and input keys. The root cause is preserved as __cause__.","triggerScenarios":"Calling the multimodal export decomposition with inputs the full model rejects: missing modality inputs (no pixel_values/audio), wrong shapes, numpy instead of tensors, or CPU/GPU device mismatches.","commonSituations":"Export scripts feeding only the text branch to a VLM; raw unprocessed media passed instead of processor outputs; models with forward-time validation that fires on dummy inputs.","solutions":["Call model(**inputs) directly (outside export) and inspect the chained exception to find the real failure","Supply complete inputs for every modality via the model's processor (images/audio + text)","Ensure tensors have the expected dtype/device and required keys are present","Re-run the decomposition once the plain forward works"],"exampleFix":"// before\ndecompose_multimodal(vlm, {\"input_ids\": ids})\n\n// after\nbatch = processor(images=imgs, text=prompts, return_tensors=\"pt\")\ndecompose_multimodal(vlm, batch)","handlingStrategy":"try-catch","validationCode":"def forward_ok(model, inputs) -> bool:\n    try:\n        with torch.no_grad():\n            model(**inputs)\n        return True\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    decompose_multimodal(model, inputs)\nexcept RuntimeError as e:\n    raise RuntimeError(f\"multimodal decomposition failed: {e.__cause__!r}\") from e.__cause__","preventionTips":["Run one plain forward with the exact export inputs first","Provide inputs for every modality via the processor","Keep dtype/device uniform between inputs and model"],"tags":["export","multimodal","inputs","transformers"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}