[Model] Add LTX-2.5 support (#6070)

Signed-off-by: lishunyang12 <lishunyang12@163.com>
This commit is contained in:
SYLAR authored and GitHub committed 2026-08-15 18:27:23 +08:00
1 parent f39b8684eb
commit ce6ab0ca46
47 files changed
+4558 -218

No files matched your search

@@ -85,6 +85,24 @@ class CuDNNAttentionImpl(AttentionImpl):
enable_gqa = query.shape[2] != key.shape[2]
query, key, value = (x.permute(0, 2, 1, 3) for x in (query, key, value))
# cuDNN has no kernel for degenerate attention shapes when either
# sequence has one token. Route those degenerate shapes before entering the
# cuDNN-only context: under torch.compile, FakeTensor evaluation raises
# before the eager RuntimeError fallback below can run.
if query.shape[-2] == 1 or key.shape[-2] == 1:
with sdpa_kernel([SDPBackend.MATH]):
output = torch.nn.functional.scaled_dot_product_attention(
query,
key,
value,
attn_mask=attention_mask,
dropout_p=0.0,
is_causal=self.causal,
scale=self.softmax_scale,
enable_gqa=enable_gqa,
)
return output.permute(0, 2, 1, 3)
# Pin cuDNN exclusively. A priority list like [CUDNN, FLASH, MATH] hits a
# PyTorch SDPA dispatch quirk: when FLASH rejects a non-None attn_mask,
# cuDNN gets runtime-disabled in the same call and the dispatcher falls
@@ -93,7 +111,7 @@ class CuDNNAttentionImpl(AttentionImpl):
#
# Fall back to the default SDPA dispatcher if cuDNN rejects the shape,
# e.g. under torch.compile where Dynamo sees a symbolic head_dim and
# cuDNN's kernel selection fails (observed in LTX-2 audio attention).
# cuDNN's kernel selection fails for some symbolic attention shapes.
# The unpinned dispatcher then picks EFFICIENT/MATH instead of raising.
try:
with sdpa_kernel([SDPBackend.CUDNN_ATTENTION]):