8000 Fixes format utils executable (#123407) · pytorch/pytorch@18c9d46 · GitHub
[go: up one dir, main page]

Skip to content

Commit 18c9d46

Browse files
LucasLLCpytorchmergebot
authored andcommitted
Fixes format utils executable (#123407)
Fixes an issue with the format utils executable, which was causing it to run as a no-op. :( Pull Request resolved: #123407 Approved by: https://github.com/wz337, https://github.com/fegin
1 parent 7b575f0 commit 18c9d46

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

torch/distributed/checkpoint/format_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ def dcp_to_torch_save(
205205
To avoid OOM, it's recommended to only run this function on a single rank.
206206
"""
207207
sd: STATE_DICT_TYPE = {}
208-
209208
_load_state_dict(
210209
sd,
211210
storage_reader=FileSystemReader(dcp_checkpoint_dir),
@@ -263,13 +262,15 @@ class FormatMode(Enum):
263262
checkpoint_missing_warning = (
264263
f"No checkpoint found at {args.src}. Skipping conversion."
265264
)
266-
if args.mode == FormatMode.TORCH_TO_DCP:
265+
if args.mode == FormatMode.TORCH_TO_DCP.value:
267266
if os.path.isfile(args.src):
268267
torch_save_to_dcp(args.src, args.dst)
269268
else:
270269
print(checkpoint_missing_warning)
271-
elif args.mode == FormatMode.DCP_TO_TORCH:
270+
elif args.mode == FormatMode.DCP_TO_TORCH.value:
272271
if os.path.isdir(args.src):
273272
dcp_to_torch_save(args.src, args.dst)
274273
else:
275274
print(checkpoint_missing_warning)
275+
else:
276+
raise ValueError(f"Unknown conversion mode: {args.mode}")

0 commit comments

Comments
 (0)
0