DistributedManager initialization fails on CPU-only hosts
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.3k
- Forks
- 787
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
Version
2.1.1 (also reproduces on current main)
On which installation method(s) does this occur?
Pip
Describe the issue
DistributedManager cannot initialize on CPU-only hosts (e.g. laptop-scale gloo runs, CPU CI):
DistributedManager.setup()passesmanager.deviceas thedevice_idargument oftorch.distributed.init_process_group. On CPU-only hosts that istorch.device("cpu"), which recent PyTorch versions reject withValueError: init_process_group device_id parameter must be an accelerator with an index.- When
local_rank is None,setup()computesrank % torch.cuda.device_count(), a division by zero when no accelerator is present (hit via the SLURM/OpenMPI initialization paths, which passlocal_rank=None). - As a follow-on, the failed initialization leaves
_shared_state["_distributed"] = True, so theatexitcleanup()callsdist.destroy_process_group()on a process group that was never created and dies withAssertionError: Process group cannot be None, obscuring the original error.
Note the distributed manager tests are skipped on CPU by an autouse fixture, so CI does not catch this path.
Minimum reproducible example
# repro.py — run on a CPU-only machine:
# torchrun --standalone --nproc_per_node=2 repro.py
import torch
from physicsnemo.distributed import DistributedManager
DistributedManager.initialize()
dm = DistributedManager()
t = torch.tensor([dm.rank + 1.0])
torch.distributed.broadcast(t, src=0)
DistributedManager.cleanup()
Relevant log output
File ".../physicsnemo/distributed/manager.py", line 590, in setup
dist.init_process_group(
File ".../torch/distributed/distributed_c10d.py", line 1763, in init_process_group
raise ValueError(
ValueError: init_process_group device_id parameter must be an accelerator with an index
Exception ignored in atexit callback: <staticmethod(<function DistributedManager.cleanup ...)>
File ".../physicsnemo/distributed/manager.py", line 823, in cleanup
dist.destroy_process_group()
AssertionError: Process group cannot be None
Environment details
nvidia-physicsnemo 2.1.1, torch 2.13.0, Python 3.12, macOS (arm64) and Linux CPU nodes; gloo backend.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in physicsnemo/distributed/manager.py around setup() near line 590 and cleanup() near line 823. Review the CPU-skipping distributed-manager test fixture and the provided torchrun reproduction, then exercise the SLURM/OpenMPI paths with the gloo backend. Done means CPU-only initialization works without division-by-zero or invalid device arguments, failed setup does not leave misleading cleanup errors, and tests cover the path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100