Skip to content

Commit 894cba0

Browse files
authored
fix FSDP save of final model (axolotl-ai-cloud#329)
1 parent 41a4d15 commit 894cba0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: scripts/finetune.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ def terminate_handler(_, __, model):
344344

345345
# TODO do we need this fix? https://huggingface.co/docs/accelerate/usage_guides/fsdp#saving-and-loading
346346
# only save on rank 0, otherwise it corrupts output on multi-GPU when multiple processes attempt to write the same file
347-
if cfg.local_rank == 0:
347+
if cfg.fsdp:
348+
model.save_pretrained(cfg.output_dir)
349+
elif cfg.local_rank == 0:
348350
if cfg.flash_optimum:
349351
model = BetterTransformer.reverse(model)
350352
model.save_pretrained(cfg.output_dir)

0 commit comments

Comments
 (0)