[Fix] [AMD] diffusion: Compare ReduceOp by identity so the compiled TP all-reduce stays one graph (#43770)

Co-authored-by: jacky.cheng <yichiche@amd.com>
This commit is contained in:
Michael
2026-10-14 17:40:07 -07:00
committed by GitHub
co-authored by jacky.cheng
parent 64a0a08f0a
commit 8333ccfccb
@@ -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_)