Skip to content

Commit

Permalink
Fix #617
Browse files Browse the repository at this point in the history
  • Loading branch information
carmocca committed Oct 5, 2023
1 parent 82b6814 commit b3efba2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions scripts/convert_hf_checkpoint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import contextlib
import gc
import json
import sys
Expand Down Expand Up @@ -292,12 +291,11 @@ def convert_hf_checkpoint(
with incremental_save(checkpoint_dir / "lit_model.pth") as saver:
# for checkpoints that split the QKV across several files, we need to keep all the bin files
# open, so we use `ExitStack` to close them all together at the end
with contextlib.ExitStack() as stack:
for bin_file in sorted(bin_files):
print("Processing", bin_file)
hf_weights = stack.enter_context(lazy_load(bin_file))
copy_fn(sd, hf_weights, saver=saver, dtype=dtype)
gc.collect()
for bin_file in sorted(bin_files):
print("Processing", bin_file)
hf_weights = lazy_load(bin_file)
copy_fn(sd, hf_weights, saver=saver, dtype=dtype)
gc.collect()
print("Saving converted checkpoint")
saver.save(sd)

Expand Down

0 comments on commit b3efba2

Please sign in to comment.