Skip to content

Commit

Permalink
fix non contiguous tensor value error in save_pretrained (#32422)
Browse files Browse the repository at this point in the history
Signed-off-by: duzhanwei <duzhanwei@bytedance.com>
Co-authored-by: duzhanwei <duzhanwei@bytedance.com>
  • Loading branch information
congcongke and duzhanwei authored Aug 9, 2024
1 parent e4522fe commit e7f4ace
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2746,7 +2746,7 @@ def save_pretrained(
if module_map:
filename_to_tensors = logging.tqdm(filename_to_tensors, desc="Saving checkpoint shards")
for shard_file, tensors in filename_to_tensors:
shard = {tensor: state_dict[tensor] for tensor in tensors}
shard = {tensor: state_dict[tensor].contiguous() for tensor in tensors}
# remake shard with onloaded parameters if necessary
if module_map:
if accelerate_version < version.parse("0.31"):
Expand Down

0 comments on commit e7f4ace

Please sign in to comment.