fix: use 1-indexing for shard names (model-00001-of-00016)
This commit is contained in:
@@ -43,11 +43,11 @@ def streaming_quantize(model_path: str, output_path: str):
|
|||||||
|
|
||||||
def process_shard(idx, shard_file, gpu_id):
|
def process_shard(idx, shard_file, gpu_id):
|
||||||
"""Process a single shard (called per-GPU)."""
|
"""Process a single shard (called per-GPU)."""
|
||||||
shard_name = f"model-{idx:05d}-of-{len(shards):05d}.safetensors"
|
shard_name = f"model-{idx+1:05d}-of-{len(shards):05d}.safetensors"
|
||||||
if (output_path / shard_name).exists():
|
if (output_path / shard_name).exists():
|
||||||
return
|
return
|
||||||
|
|
||||||
print(f"[{idx}/{len(shards)}] {Path(shard_file).name} (GPU {gpu_id})")
|
print(f"[{idx+1}/{len(shards)}] {Path(shard_file).name} (GPU {gpu_id})")
|
||||||
|
|
||||||
# Load to assigned GPU
|
# Load to assigned GPU
|
||||||
state_dict = load_file(shard_file, device=f"cuda:{gpu_id}")
|
state_dict = load_file(shard_file, device=f"cuda:{gpu_id}")
|
||||||
@@ -88,7 +88,7 @@ def streaming_quantize(model_path: str, output_path: str):
|
|||||||
# Find first unsaved shard
|
# Find first unsaved shard
|
||||||
start_idx = 0
|
start_idx = 0
|
||||||
for idx in range(len(shards)):
|
for idx in range(len(shards)):
|
||||||
shard_name = f"model-{idx:05d}-of-{len(shards):05d}.safetensors"
|
shard_name = f"model-{idx+1:05d}-of-{len(shards):05d}.safetensors"
|
||||||
if not (output_path / shard_name).exists():
|
if not (output_path / shard_name).exists():
|
||||||
start_idx = idx
|
start_idx = idx
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user