Skip to content

Commit

Permalink
fix non contiguous tensor value error in save_pretrained
Browse files Browse the repository at this point in the history
Signed-off-by: duzhanwei <duzhanwei@bytedance.com>
  • Loading branch information
duzhanwei committed Aug 7, 2024
1 parent 621fb3c commit a5dcb8f
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 @@ -2742,7 +2742,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 a5dcb8f

Please sign in to comment.