feat: skip already processed shards (resume support)
This commit is contained in:
@@ -36,6 +36,12 @@ def streaming_quantize(model_path: str, output_path: str):
|
|||||||
print(f"Found {len(shards)} shards\n")
|
print(f"Found {len(shards)} shards\n")
|
||||||
|
|
||||||
for idx, shard_file in enumerate(shards):
|
for idx, shard_file in enumerate(shards):
|
||||||
|
# Skip already processed shards
|
||||||
|
shard_name = f"model-{idx:05d}-of-{len(shards):05d}.safetensors"
|
||||||
|
if (output_path / shard_name).exists():
|
||||||
|
print(f"[{idx+1}/{len(shards)}] {Path(shard_file).name} (already saved, skipping)")
|
||||||
|
continue
|
||||||
|
|
||||||
print(f"[{idx+1}/{len(shards)}] {Path(shard_file).name}")
|
print(f"[{idx+1}/{len(shards)}] {Path(shard_file).name}")
|
||||||
|
|
||||||
state_dict = load_file(shard_file, device="cuda:0")
|
state_dict = load_file(shard_file, device="cuda:0")
|
||||||
|
|||||||
Reference in New Issue
Block a user