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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(qwen-image): run Qwen-Image attention on SageAttention when enabled
Alexander Eichhorn4abdcd48dde9
diff --git a/docs/src/content/docs/configuration/Optimization/sage-attention.mdx b/docs/src/content/docs/configuration/Optimization/sage-attention.mdxindex 915182f6cd..563925e625 100644--- a/docs/src/content/docs/configuration/Optimization/sage-attention.mdx+++ b/docs/src/content/docs/configuration/Optimization/sage-attention.mdx@@ -29,6 +29,7 @@ compared with PyTorch's default attention there:| FLUX.1 dev (FP8) | 16.1 s → 14.0 s (−13 %) | 84.2 s → 54.8 s (−35 %) | Also serves ControlNets inside the denoising loop. || FLUX.2 Klein 9B (FP8) | 15.6 s → 15.1 s (−3 %) | 27.1 s → 23.1 s (−15 %) | || Z-Image (FP8) | 10.4 s → 10.0 s (−5 %) | 33.7 s → 25.9 s (−23 %) | Z-Image Control masks its attention and keeps PyTorch's. |+| Qwen-Image 2512 (GGUF Q4_K_M) | 78.8 s → 73.5 s (−7 %) | 208.9 s → 150.3 s (−28 %) | One block reaches about 17 % error per call; images were still judged equivalent. |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.diff --git a/invokeai/app/invocations/qwen_image/qwen_image_denoise.py b/invokeai/app/invocations/qwen_image/qwen_image_denoise.pyindex 3cd1d89717..f161d20c6c 100644--- a/invokeai/app/invocations/qwen_image/qwen_image_denoise.py+++ b/invokeai/app/invocations/qwen_image/qwen_image_denoise.py@@ -34,6 +34,7 @@ from invokeai.backend.rectified_flow.rectified_flow_inpaint_extension import Recfrom invokeai.backend.stable_diffusion.diffusers_pipeline import PipelineIntermediateStatefrom invokeai.backend.stable_diffusion.diffusion.conditioning_data import QwenImageConditioningInfofrom invokeai.backend.util.devices import TorchDevice+from invokeai.backend.util.sage_attention import sage_attention_scope@invocation(@@ -484,6 +485,8 @@ class QwenImageDenoiseInvocation(BaseInvocation, WithMetadata, WithBoard):))+ exit_stack.enter_context(sage_attention_scope())+for step_idx, t in enumerate(tqdm(timesteps_sched)):# The pipeline passes timestep / 1000 to the transformertimestep = t.expand(latents.shape[0]).to(inference_dtype)