Skip to content

Commit

Permalink
Use hardlinks rather than copies for checkpoint creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
janchorowski committed Dec 30, 2020
1 parent 3858c03 commit 904d119
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fairseq/checkpoint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,14 @@ def is_better(a, b):
if len(checkpoints) > 0:
trainer.save_checkpoint(checkpoints[0], extra_state)
for cp in checkpoints[1:]:
assert PathManager.copy(
checkpoints[0], cp, overwrite=True
), f"Failed to copy {checkpoints[0]} to {cp}"
# assert PathManager.copy(
# checkpoints[0], cp, overwrite=True
# ), f"Failed to copy {checkpoints[0]} to {cp}"
try:
os.remove(cp)
except:
pass
os.link(checkpoints[0], cp)

write_timer.stop()
logger.info(
Expand Down

0 comments on commit 904d119

Please sign in to comment.