Skip to content

Commit

Permalink
Get a shared file system safe signal file name (mosaicml#3485)
Browse files Browse the repository at this point in the history
  • Loading branch information
dakinggg committed Jul 23, 2024
1 parent 6f8831d commit 29401b8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1986,7 +1986,7 @@ def _get_autoresume_checkpoint(

signal_file_path = os.path.join(
os.path.dirname(latest_checkpoint_path),
f'.node_{dist.get_node_rank()}_local_rank0_completed_autoresume',
dist.get_node_signal_file_name(),
)
if dist.get_local_rank() == 0:
os.makedirs(os.path.dirname(signal_file_path), exist_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion composer/utils/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def download_checkpoint(
if not checkpoint_is_sharded:
signal_file_path = os.path.join(
node_checkpoint_folder,
f'.node_{dist.get_node_rank()}_local_rank0_completed',
dist.get_node_signal_file_name(),
)
if dist.get_local_rank() == 0:
with open(signal_file_path, 'wb') as f:
Expand Down
2 changes: 1 addition & 1 deletion composer/utils/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def get_node_signal_file_name(rng: Optional[random.Random] = None) -> str:
random_string = ''.join(rng.choices(string.ascii_letters + string.digits, k=6))
node_rank = get_node_rank()
file_name_list = [f'._signal_file_node{node_rank}_{random_string}']
dist.broadcast_object_list(file_name_list, src=0)
broadcast_object_list(file_name_list, src=0)
return file_name_list[0]


Expand Down

0 comments on commit 29401b8

Please sign in to comment.