Lightning-AI / Lightning-AI/pytorch-lightning

`Fabric.all_reduce` silently fails when tensors are on CPU

Open
#21,530 4 comments 0 reactions 1 assignee View on GitHub

@GudeJunge is already working on this.

Since Mar 7, 2026.

docs fabric
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### 📚 Documentation

I wrote some code involving CPU offloading in a DDP context, and I used `Fabric.all_reduce` with arguments which were tensors on the CPU for each process associated with a rank.

This just fails silently, in that the tensors for each rank are the same afterwards. The docs are also silent about this. It should say that `all_reduce` works only if for rank `k`, the tensor passed as argument must be on `device("cuda", k)`. Otherwise, it just fails silently.

When you do CPU offloading, there are valid reasons to exchange tensors stored on CPU between processes, so this is (I think) not entirely dumb. I think the docs should be clear, and even better there should be an exception thrown.

cc @lantiga @justusschock

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.