huggingface/transformers · error · NotImplementedError

AutoHfExporter.from_pretrained is not implemented yet. Load/

Error message

AutoHfExporter.from_pretrained is not implemented yet. Load/export configs explicitly and call AutoHfExporter.from_config(...) instead.

What it means

AutoHfExporter.from_pretrained is declared (with a docstring advertising loading an exporter from a checkpoint that ships an export config) but its body unconditionally raises NotImplementedError. The library does not yet auto-discover export configs on the hub, so you must build the config yourself and call AutoHfExporter.from_config().

Source

Thrown at src/transformers/exporters/auto.py:117

        owner has already validated for their architecture — the target format (``dynamo`` /
        ``onnx`` / ``executorch``), exact dynamic-shape specs (e.g. ``text_ids`` dynamic to 4096,
        image tiles fixed at 448, ``batch=1`` for edge deployment), ``strict`` flag, ONNX opset,
        prefill vs. decode layout, ExecuTorch backend choice, and any other knob that today lives
        as tribal knowledge in a README or a private notebook.

        Consumers then get the owner-validated export in one call::

            exporter = AutoHfExporter.from_pretrained("org/model-name")
            program = exporter.export(model, inputs)

        Composes with the [`register_export_input_preparer`] registry: the owner supplies the
        shape spec via ``export_config.json``, transformers supplies the data-dependent
        precomputations (``cu_seqlens``, vision position ids, window indices, …) for that
        architecture. Together they cover the two hard parts of exporting new models — knowing
        the right shape contract and preparing the right inputs — so downstream users don't
        re-derive either from scratch (and don't break in production when they get it wrong).
        """
        raise NotImplementedError(
            "AutoHfExporter.from_pretrained is not implemented yet. "
            "Load/export configs explicitly and call AutoHfExporter.from_config(...) instead."
        )

    @staticmethod
    def supports_export_format(export_config_dict: dict) -> bool:
        """Return True if the provided dict describes an ``export_format`` that has both a
        registered config class and a registered exporter class. Warns with an actionable message
        when the format is missing entirely, unknown, or only half-registered."""
        export_fmt = export_config_dict.get("export_format")
        if export_fmt is None:
            logger.warning(
                "No 'export_format' key in export config — supported values are: "
                f"{sorted(AUTO_EXPORTER_MAPPING)}. Skipping."
            )
            return False

        name = export_fmt.value if isinstance(export_fmt, ExportFormat) else export_fmt

View on GitHub (pinned to a597f97485)

Solutions

  1. Load or construct the export config explicitly and use AutoHfExporter.from_config(config) instead.
  2. For a JSON file, do cfg = AutoExportConfig.from_dict(json.load(open("export_config.json"))) then AutoHfExporter.from_config(cfg).
  3. Track the transformers changelog — from_pretrained is planned but unimplemented at this version.

Example fix

# before
exporter = AutoHfExporter.from_pretrained("org/model-name")  # NotImplementedError

# after
from transformers.exporters import AutoExportConfig, AutoHfExporter
cfg = AutoExportConfig.from_dict({"export_format": "onnx", "output_path": "model.onnx"})
exporter = AutoHfExporter.from_config(cfg)
Defensive patterns

Strategy: validation

Validate before calling

from transformers.exporters import AutoExportConfig, AutoHfExporter

# from_pretrained is a stub; build the config explicitly instead
cfg = AutoExportConfig.from_dict({"export_format": "onnx"})
exporter = AutoHfExporter.from_config(cfg)

Try / catch

try:
    exporter = AutoHfExporter.from_pretrained(repo_id)
except NotImplementedError:
    cfg = AutoExportConfig.from_dict({"export_format": "onnx"})
    exporter = AutoHfExporter.from_config(cfg)

Prevention

When it happens

Trigger: Calling AutoHfExporter.from_pretrained("org/model-name") — always raises, regardless of arguments.

Common situations: Reading the class docstring or an example and assuming the one-call API works today; copy-pasting sample code from the from_pretrained docstring; exploring the API surface via dir()/autocomplete.

Related errors


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