Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(ltx2): run LTX-2 video self-attention on SageAttention when enabled

Alexander Eichhorn9507eccfb65b
diff --git a/docs/src/content/docs/configuration/Optimization/sage-attention.mdx b/docs/src/content/docs/configuration/Optimization/sage-attention.mdx
index 53cace0feb..7b21d964d1 100644
--- a/docs/src/content/docs/configuration/Optimization/sage-attention.mdx
+++ b/docs/src/content/docs/configuration/Optimization/sage-attention.mdx
@@ -33,6 +33,10 @@ compared with PyTorch's default attention there:
| Krea-2 Turbo (GGUF Q4_K_M) | 11.5 s → 11.0 s (−4 %) | 42.7 s → 36.2 s (−15 %) | Off while `INVOKE_KREA2_SDPA_BACKEND` pins a PyTorch kernel. |
| SDXL | 4.4 s → 4.2 s (−5 %) | 19.6 s → 16.1 s (−18 %) | Text cross-attention stays on PyTorch (too short to gain). Also serves ControlNets. |
+| Video model (as measured) | Resolution | Generation | Notes |
+| --- | --- | --- | --- |
+| LTX-2.5 distilled (int8) | 1248×704, 121 frames | 72.0 s → 63.4 s (−12 %) | Video self-attention only; text cross-attention and the audio streams stay on PyTorch. |
+
At 1024×1024 most of a step is spent outside attention, so the gain is small; at high resolutions and for video,
attention dominates. GGUF models spend much of each step dequantizing weights, which SageAttention does not touch.
Windows' PyTorch has no flash-attention kernel; on Linux PyTorch's own baseline is faster and the gain correspondingly
diff --git a/invokeai/app/invocations/ltx2/ltx2_denoise.py b/invokeai/app/invocations/ltx2/ltx2_denoise.py
index 87876e5095..740aeac340 100644
--- a/invokeai/app/invocations/ltx2/ltx2_denoise.py
+++ b/invokeai/app/invocations/ltx2/ltx2_denoise.py
@@ -59,6 +59,7 @@ from invokeai.backend.quantization.dequantizing_linear import (
from invokeai.backend.stable_diffusion.diffusers_pipeline import PipelineIntermediateState
from invokeai.backend.stable_diffusion.diffusion.conditioning_data import LTX2ConditioningInfo
from invokeai.backend.util.devices import TorchDevice
+from invokeai.backend.util.sage_attention import sage_attention_scope
LTX2Schedule = Literal["auto", "dev", "distilled"]
@@ -616,18 +617,19 @@ class LTX2DenoiseInvocation(BaseInvocation):
)
try:
- video_latents, audio_latents = denoise(
- transformer=transformer,
- state=state,
- positive=positive,
- negative=negative,
- guidance=guidance,
- fps=self.fps,
- dtype=inference_dtype,
- device=device,
- step_callback=step_callback,
- is_canceled=context.util.is_canceled,
- )
+ with sage_attention_scope():
+ video_latents, audio_latents = denoise(
+ transformer=transformer,
+ state=state,
+ positive=positive,
+ negative=negative,
+ guidance=guidance,
+ fps=self.fps,
+ dtype=inference_dtype,
+ device=device,
+ step_callback=step_callback,
+ is_canceled=context.util.is_canceled,
+ )
finally:
progress.close()