fastvideo.v1.attention.selector#

Module Contents#

Functions#

backend_name_to_enum

Convert a string backend name to a _Backend enum value.

get_attn_backend

get_env_variable_attn_backend

Get the backend override specified by the FastVideo attention backend environment variable, if one is specified.

get_global_forced_attn_backend

Get the currently-forced choice of attention backend, or None if auto-selection is currently enabled.

global_force_attn_backend

Force all attention operations to use a specified backend.

global_force_attn_backend_context_manager

Globally force a FastVideo attention backend override within a context manager, reverting the global attention backend override to its prior state upon exiting the context manager.

Data#

API#

fastvideo.v1.attention.selector.backend_name_to_enum(backend_name: str) Optional[fastvideo.v1.platforms._Backend][source]#

Convert a string backend name to a _Backend enum value.

Returns:

  • _Backend: enum value if backend_name is a valid in-tree type

  • None: otherwise it’s an invalid in-tree type or an out-of-tree platform is loaded.

fastvideo.v1.attention.selector.forced_attn_backend: Optional[fastvideo.v1.platforms._Backend][source]#

None

fastvideo.v1.attention.selector.get_attn_backend(head_size: int, dtype: torch.dtype, supported_attention_backends: Optional[Tuple[fastvideo.v1.platforms._Backend, ...]] = None) Type[fastvideo.v1.attention.backends.abstract.AttentionBackend][source]#
fastvideo.v1.attention.selector.get_env_variable_attn_backend() Optional[fastvideo.v1.platforms._Backend][source]#

Get the backend override specified by the FastVideo attention backend environment variable, if one is specified.

Returns:

  • _Backend enum value if an override is specified

  • None otherwise

fastvideo.v1.attention.selector.get_global_forced_attn_backend() Optional[fastvideo.v1.platforms._Backend][source]#

Get the currently-forced choice of attention backend, or None if auto-selection is currently enabled.

fastvideo.v1.attention.selector.global_force_attn_backend(attn_backend: Optional[fastvideo.v1.platforms._Backend]) None[source]#

Force all attention operations to use a specified backend.

Passing None for the argument re-enables automatic backend selection.,

Arguments:

  • attn_backend: backend selection (None to revert to auto)

fastvideo.v1.attention.selector.global_force_attn_backend_context_manager(attn_backend: fastvideo.v1.platforms._Backend) Generator[None, None, None][source]#

Globally force a FastVideo attention backend override within a context manager, reverting the global attention backend override to its prior state upon exiting the context manager.

Arguments:

  • attn_backend: attention backend to force

Returns:

  • Generator

fastvideo.v1.attention.selector.logger[source]#

β€˜init_logger(…)’