SmartAttentionDispatcher Node for ComfyUI: Replace SDPA with SageAttention
Deploy SmartAttentionDispatcher in ComfyUI to replace SDPA with SageAttention kernels, boosting speed for models like Flux, SD3.5, and Qwen without restarting.
Add SmartAttentionDispatcher before KSampler in your workflow and set --fast launch flag to accelerate generation.
Summary
SmartAttentionDispatcher is a ComfyUI node that patches PyTorch SDPA with SageAttention kernels (SA2/SA3) without restarting the UI or using launch flags. It automatically detects GPU architecture, installed libraries, and available kernels, showing active mode, GPU tier, SA2/SA3 availability, and model architecture after each run. Inspired by Kijai’s node, it adds specific kernel selection, dynamic combine mode, and support for models that import attention locally such as ErnieImage, Qwen, and ACE‑Step. The recommended launch flag is --fast, and it conflicts with --use-sage-attention.
The node patches DiT models via the standard transformer_options mechanism, and for models that import optimized_attention locally it scans sys.modules to patch references. It supports SDXL (UNet) with minimal speed gain. Qwen 2512 in SA3 mode produces unstable results for long sequences, while SA2 works correctly. The node offers modes: SA2, SA3, and a dynamic combine that switches between SA2 and SA3 across diffusion steps.
Benchmarks on a 16GB RTX 5060 Ti show an 8–9% speed improvement over vanilla SDPA when using SA2 fp8 or fp8++ kernels, with SA3 standard and per_block_mean also providing similar gains. The node is compatible with a wide range of models including SDXL 1.0, SD3.5, Flux.1 dev, Flux.2 dev, Z‑Image turbo, Qwen‑Image 2512, ERNIE‑Image turbo, LTX 2.3, Wan2.2, and HunyuanVideo 1.5.
Key changes
- Node patches SDPA with SA2/SA3 kernels automatically
- Detects GPU architecture, libraries, and available kernels
- Supports models importing attention locally (ErnieImage, Qwen, ACE‑Step)
- Recommended launch flag: --fast; conflicts with --use-sage-attention
- Modes: SA2, SA3, Combine (dynamic)
- Benchmarks show ~8–9% speed improvement with SA2 fp8 or fp8++
- SA3 unstable at long sequences for Qwen 2512
- Supports a wide range of models including SDXL, SD3.5, Flux, Z‑Image, LTX, Wan, HunyuanVideo