huggingface/transformers · error · ValueError
Per-component `config` dict is missing entries for
Error message
Per-component `config` dict is missing entries for: {sorted(missing)}. Expected one entry per component: {sorted(components)}. What it means
HfExporter.export_for_generation decomposes the model into named components (e.g. prefill/decode stages) via decompose_for_generation. When you pass config as a dict, it must contain exactly one entry per component name; this ValueError fires when components exist that have no key in your dict, and the message lists both the missing names and the full expected key set.
Solutions
- Add the missing keys listed in the message — the expected key set is printed verbatim.
- If all stages should share one config, pass the config object itself (not a dict); it is broadcast to every component.
- Log the components once (inspect the message of a deliberate run, or decompose_for_generation) and template your dict from that.
Example fix
# before
exporter.export_for_generation(model, inputs, config={"prefill": onnx_cfg}) # missing 'decode'
# after (per-component)
exporter.export_for_generation(model, inputs, config={"prefill": onnx_cfg, "decode": onnx_cfg})
# after (shared config — simplest)
exporter.export_for_generation(model, inputs, config=onnx_cfg) Defensive patterns
Strategy: try-catch
Validate before calling
# Components are model/config dependent; safest pre-check is a dry-run or sharing one config. # If you must pass a dict, share the same config object for all stages instead: exporter.export_for_generation(model, inputs, config=single_cfg) # broadcast, cannot hit this error
Try / catch
try:
out = exporter.export_for_generation(model, inputs, config=configs)
except ValueError as e:
if "missing entries for" in str(e):
missing = ast.literal_eval(str(e).split("missing entries for:")[1].split(".")[0])
configs.update({name: default_cfg for name in missing})
out = exporter.export_for_generation(model, inputs, config=configs)
else:
raise Prevention
- Default to passing a single config object (broadcast) unless stages truly differ
- When passing per-stage dicts, regenerate them after upgrading transformers — component sets change
- Pin the transformers version in export pipelines
When it happens
Trigger: Calling export_for_generation(model, inputs, config={"prefill": cfg}) when decomposition produces {"prefill", "decode"}; passing stage names that don't match (e.g. 'forward' vs 'prefill'); multi_token_decode=True yielding more components than your dict covers.
Common situations: Upgrading transformers where the component set for a model changed (new decode stages); enabling multi-token decode and reusing an old two-entry config dict; hand-writing per-stage configs from an outdated example.
Related errors
- export_config_dict must contain key 'export_format' set to…
- Unknown exporter type, got
- `axis_key` for `HQQ` backend has to be one of [`0`, `1`]…
- `axis_key` for `quanto` backend has to be one of [`0`…
- `axis_value` for `quanto` backend has to be one of [`0`…
AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14).
Data as JSON: /api/errors/4f5696a76c63dfa2.
Report an issue: GitHub.
Appendix: source
Thrown at src/transformers/exporters/base.py:187
stays dynamic under a dynamic-shape export (`config.dynamic=True`).
Returns:
`dict[str, Any]`: `{component_name: backend_specific_artifact}` — same keys as
[`~exporters.utils.decompose_for_generation`]. Values are whatever
[`~HfExporter.export`] returns for the concrete backend (`ExportedProgram`,
`ONNXProgram`, `ExecutorchProgramManager`).
"""
components = decompose_for_generation(
model,
sample_inputs,
generation_config=generation_config,
multi_token_decode=multi_token_decode,
)
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 exportedView on GitHub (pinned to a597f97485)