Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error for PT backend when pytorch.distributed is not available #3652

Merged

Conversation

chazeon
Copy link
Contributor

@chazeon chazeon commented Apr 7, 2024

By default, pytorch.distributed is not enabled on macOS by default (see pytorch.distributed.is_available()).

In this case,

  • Testing pytorch.distributed.is_initialized() will fail. To fix this issue, pytorch.distributed.is_available() needs to be tested first.
  • Distributed dataloader is not available.

This pull request allows passing the unittests while distributed is disabled.

USE_DISTRIBUTED=1 to manually enable distributed training / dataloading on macOS. Set it to 0 to disable it on other platforms. Maybe this behavior needs to be documented somewhere?

@github-actions github-actions bot added the Python label Apr 7, 2024
@@ -924,7 +944,11 @@
# Handle the case if rank 0 aborted and re-assigned
self.latest_model = Path(self.save_ckpt + f"-{_step_id + 1}.pt")

module = self.wrapper.module if dist.is_initialized() else self.wrapper
module = (

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable module is not used.
Copy link

codecov bot commented Apr 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.80%. Comparing base (073f559) to head (e9c7a0e).
Report is 4 commits behind head on devel.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3652      +/-   ##
==========================================
+ Coverage   81.72%   81.80%   +0.07%     
==========================================
  Files         503      503              
  Lines       46007    46456     +449     
  Branches     2891     2952      +61     
==========================================
+ Hits        37601    38004     +403     
- Misses       7528     7559      +31     
- Partials      878      893      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@njzjz njzjz requested a review from CaRoLZhangxy April 7, 2024 08:12
@wanghan-iapcm wanghan-iapcm added this pull request to the merge queue Apr 8, 2024
Merged via the queue into deepmodeling:devel with commit e71085c Apr 8, 2024
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants