Skip to content

Commit

Permalink
added scripts/convert_pt_to_safetensors.py
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-17 committed Nov 20, 2024
1 parent 8aac2ea commit c21087d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/convert_pt_to_safetensors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import logging

import torch

from olmo.aliases import PathOrStr
from olmo.safetensors_util import state_dict_to_safetensors_file


def main(input: PathOrStr, output: PathOrStr):
state_dict = torch.load(input)
state_dict_to_safetensors_file(state_dict, output)


if __name__ == "__main__":
import argparse

parser = argparse.ArgumentParser(
prog=__file__, description="Convert state dicts in pt format to state dicts in safetensors format."
)
parser.add_argument("input")
parser.add_argument("output")
args = parser.parse_args()

logging.basicConfig(level=logging.INFO)
main(args.input, args.output)

0 comments on commit c21087d

Please sign in to comment.