emmi_inference.device¶
Attributes¶
Classes¶
Supported execution devices. |
|
Carrier for device execution context. |
Functions¶
|
Resolve the effective device string. |
|
Synchronize device streams. |
|
Decide whether autocast should be enabled. |
Module Contents¶
- class emmi_inference.device.DeviceEnum¶
Bases:
enum.StrEnumSupported execution devices.
- AUTO¶
Let the library pick the best available backend (CUDA -> MPS -> CPU).
- CPU¶
Force CPU execution.
- CUDA¶
NVIDIA CUDA GPU (if available).
- MPS¶
Apple Metal Performance Shaders backend on Apple Silicon (if available).
Initialize self. See help(type(self)) for accurate signature.
- AUTO = 'auto'¶
- CPU = 'cpu'¶
- CUDA = 'cuda'¶
- MPS = 'mps'¶
- emmi_inference.device.DeviceType¶
- emmi_inference.device.resolve_device(device=DeviceEnum.AUTO)¶
Resolve the effective device string.
- Parameters:
device (DeviceType) – Either a DeviceEnum or a string (“auto”, “cpu”, “cuda”, “mps”). When set to “auto”, prefers CUDA, then MPS, then CPU.
- Returns:
One of “cuda”, “mps”, or “cpu” depending on runtime availability.
- Return type:
- emmi_inference.device.sync_device(device)¶
Synchronize device streams.
- Parameters:
device (DeviceType) – Either a DeviceEnum or string; will be resolved to the effective device.
- Return type:
None
- emmi_inference.device.resolve_autocast(effective_device, requested)¶
Decide whether autocast should be enabled.
Autocast is disabled on Apple MPS as PyTorch doesn’t support it.
- class emmi_inference.device.DeviceContext(device, dtype, autocast)¶
Carrier for device execution context.
- device¶
Effective device string (“cuda”, “mps”, or “cpu”).
- dtype¶
Optional compute dtype used for autocast/mixed precision.
- autocast¶
Whether to attempt autocast (subject to device support).
- device¶
- dtype¶
- autocast¶
- amp()¶
Return an AMP/autocast context manager for the current device.
- Returns:
torch.cuda.amp.autocast when enabled on CUDA; otherwise a no-op context manager.
- Return type:
ContextManager