huggingface/transformers · error · RuntimeError

{type(self).__name__}.export failed on component '{name}' (s

Error message

{type(self).__name__}.export failed on component '{name}' (submodel={type(submodel).__name__}, input keys={list(subinputs)}).

What it means

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.

Source

Thrown at src/transformers/exporters/base.py:200

        )

        if isinstance(config, dict):
            missing = set(components) - set(config)
            if missing:
                raise ValueError(
                    f"Per-component `config` dict is missing entries for: {sorted(missing)}. "
                    f"Expected one entry per component: {sorted(components)}."
                )
            configs = config
        else:
            configs = dict.fromkeys(components, config)

        exported: dict[str, object] = {}
        for name, (submodel, subinputs) in components.items():
            try:
                exported[name] = self.export(submodel, subinputs, config=configs[name])
            except Exception as e:
                raise RuntimeError(
                    f"{type(self).__name__}.export failed on component '{name}' "
                    f"(submodel={type(submodel).__name__}, input keys={list(subinputs)})."
                ) from e

        return exported

View on GitHub (pinned to a597f97485)

Solutions

  1. Inspect exc.__cause__ — the real traceback and error live there, not in the wrapper message.
  2. Reproduce the failing component standalone: take the submodel class and input keys from the message and call exporter.export on that stage directly.
  3. Fix the root cause in the submodel/inputs (e.g. provide proper past_key_values and cache_position for decode, mark dynamic axes explicitly).
  4. If per-stage isolation is hard, export the undecomposed model with plain export() first to bisect.

Example fix

# before
try:
    exporter.export_for_generation(model, inputs, config=cfg)
except RuntimeError as e:
    print(e)  # only the wrapper — root cause hidden

# after
try:
    exporter.export_for_generation(model, inputs, config=cfg)
except RuntimeError as e:
    raise e.__cause__ or e  # surfaces the real tracing error with its traceback
Defensive patterns

Strategy: try-catch

Try / catch

try:
    exported = exporter.export_for_generation(model, inputs, config=cfg)
except RuntimeError as e:
    cause = e.__cause__
    if cause is not None:
        logging.exception("component export failed", exc_info=cause)
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14). Data as JSON: /api/errors/7acf15717e3a693b. Report an issue: GitHub.