Skip to content

Commit ad1585b

Browse files
wz337pytorchmergebot
authored andcommitted
[Checkpoint] Minor update to checkpoint utils (#89964)
Change to only print temp directory once on rank0. Pull Request resolved: #89964 Approved by: https://github.com/XilunWu
1 parent a43e09c commit ad1585b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

torch/testing/_internal/distributed/checkpoint_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ def wrapper(self, *args: Tuple[object], **kwargs: Dict[str, Any]) -> None:
2121
# Only create temp_dir when rank is 0
2222
if dist.get_rank() == 0:
2323
temp_dir = tempfile.mkdtemp()
24+
print(f"Using temp directory: {self.temp_dir }")
2425
else:
2526
temp_dir = ""
2627
object_list = [temp_dir]
28+
2729
# Broadcast temp_dir to all the other ranks
2830
dist.broadcast_object_list(object_list)
2931
self.temp_dir = object_list[0]
30-
print(f"Using temp directory: {self.temp_dir }")
32+
3133
try:
3234
func(self)
3335
finally:

0 commit comments

Comments
 (0)