[Diffusion][Attention] Support per-role attention backend via CLI (#2681)

Signed-off-by: gcanlin <canlinguosdu@gmail.com>
Signed-off-by: Hongsheng Liu <liuhongsheng4@huawei.com>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
Canlin GuoandHongsheng Liu authored and GitHub committed 2026-05-10 11:59:05 +08:00
1 parent 26d481fc84
commit 11c4c7f0ff
29 files changed
+1262 -106

No files matched your search

@@ -15,7 +15,6 @@ It does NOT support:
import inspect
import logging
import os
import re
from typing import Any, cast
@@ -211,7 +210,8 @@ class DiffusersAdapterPipeline(nn.Module, DiffusionPipelineProfilerMixin):
logging.info("No transformer found in diffusers pipeline. Skipping attention backend setting.")
return
attention_backend_config = self.od_config.attention_backend or os.environ.get("DIFFUSION_ATTENTION_BACKEND")
default_spec = self.od_config.attention_config.default
attention_backend_config = default_spec.backend if default_spec is not None else None
attention_backend_attempts: list[str] = []
match attention_backend_config:
case "FLASH_ATTN" | None: