fastvideo.v1.platforms.interface
#
Module Contents#
Classes#
Data#
API#
- class fastvideo.v1.platforms.interface.DeviceCapability[source]#
Bases:
typing.NamedTuple
- class fastvideo.v1.platforms.interface.Platform[source]#
-
- classmethod get_attn_backend_cls(selected_backend: Optional[fastvideo.v1.platforms.interface._Backend], head_size: int, dtype: torch.dtype) str [source]#
Get the attention backend class of a device.
- abstract classmethod get_current_memory_usage(device: Optional[torch.types.Device] = None) float [source]#
Return the memory usage in bytes.
- classmethod get_device_capability(device_id: int = 0) Optional[fastvideo.v1.platforms.interface.DeviceCapability] [source]#
Stateless version of :func:
torch.cuda.get_device_capability
.
- classmethod get_device_communicator_cls() str [source]#
Get device specific communicator class for distributed communication.
- abstract classmethod get_device_total_memory(device_id: int = 0) int [source]#
Get the total memory of a device in bytes.
- abstract classmethod get_device_uuid(device_id: int = 0) str [source]#
Get the uuid of a device, e.g. the PCI bus ID.
- classmethod has_device_capability(capability: Union[Tuple[int, int], int], device_id: int = 0) bool [source]#
Test whether this platform is compatible with a device capability.
The
capability
argument can either be:A tuple
(major, minor)
.An integer
<major><minor>
. (See :meth:DeviceCapability.to_int
)
- classmethod inference_mode()[source]#
A device-specific wrapper of
torch.inference_mode
.This wrapper is recommended because some hardware backends such as TPU do not support
torch.inference_mode
. In such a case, they will fall back totorch.no_grad
by overriding this method.
- abstract classmethod is_async_output_supported(enforce_eager: Optional[bool]) bool [source]#
Check if the current platform supports async output.
- classmethod seed_everything(seed: Optional[int] = None) None [source]#
Set the seed of each random module.
torch.manual_seed
will set seed on all devices.Loosely based on: https://github.com/Lightning-AI/pytorch-lightning/blob/2.4.0/src/lightning/fabric/utilities/seed.py#L20