OnnxBackendConfig#

class openstef_foundation_models.presets.OnnxBackendConfig(*, kind: Literal['onnx'] = 'onnx', providers: list[CpuProvider | CudaProvider | TensorRTProvider | CoreMLProvider] | None = None, policy: DefaultProviderPolicy = DefaultProviderPolicy(kind='default'), session_options: SessionOptionsConfig | None = 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:
kind: Literal['onnx']#

Discriminator tag for backend type.

providers: list[CpuProvider | CudaProvider | TensorRTProvider | CoreMLProvider] | 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: LocalCheckpoint | HubCheckpoint) → 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.

Return type:

InferenceBackend

Returns:

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

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].