fix: add argparser and fix Path issue

This commit is contained in:
Christian Medina
2026-07-03 04:09:23 -04:00
parent c84a3b6252
commit 3498a40390

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""Convert torch.save quantized shards to safetensors format."""
import argparse
import gc
import torch
from pathlib import Path
@@ -15,7 +16,7 @@ def convert_shards(model_path):
print(f"Converting {len(shards)} shards to safetensors format...\n")
for i, shard_path in enumerate(shards):
print(f"Converting shard {i+1}/{len(shards)}: {shard_path.name}")
print(f"Converting shard {i+1}/{len(shards)}: {Path(shard_path).name}")
# Load torch.save format
ckpt = torch.load(shard_path, map_location="cpu", weights_only=False)
@@ -42,4 +43,7 @@ def convert_shards(model_path):
if __name__ == "__main__":
convert_shards("/data/models/Ornith-1.0-35B-nf4")
parser = argparse.ArgumentParser()
parser.add_argument("--model-path", type=str, default="/data/models/Ornith-1.0-35B-nf4")
args = parser.parse_args()
convert_shards(args.model_path)