[ROCm]: Update rope+kvcache fusion conditions and disable custom op by default (#36716)

Signed-off-by: Rohan138 <rohanpotdar138@gmail.com>
This commit is contained in:
Rohan Potdar
2026-03-25 20:58:44 +00:00
committed by GitHub
parent 70a2152830
commit a0e8c74005
5 changed files with 42 additions and 18 deletions
+33 -7
View File
@@ -1042,13 +1042,6 @@ class CompilationConfig:
self.splitting_ops = []
return
# NOTE: this function needs to be called only when mode is
# CompilationMode.VLLM_COMPILE
assert self.mode == CompilationMode.VLLM_COMPILE, (
"set_splitting_ops_for_v1 should only be called when "
"mode is CompilationMode.VLLM_COMPILE"
)
if self.pass_config.fuse_attn_quant and not self.use_inductor_graph_partition:
self.set_splitting_ops_for_attn_fusion()
else:
@@ -1069,6 +1062,16 @@ class CompilationConfig:
# that doesn't seem to affect performance.
# https://github.com/vllm-project/vllm/issues/33267
if not self.use_inductor_graph_partition:
if self.pass_config.fuse_rope_kvcache:
logger.warning_once(
"fuse_rope_kvcache is enabled, but splitting_ops is None "
"and Inductor graph partition is not enabled."
"Disabling fuse_rope_kvcache."
"Please either set splitting_ops to an empty list []"
"or set use_inductor_graph_partition to True "
"to enable RoPE+KV cache fusion."
)
self.pass_config.fuse_rope_kvcache = False
self.splitting_ops.append("vllm::unified_kv_cache_update")
self.splitting_ops.append("vllm::unified_mla_kv_cache_update")
@@ -1142,6 +1145,29 @@ class CompilationConfig:
op in self.splitting_ops for op in self._attention_ops
)
def splitting_ops_contain_kv_cache_update(self) -> bool:
# when using Dynamo partition while splitting ops is None
# and attn+quant fusion disabled, the kv_cache_update_ops are
# appended to splitting_ops in set_splitting_ops_for_v1 due to
# https://github.com/vllm-project/vllm/issues/33267
# In this case, we return True if the kv_cache_update_ops
# are not in the splitting_ops yet, but will subsequently
# be added to splitting_ops.
if (
not self.use_inductor_graph_partition
and self.splitting_ops is None
and not self.pass_config.fuse_attn_quant
):
return True
kv_cache_update_ops = [
"vllm::unified_kv_cache_update",
"vllm::unified_mla_kv_cache_update",
]
return self.splitting_ops is not None and all(
op in self.splitting_ops for op in kv_cache_update_ops
)
def is_attention_compiled_piecewise(self) -> bool:
if not self.splitting_ops_contain_attention():
return False
+5 -2
View File
@@ -144,7 +144,10 @@ def enable_rope_kvcache_fusion(cfg: "VllmConfig") -> bool:
return (
rocm_aiter_ops.is_enabled()
and cfg.compilation_config.is_custom_op_enabled("rotary_embedding")
and cfg.compilation_config.use_inductor_graph_partition
and (
cfg.compilation_config.use_inductor_graph_partition
or not cfg.compilation_config.splitting_ops_contain_kv_cache_update()
)
)
@@ -190,7 +193,7 @@ OPTIMIZATION_LEVEL_01 = {
"enable_sp": False,
"fuse_gemm_comms": False,
"fuse_act_padding": enable_norm_pad_fusion,
"fuse_rope_kvcache": enable_rope_kvcache_fusion,
"fuse_rope_kvcache": False,
},
"cudagraph_mode": CUDAGraphMode.PIECEWISE,
"use_inductor_graph_partition": False,
-7
View File
@@ -649,13 +649,6 @@ class RocmPlatform(Platform):
and "-grouped_topk" not in compilation_config.custom_ops
):
compilation_config.custom_ops.append("+grouped_topk")
# Enable rotary embedding customop when using AITER if not disabled by user
if (
rocm_aiter_ops.is_enabled()
and "+rotary_embedding" not in compilation_config.custom_ops
and "-rotary_embedding" not in compilation_config.custom_ops
):
compilation_config.custom_ops.append("+rotary_embedding")
# Default dispatch to rocm's sparse_attn_indexer implementation
compilation_config.custom_ops.append("+sparse_attn_indexer")