[amd] Add deterministic all-reduce kernel for AMD (ROCm) (#15340)

Co-authored-by: Thomas Wang <1am9trash@gmail.com>
This commit is contained in:
sunxxuns
2025-12-18 23:36:03 -08:00
committed by GitHub
co-authored by Thomas Wang
parent 0e869f0868
commit f2d64e6782
12 changed files with 1466 additions and 8 deletions
+13 -5
View File
@@ -2314,11 +2314,19 @@ class ServerArgs:
# Check TP size
if self.tp_size > 1:
os.environ["NCCL_ALGO"] = "allreduce:tree"
self.disable_custom_all_reduce = True
logger.warning(
"NCCL_ALGO is set to 'allreduce:tree' and custom all reduce is disabled for deterministic inference when TP size > 1."
)
if is_hip():
# AMD: use 1-stage all-reduce kernel which is inherently deterministic
# (each GPU reads all data from all GPUs, reduces locally in fixed order)
logger.info(
"AMD/ROCm: Using 1-stage all-reduce kernel (deterministic)"
)
else:
# CUDA: use NCCL tree algorithm
os.environ["NCCL_ALGO"] = "allreduce:tree"
self.disable_custom_all_reduce = True
logger.warning(
"NCCL_ALGO is set to 'allreduce:tree' and custom all reduce is disabled for deterministic inference when TP size > 1."
)
def _handle_dllm_inference(self):
if self.dllm_algorithm is None: