{"record":{"id":"5af45f08ccef79fa","repo":"huggingface/transformers","slug":"type-self-name-does-not-implement-export","errorCode":null,"errorMessage":"{type(self).__name__} does not implement `export`. Pick a concrete exporter (`DynamoExporter`, `OnnxExporter`, `ExecutorchExporter`), or override `export` in your subclass with a backend-specific tracing pipeline that consumes `config` and returns the runtime artifact.","messagePattern":"(.+?) does not implement `export`\\. Pick a concrete exporter \\(`DynamoExporter`, `OnnxExporter`, `ExecutorchExporter`\\), or override `export` in your subclass with a backend-specific tracing pipeline that consumes `config` and returns the runtime artifact\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"src/transformers/exporters/base.py","lineNumber":126,"sourceCode":"        \"\"\"\n        Export the model and return the backend-specific program object.\n\n        Args:\n            model ([`PreTrainedModel`]):\n                The model to export.\n            sample_inputs (`dict[str, torch.Tensor | Cache]`):\n                **Forward** kwargs — what you'd pass to `model(**sample_inputs)`. These are used\n                directly as the example inputs during tracing. For an autoregressive decode-step\n                export, this means you need to include `past_key_values`, `cache_position`, etc.\n                If you only have generation-style inputs, use [`~HfExporter.export_for_generation`]\n                instead — it runs `model.generate` for you and exports each stage.\n            config ([`~transformers.exporters.configs.ExportConfigMixin`]):\n                Backend-specific configuration.\n\n        Returns:\n            Backend-specific export artifact.\n        \"\"\"\n        raise NotImplementedError(\n            f\"{type(self).__name__} does not implement `export`. Pick a concrete exporter \"\n            \"(`DynamoExporter`, `OnnxExporter`, `ExecutorchExporter`), or override `export` \"\n            \"in your subclass with a backend-specific tracing pipeline that consumes `config` \"\n            \"and returns the runtime artifact.\"\n        )\n\n    def export_for_generation(\n        self,\n        model: PreTrainedModel,\n        sample_inputs: MutableMapping[str, torch.Tensor | Cache],\n        config: ExportConfigMixin | dict[str, ExportConfigMixin],\n        generation_config: GenerationConfig | None = None,\n        multi_token_decode: bool = False,\n    ) -> dict[str, object]:\n        \"\"\"\n        Decompose a generative model and export each component independently.\n\n        Thin wrapper around [`~exporters.utils.decompose_for_generation`] that calls","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/exporters/base.py#L108-L144","documentation":"The base HfExporter.export is an abstract stub that always raises NotImplementedError with guidance text. It fires when export() is invoked on the base class or on a subclass that overrode export_for_generation but not export. The message names the concrete exporters to use (DynamoExporter, OnnxExporter, ExecutorchExporter) or tells you to implement a backend-specific tracing pipeline.","triggerScenarios":"Instantiating HfExporter() directly (the @abstractmethod is not enforced at construction in all Python versions/setups) and calling .export(); subclassing HfExporter for a custom backend without overriding export(); calling export on a partially-built custom exporter.","commonSituations":"Writing a custom backend plugin and forgetting the export method; refactoring a subclass and dropping the override; mistaking the base class for a dispatcher that picks a backend automatically.","solutions":["Use a concrete exporter: DynamoExporter(), OnnxExporter(), or ExecutorchExporter().","In a custom subclass, override export(self, model, sample_inputs, config) with your tracing pipeline that returns the runtime artifact.","If you wanted auto-dispatch by config, go through AutoHfExporter.from_config(config).export(...)."],"exampleFix":"# before\nHfExporter().export(model, inputs, OnnxConfig())  # NotImplementedError\n\n# after\nfrom transformers.exporters.exporter_onnx import OnnxExporter\nOnnxExporter().export(model, inputs, OnnxConfig())","handlingStrategy":"validation","validationCode":"from transformers.exporters.base import HfExporter\n\nassert type(exporter) is not HfExporter, \"use a concrete exporter: Dynamo/Onnx/Executorch\"\nassert type(exporter).export is not HfExporter.export, \"subclass must override export()\"\nexporter.export(model, inputs, cfg)","typeGuard":"def is_concrete_exporter(obj) -> bool:\n    from transformers.exporters.base import HfExporter\n    return isinstance(obj, HfExporter) and type(obj).export is not HfExporter.export","tryCatchPattern":"try:\n    exporter.export(model, inputs, cfg)\nexcept NotImplementedError as e:\n    if \"does not implement `export`\" in str(e):\n        exporter = AutoHfExporter.from_config(cfg)  # dispatch to the right concrete exporter\n    else:\n        raise","preventionTips":["Never instantiate HfExporter directly; construct the backend-specific class","In custom exporter plugins, define export() before anything else and keep a test that calls it"],"tags":["export","not-implemented","abstract-method","plugin"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}