[AMD] Diffusion - Enabel rocm miopen tuning on vae (#22428)

This commit is contained in:
YC Yen-Ching Tseng
2026-04-10 22:47:25 -07:00
committed by GitHub
parent 7e4e1dcd7a
commit cf1436d6ae
2 changed files with 16 additions and 1 deletions
+3
View File
@@ -57,6 +57,7 @@ if TYPE_CHECKING:
SGLANG_USE_RUNAI_MODEL_STREAMER: bool = True SGLANG_USE_RUNAI_MODEL_STREAMER: bool = True
SGLANG_DIFFUSION_VAE_CHANNELS_LAST_3D: bool = False SGLANG_DIFFUSION_VAE_CHANNELS_LAST_3D: bool = False
SGLANG_USE_ROCM_VAE: bool = False SGLANG_USE_ROCM_VAE: bool = False
SGLANG_USE_ROCM_CUDNN_BENCHMARK: bool = False
def get_default_cache_root() -> str: def get_default_cache_root() -> str:
@@ -283,6 +284,8 @@ environment_variables: dict[str, Callable[[], Any]] = {
), ),
# ROCm: use AITer GroupNorm in VAE for improved performance # ROCm: use AITer GroupNorm in VAE for improved performance
"SGLANG_USE_ROCM_VAE": _lazy_bool("SGLANG_USE_ROCM_VAE"), "SGLANG_USE_ROCM_VAE": _lazy_bool("SGLANG_USE_ROCM_VAE"),
# ROCm: enable cudnn.benchmark (MIOpen auto-tuning) for VAE conv layers
"SGLANG_USE_ROCM_CUDNN_BENCHMARK": _lazy_bool("SGLANG_USE_ROCM_CUDNN_BENCHMARK"),
} }
# Add cache-dit Secondary Transformer Env Vars via programmatic generation to reduce duplication # Add cache-dit Secondary Transformer Env Vars via programmatic generation to reduce duplication
@@ -193,7 +193,19 @@ class RocmPlatform(Platform):
@classmethod @classmethod
def optimize_vae(cls, vae: torch.nn.Module) -> torch.nn.Module: def optimize_vae(cls, vae: torch.nn.Module) -> torch.nn.Module:
"""Replace nn.GroupNorm with AITer GroupNorm for improved ROCm VAE performance.""" """Apply ROCm-specific optimizations to VAE.
- Enable MIOpen benchmark mode so that the best convolution algorithm
is selected for each distinct input shape (benefits Conv3d-heavy VAE
decode).
- Replace nn.GroupNorm with AITer GroupNorm when available.
"""
if envs.SGLANG_USE_ROCM_CUDNN_BENCHMARK and not torch.backends.cudnn.benchmark:
torch.backends.cudnn.benchmark = True
logger.info(
"Enabled cudnn.benchmark (MIOpen auto-tuning) for VAE conv layers"
)
if not envs.SGLANG_USE_ROCM_VAE: if not envs.SGLANG_USE_ROCM_VAE:
return vae return vae
try: try: