Skip to content

Commit

Permalink
clean up distributed training automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
sangkeun00 committed May 30, 2023
1 parent 562eb50 commit 210c65c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions betty/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def run(self):
self.logger.info("Early stopping is executed!")
break

self.cleanup()

def initialize(self):
"""
Initialize dependencies (computational graph) between problems.
Expand Down Expand Up @@ -339,6 +341,15 @@ def is_rank_zero(self):
"""
return self._rank == 0

def cleanup(self):
"""
Clean up distributed training
"""
if self._strategy in ["distributed", "zero", "fsdp"]:
dist.destroy_process_group()
if self.is_rank_zero():
self.logger.info("Multilevel optimization finished!")

def is_implemented(self, fn_name):
"""
Check whether ``fn_name`` method is implemented in the class.
Expand Down

0 comments on commit 210c65c

Please sign in to comment.