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

Skip to content

Commit 1ab823a

Browse files
LucasLLCpytorchbot
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 (cherry picked from commit 18c9d46)
1 parent 23961ce commit 1ab823a

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
@@ -240,7 +240,6 @@ def dcp_to_torch_save(
240240
To avoid OOM, it's recommended to only run this function on a single rank.
241241
"""
242242
sd: STATE_DICT_TYPE = {}
243-
244243
_load_state_dict(
245244
sd,
246245
storage_reader=FileSystemReader(dcp_checkpoint_dir),
@@ -298,13 +297,15 @@ class FormatMode(Enum):
298297
checkpoint_missing_warning = (
299298
f"No checkpoint found at {args.src}. Skipping conversion."
300299
)
301-
if args.mode == FormatMode.TORCH_TO_DCP:
300+
if args.mode == FormatMode.TORCH_TO_DCP.value:
302301
if os.path.isfile(args.src):
303302
torch_save_to_dcp(args.src, args.dst)
304303
else:
305304
print(checkpoint_missing_warning)
306-
elif args.mode == FormatMode.DCP_TO_TORCH:
305+
elif args.mode == FormatMode.DCP_TO_TORCH.value:
307306
if os.path.isdir(args.src):
308307
dcp_to_torch_save(args.src, args.dst)
309308
else:
310309
print(checkpoint_missing_warning)
310+
else:
311+
raise ValueError(f"Unknown conversion mode: {args.mode}")

0 commit comments

Comments
 (0)
0