{"record":{"id":"7acf15717e3a693b","repo":"huggingface/transformers","slug":"type-self-name-export-failed-on-component","errorCode":null,"errorMessage":"{type(self).__name__}.export failed on component '{name}' (submodel={type(submodel).__name__}, input keys={list(subinputs)}).","messagePattern":"(.+?)\\.export failed on component '(.+?)' \\(submodel=(.+?), input keys=(.+?)\\)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/transformers/exporters/base.py","lineNumber":200,"sourceCode":"        )\n\n        if isinstance(config, dict):\n            missing = set(components) - set(config)\n            if missing:\n                raise ValueError(\n                    f\"Per-component `config` dict is missing entries for: {sorted(missing)}. \"\n                    f\"Expected one entry per component: {sorted(components)}.\"\n                )\n            configs = config\n        else:\n            configs = dict.fromkeys(components, config)\n\n        exported: dict[str, object] = {}\n        for name, (submodel, subinputs) in components.items():\n            try:\n                exported[name] = self.export(submodel, subinputs, config=configs[name])\n            except Exception as e:\n                raise RuntimeError(\n                    f\"{type(self).__name__}.export failed on component '{name}' \"\n                    f\"(submodel={type(submodel).__name__}, input keys={list(subinputs)}).\"\n                ) from e\n\n        return exported\n","sourceCodeStart":182,"sourceCodeEnd":206,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/exporters/base.py#L182-L206","documentation":"A wrapping RuntimeError raised by export_for_generation when self.export() raises for any decomposed component. It preserves the original exception via `from e` (accessible as __cause__) and enriches it with the component name, the submodel class, and the submodel's input keys — the context you need to tell a prefill-stage shape problem from a decode-stage cache problem.","triggerScenarios":"Any underlying failure (tracing error, unsupported op, dtype mismatch, shape guard) inside one component's export during export_for_generation; typically only the decode component fails because its inputs include past_key_values/cache_position.","commonSituations":"Exports that succeed for full-sequence forward but fail on the decode step (cache objects, symbolic shapes); ops untraceable by dynamo inside one stage; wrong sample_inputs for one stage.","solutions":["Inspect exc.__cause__ — the real traceback and error live there, not in the wrapper message.","Reproduce the failing component standalone: take the submodel class and input keys from the message and call exporter.export on that stage directly.","Fix the root cause in the submodel/inputs (e.g. provide proper past_key_values and cache_position for decode, mark dynamic axes explicitly).","If per-stage isolation is hard, export the undecomposed model with plain export() first to bisect."],"exampleFix":"# before\ntry:\n    exporter.export_for_generation(model, inputs, config=cfg)\nexcept RuntimeError as e:\n    print(e)  # only the wrapper — root cause hidden\n\n# after\ntry:\n    exporter.export_for_generation(model, inputs, config=cfg)\nexcept RuntimeError as e:\n    raise e.__cause__ or e  # surfaces the real tracing error with its traceback","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    exported = exporter.export_for_generation(model, inputs, config=cfg)\nexcept RuntimeError as e:\n    cause = e.__cause__\n    if cause is not None:\n        logging.exception(\"component export failed\", exc_info=cause)\n    raise","preventionTips":["Always inspect __cause__ — the wrapper message alone hides the root error","Export each generation stage standalone first to localize failures","Ensure decode-stage sample_inputs include past_key_values and cache_position"],"tags":["export","generation","wrapper-exception","debugging"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}