[diffusion] feat: support SparseVideoGen2 attention backend (#17507)
Co-authored-by: Mick <mickjagger19@icloud.com>
This commit is contained in:
@@ -224,6 +224,35 @@ class CudaPlatformBase(Platform):
|
||||
raise ImportError(
|
||||
"Video Sparse Attention backend is not installed."
|
||||
) from e
|
||||
elif selected_backend == AttentionBackendEnum.SPARSE_VIDEO_GEN_2_ATTN:
|
||||
try:
|
||||
from svg.kernels.triton.permute import ( # noqa: F401
|
||||
apply_inverse_permutation_triton,
|
||||
permute_tensor_by_labels_triton,
|
||||
)
|
||||
from svg.kmeans_utils import ( # noqa: F401
|
||||
batch_kmeans_Euclid,
|
||||
density_calculation,
|
||||
dynamic_block_sparse_fwd_flashinfer,
|
||||
identify_dynamic_map,
|
||||
)
|
||||
|
||||
from sglang.multimodal_gen.runtime.layers.attention.backends.sparse_video_gen_2_attn import ( # noqa: F401
|
||||
SparseVideoGen2AttentionBackend,
|
||||
)
|
||||
|
||||
logger.info("Using Sparse Video Gen 2 (SAP) Attention backend")
|
||||
return "sglang.multimodal_gen.runtime.layers.attention.backends.sparse_video_gen_2_attn.SparseVideoGen2AttentionBackend"
|
||||
except ImportError as e:
|
||||
logger.error(
|
||||
"Failed to import Sparse Video Gen 2 (SAP) Attention backend: %s",
|
||||
str(e),
|
||||
)
|
||||
raise ImportError(
|
||||
"Sparse Video Gen 2 (SAP) Attention backend is not installed. "
|
||||
"Please install it by following the instructions at "
|
||||
"https://github.com/svg-project/Sparse-VideoGen"
|
||||
) from e
|
||||
elif selected_backend == AttentionBackendEnum.VMOBA_ATTN:
|
||||
try:
|
||||
from kernel.attn.vmoba_attn.vmoba import moba_attn_varlen # noqa: F401
|
||||
|
||||
@@ -31,6 +31,7 @@ class AttentionBackendEnum(enum.Enum):
|
||||
SAGE_ATTN = enum.auto()
|
||||
SAGE_ATTN_3 = enum.auto()
|
||||
VIDEO_SPARSE_ATTN = enum.auto()
|
||||
SPARSE_VIDEO_GEN_2_ATTN = enum.auto()
|
||||
VMOBA_ATTN = enum.auto()
|
||||
AITER = enum.auto()
|
||||
SLA_ATTN = enum.auto()
|
||||
|
||||
Reference in New Issue
Block a user