Skip to content

Local engine

Mimir runs the ONNX graph on your machine. Create one with from_pretrained, which downloads the release at the revision this package version pins, verifies the manifest's Sigstore signature and every file's SHA-256, checks the graph against its contract, and loads it — or raises ArtifactError before anything is read. Safe to share across threads. Needs mimir-decisions[local] (CPU) or mimir-decisions[local-gpu] (CUDA); the two install the same onnxruntime module, so keep one of them.

Argument Default Does
model Mythologic/MIMIR-1 a Hub id or a local release directory
revision the pinned revision a Hub revision
device auto cpu, cuda, or CUDA when available
variant the variant listed for the device fp32 (CPU) or fp16 (CUDA)
policy the release policy path to a custom policy JSON from mimir calibrate
cache_dir the Hub cache where the model is stored
offline False load only from the cache, with no network access
allow_unsigned False load a local directory that has no signature

info() reports the model, revision, variant, runtime fingerprint, certified risk levels and input limits. count_tokens(context, spec) sizes a request before sending it; a request over a limit raises InputLimitError naming the value and the limit.

mimir.runtime.engine.Mimir

Bases: Decider

Local MIMIR engine. Create one with Mimir.from_pretrained.

Safe to share across threads.

policy property

policy: Policy | None

The loaded policy, or None.

runtime property

runtime: LoadedRuntime

The loaded graph and runtime, as policy fingerprints describe them.

snapshot property

snapshot: Snapshot

The verified release.

from_pretrained classmethod

from_pretrained(
    model: str = DEFAULT_MODEL,
    *,
    revision: str | None = None,
    device: str = "auto",
    variant: str | None = None,
    policy: str | Path | None = None,
    cache_dir: str | Path | None = None,
    allow_unsigned: bool = False,
    verifier: ManifestVerifier | None = None,
    offline: bool = False,
) -> Mimir

Download, verify and load a release.

Parameters:

Name Type Description Default
model str

Hub repository id or local directory.

DEFAULT_MODEL
revision str | None

Hub revision; defaults to the revision pinned by this package version.

None
device str

auto, cpu or cuda.

'auto'
variant str | None

Graph variant; defaults to the variant listed for the device.

None
policy str | Path | None

Path to a custom policy JSON from mimir calibrate (its .npz alongside).

None
cache_dir str | Path | None

Hub cache directory.

None
allow_unsigned bool

Load a local directory that has no manifest signature.

False
verifier ManifestVerifier | None

Manifest signature verifier; defaults to Sigstore with the release identity.

None
offline bool

Load only from cache_dir, with no network access.

False

Raises:

Type Description
ArtifactError

download, signature, integrity or graph contract failure.

UncertifiedRuntimeError

the runtime does not match the policy's certification.

EquivalenceError

the equivalence check failed on unlisted hardware.

assess_many

assess_many(
    items: Items,
    *,
    alpha: float | None = None,
    batch_size: int | None = None,
) -> list[Evaluation]

Return results with their policy assessments, as mimir calibrate needs.

Assessments are computed at the loaded policy's first risk level; their calibrated scores, decisions and gate outcomes do not depend on the risk level.

count_tokens

count_tokens(
    context: ContextLike, spec: DecisionSpec
) -> int

Return the encoder tokens a request uses, before batch padding.