[AMD][No-Merge] Simplify fused allreduce + RMSNorm and remove hidden_dim allowlist (#21986)

Co-authored-by: HAI <hixiao@gmail.com>
This commit is contained in:
Hubert Lu
2026-04-11 23:47:08 -07:00
committed by GitHub
co-authored by HAI
parent 9a4e8089ff
commit edaa5973d4
4 changed files with 263 additions and 56 deletions
@@ -628,7 +628,7 @@ class GroupCoordinator:
weight_: torch.Tensor,
eps: float,
) -> Optional[Tuple[torch.Tensor, torch.Tensor]]:
"""Attempt fused all-reduce + RMSNorm via custom all-reduce communicator."""
"""Attempt fused all-reduce + RMSNorm via custom all-reduce communicator. ROCm/HIP Only"""
ca_comm = self.ca_comm
if ca_comm is None or getattr(ca_comm, "disabled", True):
return None
@@ -646,24 +646,17 @@ class GroupCoordinator:
if not hasattr(ca_comm, "custom_fused_ar_rms"):
return None
# 1-stage policy for fused AR+RMSNorm:
# 1) Explicit env override wins.
# 2) Deterministic inference forces 1-stage for reproducibility.
# 3) Otherwise follow AITER's heuristic (small payloads only).
# 1-stage vs 2-stage selection for fused AR+RMSNorm:
# The 1-stage kernel launches one block per token and is capped at
# 80 tokens (kMaxBlocks). Guard with a byte threshold so large
# prefill batches fall through to the 2-stage kernel instead of
# hitting a runtime error. AITER's C++ dispatch already gates
# which hidden_dims have valid 1-stage support.
if envs.SGLANG_USE_1STAGE_ALLREDUCE.is_set():
use_1stage_ar = envs.SGLANG_USE_1STAGE_ALLREDUCE.get()
elif envs.SGLANG_ENABLE_DETERMINISTIC_INFERENCE.get():
use_1stage_ar = True
else:
total_bytes = input_.numel() * input_.element_size()
hidden_dim = input_.shape[-1]
use_1stage_ar = total_bytes <= 128 * 1024 and hidden_dim in {
512,
1024,
2048,
2880,
4096,
}
use_1stage_ar = total_bytes <= 128 * 1024
fused_outputs = ca_comm.custom_fused_ar_rms(
input_,
+2 -1
View File
@@ -167,11 +167,12 @@ def apply_flashinfer_allreduce_fusion(batch_size: int):
def apply_aiter_all_reduce_fusion(input_tensor: torch.Tensor):
n = input_tensor.shape[-1]
total_bytes = input_tensor.numel() * input_tensor.element_size()
# Aiter's should_custom_ar uses <= max_size/2 (64 MB); match that boundary.
return (
_use_aiter
and total_bytes > 0
and n <= 16384
and total_bytes < 8 * 1024 * 8192
and total_bytes <= 8 * 1024 * 8192
and get_tensor_model_parallel_world_size() != 6
and not is_dp_attention_enabled()
and get_global_server_args().enable_aiter_allreduce_fusion