Fix a bug of distributed 'gather' with noncontiguous tensors on the NCCL backend. (#159549)

Fixes #159548

* Throw an error message when the input tensors for the distributed `gather` are noncontiguous. This behaviour is consistent with the distributed `all_gather`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/159549
Approved by: https://github.com/d4l3k
This commit is contained in:
tiandeyu-cs
2025-08-01 03:26:03 +00:00
committed by PyTorch MergeBot
parent 5cc6a0abc1
commit a4fc051c9a

View File

@ -5430,6 +5430,7 @@ c10::intrusive_ptr<Work> ProcessGroupNCCL::gather(
TORCH_CHECK(inputTensors.size() == 1, MULTI_DEVICE_ERROR_MSG);
auto inputTensor = inputTensors.back();
check_gpu_single_tensor(inputTensor);
std::vector<at::Tensor> outputs;