Skip to content

Instantly share code, notes, and snippets.

@marduk191
marduk191 / pt_to_safe.py
Last active July 9, 2025 00:44 — forked from silveroxides/pt_to_safe.py
Pytorch Model to Safetensors converter
# created by https://gist.github.com/silveroxides
import torch
from safetensors.torch import save_file
import argparse
import os
def convert_pt_to_safetensors(model_path, safe_path):
model = torch.load(model_path, map_location="cpu", weights_only=False)
metadata = {"format":"pt"}
save_file(model, safe_path, metadata)