Lightning-AI / Lightning-AI/pytorch-lightning
Add debugging utilitity methods for DDP
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.4k
- Forks
- 3.8k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 6
Description
I would really like to have _rank_breakpoint(0) and multi_print(msg) (using color) to help debugging DDP. Maybe next PRs :)
_Originally posted by @tchaton in https://github.com/PyTorchLightning/pytorch-lightning/pull/11445#discussion_r788463929_
rank_breakpoint implementation by @awaelchli
```py
def rank_breakpoint(rank=0):
if global_rank != rank:
barrier() # all processes wait here except the one we want to debug
else:
# the chosen rank will set a trace, but we want the frame from where this function is called
pdb.Pdb().set_trace(inspect.currentframe().f_back.f_back)
# once breakpoint gets skipped, synchronize with all other workers
barrier()
```
(pseudocode)
```python
def multi_message(msg, rank=-1):
if rank == -1:
print_with_color_per_rank(msg):
else:
if local_rank == rank:
print(msg)
```
cc @borda @awaelchli @rohitgr7 @akihironitta @tchaton
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
No file, test, or entry point is named. Start by locating the existing DDP and debugging utilities, then compare their behavior with the requested rank_breakpoint and multi_message pseudocode; done should include agreed APIs and coverage for rank selection, synchronization, and colored per-rank output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- devtools, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100