From 8333ccfccb265ea4c1c3b2b036291a7fbd0b54a0 Mon Sep 17 00:00:00 2001 From: Michael <13900043+michaelzhang-ai@users.noreply.github.com> Date: Wed, 14 Oct 2026 17:40:07 -0700 Subject: [PATCH] [Fix] [AMD] diffusion: Compare ReduceOp by identity so the compiled TP all-reduce stays one graph (#43770) Co-authored-by: jacky.cheng --- .../multimodal_gen/runtime/distributed/group_coordinator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/sglang/multimodal_gen/runtime/distributed/group_coordinator.py b/python/sglang/multimodal_gen/runtime/distributed/group_coordinator.py index af577eba20..3d32e83b1d 100644 --- a/python/sglang/multimodal_gen/runtime/distributed/group_coordinator.py +++ b/python/sglang/multimodal_gen/runtime/distributed/group_coordinator.py @@ -375,7 +375,9 @@ class GroupCoordinator: torch.compiler.is_compiling() and self.srt_custom_allreduce is not None and not async_op - and op == torch.distributed.ReduceOp.SUM + # Compare by identity: Dynamo before torch 2.14 cannot trace + # RedOpType.__eq__ and breaks the graph on `==`. + and op is torch.distributed.ReduceOp.SUM and not input_.is_cpu ): return diffusion_all_reduce(input_, group_name=self.unique_name) @@ -384,7 +386,7 @@ class GroupCoordinator: if ( not async_op and custom_ar is not None - and op == torch.distributed.ReduceOp.SUM + and op is torch.distributed.ReduceOp.SUM and not input_.is_cpu and not custom_ar.disabled and custom_ar.should_custom_ar(input_)