OnnxBackendConfig#

class openstef_foundation_models.presets.OnnxBackendConfig(**data: Any) None[source]#

Bases: BaseConfig

Compute configuration for an ONNX Runtime inference backend.

Holds only how to run the model (execution providers, session options), not which weights: the checkpoint is supplied to build() by the caller, so the same compute settings can run different checkpoints.

Parameters:

data (Any)

kind: Literal['onnx']#

Discriminator tag for backend type.

providers: list[Annotated[CpuProvider | CudaProvider | TensorRTProvider | CoreMLProvider, FieldInfo(annotation=NoneType, required=True, discriminator='kind')]] | None#

Ordered execution providers to try. ``None`` lets :attr:`policy` pick a host-appropriate chain from the checkpoint metadata (graceful). An explicit list is used exactly as given (strict: a missing accelerator raises).

policy: DefaultProviderPolicy#

Selection policy used when :attr:`providers` is None. Maps the checkpoint’s precision and static-shape-ness plus the host to an ordered provider chain. Replace it (e.g. a subclass overriding select) to target hardware the default does not cover.

session_options: SessionOptionsConfig | None#

Optional ONNX Runtime session options.

build(checkpoint: Annotated[LocalCheckpoint | HubCheckpoint, FieldInfo(annotation=NoneType, required=True, discriminator='kind')]) InferenceBackend[source]#

Resolve checkpoint and build the ONNX Runtime backend.

Importing the backend raises MissingExtraError if ONNX Runtime is not installed.

Parameters:
  • checkpoint (LocalCheckpoint | HubCheckpoint) – The checkpoint (weights + metadata) to load and run.

  • checkpoint

Returns:

A ready-to-run backend wrapping the resolved checkpoint.

Return type:

InferenceBackend

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'protected_namespaces': ()}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].