sage_attn3 ¶
Classes¶
fastvideo.attention.backends.sage_attn3.SageAttention3Impl ¶
SageAttention3Impl(num_heads: int, head_size: int, causal: bool, softmax_scale: float, num_kv_heads: int | None = None, prefix: str = '', **extra_impl_args)
Bases: AttentionImpl
Source code in fastvideo/attention/backends/sage_attn3.py
Methods:¶
fastvideo.attention.backends.sage_attn3.SageAttention3Impl.forward ¶
forward(query: Tensor, key: Tensor, value: Tensor, attn_metadata: AttentionMetadata) -> Tensor
Call sageattn3_blackwell directly. Input is already [B, H, L, D] and contiguous from preprocess_qkv.
Source code in fastvideo/attention/backends/sage_attn3.py
fastvideo.attention.backends.sage_attn3.SageAttention3Impl.postprocess_output ¶
postprocess_output(output: Tensor, attn_metadata: AttentionMetadata) -> Tensor
Transpose output from [B, H, L, D] back to [B, L, H, D].
fastvideo.attention.backends.sage_attn3.SageAttention3Impl.preprocess_qkv ¶
preprocess_qkv(qkv: Tensor, attn_metadata: AttentionMetadata) -> Tensor
Transpose stacked QKV from [3B, L, H, D] to [3B, H, L, D].
Single bulk permute+contiguous on the entire stacked tensor rather than three separate transposed views for Q, K, V. The .contiguous() is required: sageattn_blackwell's fake kernel returns empty_like(q), so the op's output strides must match contiguous q under torch.compile.