Skip to content

Commit

Permalink
Add max shard size to transformers save_pretrained (#1648)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-chu authored Nov 7, 2024
1 parent a16b93d commit bec9ecd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions llmfoundry/callbacks/hf_checkpointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,10 @@ def tensor_hook(
) if is_te_imported and state.precision == Precision.AMP_FP8 else contextlib.nullcontext(
)
with context_manager:
new_model_instance.save_pretrained(temp_save_dir)
new_model_instance.save_pretrained(
temp_save_dir,
max_shard_size='1GB',
)
if original_tokenizer is not None:
assert isinstance(
original_tokenizer,
Expand Down Expand Up @@ -799,7 +802,10 @@ def tensor_hook(
new_model_instance = self.transform_model_pre_registration(
new_model_instance,
)
new_model_instance.save_pretrained(register_save_dir)
new_model_instance.save_pretrained(
register_save_dir,
max_shard_size='1GB',
)
if original_tokenizer:
original_tokenizer.save_pretrained(register_save_dir)

Expand Down

0 comments on commit bec9ecd

Please sign in to comment.