CoreMLProvider#

class openstef_foundation_models.inference.CoreMLProvider(**data: Any) None[source]#

Bases: BaseConfig

The CoreML execution provider (Apple, GPU/Neural Engine).

ModelFormat=MLProgram is required for modern CoreML: the legacy NeuralNetwork format fragments the graph and silently falls back to CPU for many ops.

Parameters:

data (Any)

kind: Literal['coreml']#

Discriminator tag for execution-provider type.

model_format: Literal['MLProgram', 'NeuralNetwork']#

CoreML model format. MLProgram is required for modern op coverage.

compute_units: Literal['CPUOnly', 'CPUAndGPU', 'CPUAndNeuralEngine', 'ALL']#

Which compute units CoreML may dispatch to. Prefer ‘CPUAndGPU’ for large transformer graphs: allowing the Neural Engine (‘ALL’/’CPUAndNeuralEngine’) can make CoreML’s ahead-of-time compile run for many minutes for no inference win.

cache_dir: Path | None#

Directory for CoreML’s compiled-model cache (ORT ‘ModelCacheDirectory’). CoreML compiles the graph ahead of time on session build, which is slow; caching it cuts a warm rebuild from tens of seconds to a few. The cache is ORT-version/OS/hardware-specific — a local speedup, not a portable artifact. Requires ‘MLProgram’ format.

to_ort() OrtProvider[source]#

Compile to an ONNX Runtime provider tuple.

Return type:

tuple[str, dict[str, object]]

Returns:

The CoreMLExecutionProvider with format, compute-unit and (optional) cache options.

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