Python · Executors

Executors

import uformfrom uform import GPUDevice, Executor, MeshOptions, … 4.0.0-rc.1 · 3ee5e534

uform.Executor.for_ram(threads=0, *, memory_domains=None, cpu_class=None) creates an executor of host threads, and uform.Executor.for_vram(devices=None, *, scratch_limit=0, gpu_class=None) opens one stream per device. A device is named by its position in uform.gpu_devices(), which lists every GPU the process can drive as a uform.GPUDevice, NVIDIA devices first, then AMD. A uform.CPUClass or uform.GPUClass pin dispatches as that class, and None derives the hardware’s own. uform.Executor.on_pool(pool) mirrors the C verb that borrows a ForkUnion pool, and raises UnsupportedError until borrowing is designed. An executor runs one call at a time, and a call finding another one holding it raises ContendedError once waited for. A deferred call on the executor’s own threads finishes while Python only awaits it, and its progress callbacks run on those threads, holding the GIL while they do. executor.drain(uform.Mood.PARKED) waits until no call holds the executor and its devices are idle, then applies the mood. In a with block, it waits for its calls and closes on exit.

API

Types

CPUClassThe CPU families dispatch picks from, valued as uform_cpu_class_t; a RAM placement may pin one.
__init__.py:96 ↗
class CPUClass(IntEnum)

Values

SERIAL1
INTEL_HASWELL2
INTEL_SIERRA3
INTEL_SKYLAKE4
INTEL_ICELAKE5
AMD_GENOA6
INTEL_SAPPHIRE7
INTEL_GRANITE8
INTEL_DIAMOND9
AWS_G210
APPLE_M211
APPLE_M412
AWS_G513
NVIDIA_VERA14
ALIBABA_C93015
WASM32_V12816
WASM64_EXTENDED17
MONOVERSIONED18
GPUClassThe GPU families dispatch picks from, valued as uform_gpu_class_t; a VRAM placement may pin one.
__init__.py:118 ↗
class GPUClass(IntEnum)

Values

NVIDIA_AMPERE1
NVIDIA_ADA2
NVIDIA_HOPPER3
NVIDIA_BLACKWELL4
NVIDIA_BLACKWELLRTX5
NVIDIA_RUBIN6
AMD_CDNA37
AMD_CDNA48
AMD_CDNA59
APPLE_METAL710
APPLE_METAL911
APPLE_METAL1012
GPUVendorThe vendor whose runtime drives a GPU, valued as uform_gpu_vendor_t.
__init__.py:134 ↗
class GPUVendor(IntEnum)

Values

NVIDIA1
AMD2
APPLE3
MultimemTierHow a mesh's NVLink domains reduce, valued as uform_multimem_tier_t.
__init__.py:221 ↗
class MultimemTier(IntEnum)

Values

SWITCH_REDUCED0
PEER_READ1
ClassGPUDeviceOne GPU this process can drive, its position in gpu_devices() being its ordinal.6
lib.pyi:141 ↗
class GPUDevice(structseq[Any], tuple[GPUVendor, int, GPUClass | None, int, int, str])
vendorThe vendor whose runtime drives the device.
lib.pyi:148 ↗
vendor: GPUVendor
vendor_ordinalThe device's ordinal in its vendor's runtime, as nvidia-smi or rocm-smi list it.
lib.pyi:153 ↗
vendor_ordinal: int
gpu_classThe class whose kernels run on it, or None.
lib.pyi:158 ↗
gpu_class: GPUClass | None
compute_unitsStreaming multiprocessors or compute units.
lib.pyi:163 ↗
compute_units: int
memory_bytesDevice memory in bytes.
lib.pyi:168 ↗
memory_bytes: int
nameThe vendor's own name for the device.
lib.pyi:173 ↗
name: str
ClassExecutorThe threads or streams a verb runs on, shared across models and named by on and deferred.5
lib.pyi:271 ↗
class Executor
for_ramSpawns host threads for RAM-resident models.
lib.pyi:276 ↗
@classmethod
def for_ram(
    threads: int = 0,
    *,
    memory_domains: Sequence[int] | None = None,
    deferred_limit: int = 0,
    cpu_class: CPUClass | None = None,
) -> Executor

Calls uform_executor_for_ram.

on_poolBorrows a ForkUnion pool; raises UnsupportedError until borrowing is designed.
lib.pyi:288 ↗
@classmethod
def on_pool(
    pool: int,
    /,
    *,
    memory_domains: Sequence[int] | None = None,
    deferred_limit: int = 0,
    cpu_class: CPUClass | None = None,
) -> Executor

Calls uform_executor_on_pool.

for_vramOpens one submission stream on every named device.
lib.pyi:301 ↗
@classmethod
def for_vram(
    devices: Sequence[int] | None = None,
    *,
    scratch_limit: int = 0,
    deferred_limit: int = 0,
    gpu_class: GPUClass | None = None,
    memory_domains: Sequence[int] | None = None,
    cpu_class: CPUClass | None = None,
) -> Executor

Calls uform_executor_for_vram.

drainWaits for every call submitted before it, then sets the idle mood.
lib.pyi:315 ↗
def drain(mood: Mood = ...) -> None

Calls uform_executor_drain.

__exit__Closes it once its calls finish, or leaves that to its last live GPU arena.
lib.pyi:320 ↗
def __exit__(
    kind: type[BaseException] | None,
    value: BaseException | None,
    traceback: TracebackType | None,
    /,
) -> None

Calls uform_executor_free.

ClassMeshOptionsWhere this process sits among the processes training one model, and how they meet.7
lib.pyi:863 ↗
class MeshOptions
MeshOptions
lib.pyi:873 ↗
MeshOptions(
    *,
    host_domain_index: int = 0,
    host_domain_count: int = 0,
    gpus_per_multimem_domain: int = 0,
    directory: _PathLike | None = None,
    job: str | None = None,
    timeout_seconds: float = 0.0,
)
host_domain_index
lib.pyi:867 ↗
host_domain_index: Final[int]
host_domain_count
lib.pyi:868 ↗
host_domain_count: Final[int]
gpus_per_multimem_domain
lib.pyi:869 ↗
gpus_per_multimem_domain: Final[int]
directory
lib.pyi:870 ↗
directory: Final[_PathLike | None]
job
lib.pyi:871 ↗
job: Final[str | None]
timeout_seconds
lib.pyi:872 ↗
timeout_seconds: Final[float]
ClassMeshDescriptionWhat a mesh reports about itself, as uform_mesh_description_t holds it.7
lib.pyi:906 ↗
class MeshDescription(structseq[Any], tuple[int, int, int, int, int, MultimemTier, GPUClass | None])
gpus_per_host_domainGPUs one process drives.
lib.pyi:921 ↗
gpus_per_host_domain: int
gpus_per_multimem_domainGPUs one NVLink domain spans.
lib.pyi:926 ↗
gpus_per_multimem_domain: int
gpus_per_colocated_domainGPUs in the whole run.
lib.pyi:931 ↗
gpus_per_colocated_domain: int
host_domain_indexThis process's index among the run's processes.
lib.pyi:936 ↗
host_domain_index: int
first_gpu_indexThe run-wide index of this process's first GPU.
lib.pyi:941 ↗
first_gpu_index: int
multimem_tierHow its NVLink domains reduce.
lib.pyi:946 ↗
multimem_tier: MultimemTier
gpu_classThe class every GPU of the run dispatches as, or None.
lib.pyi:951 ↗
gpu_class: GPUClass | None
ClassMeshOne process's place among the processes of a run, borrowed by every trainer.2
lib.pyi:955 ↗
class Mesh
bootstrapJoins this process to the run's mesh.
lib.pyi:960 ↗
@classmethod
def bootstrap(
    executor: Executor,
    options: MeshOptions | None,
    /,
) -> Mesh

Calls uform_mesh_bootstrap.

describeThe mesh's shape and this process's place in it.
lib.pyi:965 ↗
def describe() -> MeshDescription

Calls uform_mesh_describe.

Functions

capabilities_compiledThe hardware capabilities this binary was compiled with.
__init__.py:27 ↗
def capabilities_compiled() -> str

Calls uform_capabilities_compiled.

capabilities_availableThe hardware capabilities this machine offers at runtime.
__init__.py:31 ↗
def capabilities_available() -> str

Calls uform_capabilities_available.

gpu_devicesEvery GPU this process can drive, a device's position being its ordinal.
__init__.py:35 ↗
def gpu_devices() -> tuple[GPUDevice, ...]

Calls uform_gpu_devices.