[Model][Hardware][AMD]: Part 1/2 -> Enable e2e QK Norm + RoPE + KV Cache runtime fusion for Qwen3-30B-A3B on ROCM_AITER_FA, and ROCM_AITER_UNIFIED_ATTN (#42749)

Signed-off-by: Jack Hu <Jack.Hu@amd.com>
Co-authored-by: Douglas Lehr <91553416+dllehr-amd@users.noreply.github.com>
This commit is contained in:
Jack Hu
2026-07-16 17:39:04 -05:00
committed by GitHub
co-authored by Douglas Lehr
parent ab0a20d151
commit 2cab53ddee
15 changed files with 1361 additions and 4 deletions
+36 -2
View File
@@ -146,10 +146,16 @@ class PassConfig:
"""Fuse paired q/kv RMS norms in MLA attention."""
fuse_rope_kvcache: bool = None # type: ignore[assignment]
"""Fuse the QK rope + KV cache ops."""
fuse_qk_norm_rope_kvcache: bool = Field(default=None) # type: ignore[assignment]
"""Fuse QK RMSNorm + RoPE + KV cache update into a single AITER HIP
kernel. Supersedes both enable_qk_norm_rope_fusion and fuse_rope_kvcache
for layers that support it. Auto-enabled at O1+ on ROCm for models
with QK-norm (e.g. Qwen3-MoE)."""
rope_kvcache_fusion_max_token_num: int = 256
"""The threshold for ROCm AITER RoPE+KVCache fusion e.g. for small batch decode.
Larger batch sizes e.g. during prefill will use the unfused kernels.
Also applies to the fused QK-Norm+RoPE+KVCache pass.
"""
fi_allreduce_fusion_max_size_mb: float | None = None
@@ -228,6 +234,8 @@ class PassConfig:
"fuse_act_padding",
"fuse_mla_dual_rms_norm",
"fuse_rope_kvcache",
"fuse_qk_norm_rope_kvcache",
"enable_qk_norm_rope_fusion",
"fuse_rope_kvcache_cat_mla",
mode="wrap",
)
@@ -288,6 +296,12 @@ class PassConfig:
"The fusion will be disabled."
)
self.fuse_rope_kvcache = False
if self.fuse_qk_norm_rope_kvcache and not current_platform.is_rocm():
logger.warning_once(
"QK-Norm+RoPE+KVCache fusion requires ROCm with AITER. "
"The fusion will be disabled."
)
self.fuse_qk_norm_rope_kvcache = False
if self.fuse_rope_kvcache_cat_mla and not current_platform.is_cuda_alike():
logger.warning_once(
"MLA KV cache update with RoPE fusion enabled but the "
@@ -302,10 +316,13 @@ class PassConfig:
after all defaults are finalized.
TODO also log the compile ranges for which this is enabled.
"""
fusion_prefixes = ("fuse_", "enable_")
enabled_fusions = [
f.name[len("fuse_") :]
f.name[len(prefix) :]
for f in fields(self) # type: ignore[arg-type]
if getattr(self, f.name) and f.name.startswith("fuse_")
if getattr(self, f.name)
for prefix in fusion_prefixes
if f.name.startswith(prefix)
]
if enabled_fusions:
@@ -947,6 +964,7 @@ class CompilationConfig:
# TODO(zhuhaoran): support rope native forward match and remove this.
# Linked issue: https://github.com/vllm-project/vllm/issues/28042
self.custom_ops.append("+rotary_embedding")
if (
self.pass_config.fuse_rope_kvcache
and "+rotary_embedding" not in self.custom_ops
@@ -955,6 +973,12 @@ class CompilationConfig:
# Linked issue: https://github.com/vllm-project/vllm/issues/28042
self.custom_ops.append("+rotary_embedding")
if (
self.pass_config.fuse_qk_norm_rope_kvcache
and "+rotary_embedding" not in self.custom_ops
):
self.custom_ops.append("+rotary_embedding")
if (
is_torch_equal_or_newer("2.9.0.dev")
and "combo_kernels" not in self.inductor_compile_config
@@ -1137,6 +1161,16 @@ class CompilationConfig:
"to enable RoPE+KV cache fusion."
)
self.pass_config.fuse_rope_kvcache = False
if self.pass_config.fuse_qk_norm_rope_kvcache:
logger.warning_once(
"fuse_qk_norm_rope_kvcache is enabled, but "
"splitting_ops is None and Inductor graph partition "
"is not enabled. Disabling fuse_qk_norm_rope_kvcache. "
"Please either set splitting_ops to an empty list [] "
"or set use_inductor_graph_partition to True "
"to enable QK-Norm+RoPE+KV cache fusion."
)
self.pass_config.fuse_qk_norm_rope_kvcache = False
self.splitting_ops.append("vllm::unified_kv_cache_update")
self.splitting_ops.append("vllm::unified_mla_kv_cache_update")