Mojo · Design

Design

from uform import Library 4.0.0-rc.1 · 3ee5e534

Blocking stays simple: a verb on the model or on model.on(executor) reads as it would if asynchrony did not exist. Deferred calls are symmetric, the same verbs on another receiver, observed only through the outcome’s status word, and release rides Mojo’s own destructor. Nothing costs anything until used: the binding starts no threads, keeps no counts and caches nothing, so a call is one argument structure built on the stack and one indirect call.

API

StructLibraryA reference to the loaded engine, cheap to copy and shared by everything it creates.25
struct Library

Every handle carries one, which is what keeps the shared object mapped for as long as anything can still call into it. It is a loader reference and nothing more: an executor never retains a model, and a model never retains an executor.

Fields

sharedArcPointer[_Loaded]The handle and its symbols, refcounted so the last holder unmaps the object.

Conforms to

Copyable, Deinitable, ImplicitlyCopyable, Movable
__init__Opens the shared object and resolves it, which every handle then shares.
def __init__(out self)

Raises

With LIBRARY_MISSING, when nothing is on the loader path, with VERSION_MISMATCH when what loaded is another major version, or with SYMBOL_MISSING when it does not export an entry point the binding needs.
symbolsThe resolved entry points, borrowed rather than copied on every call.
def symbols(self) -> ref[self.shared.symbols] Symbols

Returns

A reference that stays valid for as long as this Library is held.
versionThe loaded engine's major, minor and patch, which may differ from what this binding was written against within one major. Calls uform_version.
def version(self) -> Tuple[Int, Int, Int]
version_nameThe loaded engine's own version, which is also the cheapest check that loading worked. Calls uform_version_name.
def version_name(self) -> String
capabilities_compiledThe hardware capabilities this build of the engine was compiled with, comma-separated. Calls uform_capabilities_compiled.
def capabilities_compiled(self) -> String
capabilities_availableThe hardware capabilities this machine offers now, which the build does not imply. Calls uform_capabilities_available.
def capabilities_available(self) -> String
gpu_devicesFills devices with every GPU this process can drive, in the ordinal order every VRAM call names them by. Calls uform_gpu_devices.
def gpu_devices[devices_origin: MutOrigin, //](
    self,
    devices: Span[GPUDevice, devices_origin]
) -> Int

Parameters

devicesSpan[GPUDevice, devices_origin]Where the listing lands, as many entries as fit; may be empty to only count.

Returns

How many devices this process can drive, which may exceed len(devices).

Raises

Error if a vendor runtime is present but refuses the listing.
status_nameThe engine's spelling of a status, "unrecognized" for a code it does not name. Calls uform_status_name.
def status_name(self, status: Status) -> String
status_from_nameReads a spelling back; INVALID_ARGUMENT when unrecognized. Calls uform_status_from_name.
def status_from_name(self, name: StringSpan) -> Status
scalar_nameThe engine's spelling of a scalar kind, as F32 spells "f32". Calls uform_scalar_name.
def scalar_name(self, scalar: ScalarKind) -> String
scalar_from_nameReads a spelling back; UNKNOWN when unrecognized. Calls uform_scalar_from_name.
def scalar_from_name(self, name: StringSpan) -> ScalarKind
mood_nameThe engine's spelling of a mood, as PARKED spells "parked". Calls uform_mood_name.
def mood_name(self, mood: Mood) -> String
mood_from_nameReads a spelling back; PARKED when unrecognized. Calls uform_mood_from_name.
def mood_from_name(self, name: StringSpan) -> Mood
cpu_class_nameThe engine's spelling of a CPU class, as INTEL_HASWELL spells "intel-haswell". Calls uform_cpu_class_name.
def cpu_class_name(self, cpu_class: CPUClass) -> String
cpu_class_from_nameReads a spelling back; UNKNOWN when unrecognized. Calls uform_cpu_class_from_name.
def cpu_class_from_name(self, name: StringSpan) -> CPUClass
gpu_class_nameThe engine's spelling of a GPU class, as NVIDIA_HOPPER spells "nvidia-hopper". Calls uform_gpu_class_name.
def gpu_class_name(self, gpu_class: GPUClass) -> String
gpu_class_from_nameReads a spelling back; UNKNOWN when unrecognized. Calls uform_gpu_class_from_name.
def gpu_class_from_name(self, name: StringSpan) -> GPUClass
modality_nameThe engine's spelling of a modality, as TEXT spells "text". Calls uform_modality_name.
def modality_name(self, modality: Modality) -> String
modality_from_nameReads a spelling back; TEXT when unrecognized. Calls uform_modality_from_name.
def modality_from_name(self, name: StringSpan) -> Modality
objective_nameThe engine's spelling of an objective, as JOINT spells "joint". Calls uform_objective_name.
def objective_name(self, objective: Objective) -> String
objective_from_nameReads a spelling back; MASKED when unrecognized. Calls uform_objective_from_name.
def objective_from_name(self, name: StringSpan) -> Objective
negatives_nameThe engine's spelling of a negatives policy, as NAMED spells "named". Calls uform_negatives_name.
def negatives_name(self, negatives: Negatives) -> String
negatives_from_nameReads a spelling back; AMBIENT when unrecognized. Calls uform_negatives_from_name.
def negatives_from_name(self, name: StringSpan) -> Negatives
multimem_tier_nameThe engine's spelling of a multimem tier, as PEER_READ spells "peer-read". Calls uform_multimem_tier_name.
def multimem_tier_name(self, tier: MultimemTier) -> String
multimem_tier_from_nameReads a spelling back; SWITCH_REDUCED when unrecognized. Calls uform_multimem_tier_from_name.
def multimem_tier_from_name(self, name: StringSpan) -> MultimemTier