[Perf] distributed: skip the DLPack re-wrap of custom all-reduce results (#44251)

Co-authored-by: Mick Qian <mickqian@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mick
2026-10-17 18:44:31 +08:00
committed by GitHub
co-authored by Mick Qian Claude Opus 5.5
parent eb5739b30e
commit 400c1dfe6e
@@ -228,6 +228,10 @@ def custom_all_reduce(
) -> torch.Tensor:
module = get_all_reduce_module(input.dtype, comm.world_size)
result = module.all_reduce(comm, input, algo.algo_name, graph_params, use_multicast)
# Already a torch.Tensor once tvm-ffi loads torch's DLPack exchange API;
# re-wrapping it is a pure round trip (~15 us per call on GB300).
if isinstance(result, torch.Tensor):
return result
return torch.from_dlpack(result)