requant_gguf: check the output's free space against the plan before writing (or in --dry-run, return 3)
The release runbook promises the pack/requant builder checks free space before it writes (DEEPSEEK-RELEASE.MD 9.6 item 5); it did not. --dry-run now prints 'space: N GB planned, M GB free on <fs>' and returns 3 when 98% of the free space does not cover the plan, so 'requant_dry && requant' cannot start a run that will fill the disk; a real run raises instead. With --resume only the bytes still missing are counted against the free space. Verified on the box with two recipes that do not fit /data today: rq3 (224.3 GB planned against 128.6 GB free) and rq_gu3 (251.2 GB against 128.6 GB) both refuse with the numbers printed, rc 3 in dry-run. pack_gguf's own output is a few MB (tensors.txt, engram.bin, tokenizer) and needs no guard.
This commit is contained in:
1 parent
996b8a4044
commit
734ada7e1b
1 file changed
+19
-2
@@ -37,6 +37,7 @@ import multiprocessing as mp
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
import struct
|
||||
import sys
|
||||
import time
|
||||
@@ -398,8 +399,24 @@ def main() -> int:
|
||||
total = sum(o[2] for o in outs)
|
||||
print("plan: %d shards, %.1f GB (%s), %d jobs" % (len(outs), total / 1e9,
|
||||
", ".join("%s %.1f GB" % (k, v / 1e9) for k, v in sorted(plan_sizes.items())), len(jobs)), flush=True)
|
||||
if a.dry_run:
|
||||
return 0
|
||||
# the free-space check the release runbook promises (DEEPSEEK-RELEASE.MD 9.6 item 5): the plan's bytes against what
|
||||
# the output's filesystem has, with 2% of headroom. It runs in --dry-run too, so the operator sees the verdict
|
||||
# before committing hours of CPU.
|
||||
probe = out if out.exists() else next((p for p in [out.parent, pathlib.Path("/")] if p.exists()), pathlib.Path("/"))
|
||||
du = shutil.disk_usage(probe)
|
||||
print("space: %.1f GB planned, %.1f GB free on %s%s" % (total / 1e9, du.free / 1e9, probe,
|
||||
"" if du.free * 0.98 >= total else " <- NOT ENOUGH"), flush=True)
|
||||
if a.dry_run: # nothing is written: report the verdict, and 3 when the space is short (so `--dry-run && requant` works)
|
||||
return 0 if du.free * 0.98 >= total else 3
|
||||
if a.resume:
|
||||
have = sum(p.stat().st_size for p in out.glob("*.gguf") if p.is_file()) if out.exists() else 0
|
||||
need = max(0, total - have)
|
||||
if du.free * 0.98 < need:
|
||||
raise SystemExit("%s: %d GB free, %d GB more needed (%d GB already written) - free space first"
|
||||
% (out, du.free / 1e9, need / 1e9, have / 1e9))
|
||||
elif du.free * 0.98 < total:
|
||||
raise SystemExit("%s: %d GB free, %d GB needed - free space first (or --out elsewhere)"
|
||||
% (out, du.free / 1e9, total / 1e9))
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
for opath, head, size in outs:
|
||||
if a.resume and opath.is_file() and opath.stat().st_size == size:
|
||||
|
||||
Reference in new issue
Block a user