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
- 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.
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
- 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
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
- Per-component `config` dict is missing entries for: {sorted(
- decompose_prefill_decode failed for {type(model).__name__}.
- decompose_prefill_decode expected at least {num_new_tokens}
- `crop` was called, but the current layer does not track past
- Once the sliding window size has been reached, `DynamicSlidi
AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14).
Data as JSON: /api/errors/7acf15717e3a693b.
Report an issue: GitHub.