tarekfurthy commited on
Commit
2037f4f
·
verified ·
1 Parent(s): 2b18b09

fix NameError: import time (the quantize timer) + reuse guards so a retry skips 13 min of done work

Browse files

time.time() was used in the new quantize block but never imported. Also: reuse tq1_0_bytes.pkl when it is at full size (the pipeline writes it last) and reuse the rotated f16 base when it is newer than rotation_H.pt. Verified with a symtable pass for names read but never bound -- now none.

Files changed (1) hide show
  1. UPLOAD_1_trnr_ship.py +18 -6
UPLOAD_1_trnr_ship.py CHANGED
@@ -11,7 +11,7 @@
11
  #
12
  # SECURITY: HF_TOKEN below is FULL-ACCESS. Rotate it at huggingface.co/settings/tokens the moment
13
  # this finishes.
14
- import ast, os, re, sys, glob, json, shutil, pickle, tarfile, subprocess
15
  import numpy as np
16
  K = "/kaggle/working"; W = "/tmp/trnr"; SRC = W + "/llama.cpp"
17
  PIN = "16f090f92c0e2ac6dfddcaf93589a9b158c598c7"
@@ -893,7 +893,17 @@ if not os.path.exists(K + "/wiki_rows.pkl"):
893
  P("wiki_rows.pkl + wiki.test.txt ok")
894
 
895
  B("4/8 quantizer (~9 min, GPU) then converter -> rotated base GGUF")
896
- assert SH("cd %s && python -u %s" % (K, K + "/pack_g256.py")) == 0, "pipeline failed -- paste this back"
 
 
 
 
 
 
 
 
 
 
897
  for f in ("tq1_0_bytes.pkl", "rotation_H.pt"):
898
  P("%-16s %.4f GB" % (f, os.path.getsize(K + "/v1_g256/" + f) / 1e9))
899
  # the quantizer re-creates ternary_experts.pt (1.3 GB); free it BEFORE the 13.9 GB conversion
@@ -903,10 +913,12 @@ if os.path.exists(_dbg):
903
  % (os.path.getsize(_dbg) / 1e9))
904
  os.remove(_dbg)
905
  DU("after the quantizer")
906
- BASE = K + "/trnr-base.gguf"
907
- assert SH("cd %s && python -u %s %s --outtype f16 --outfile %s --rot %s/v1_g256/rotation_H.pt"
908
- % (K, K + "/trnr_convert.py", HF, BASE, K)) == 0, "conversion failed -- paste this back"
909
- P("trnr-base.gguf %.3f GB" % (os.path.getsize(BASE) / 1e9))
 
 
910
 
911
  B("5/8 quantize experts -> TQ1_0, splice OUR bytes IN PLACE, validate")
912
  sys.path.insert(0, SRC + "/gguf-py"); import gguf
 
11
  #
12
  # SECURITY: HF_TOKEN below is FULL-ACCESS. Rotate it at huggingface.co/settings/tokens the moment
13
  # this finishes.
14
+ import ast, os, re, sys, glob, json, shutil, pickle, tarfile, subprocess, time
15
  import numpy as np
16
  K = "/kaggle/working"; W = "/tmp/trnr"; SRC = W + "/llama.cpp"
17
  PIN = "16f090f92c0e2ac6dfddcaf93589a9b158c598c7"
 
893
  P("wiki_rows.pkl + wiki.test.txt ok")
894
 
895
  B("4/8 quantizer (~9 min, GPU) then converter -> rotated base GGUF")
896
+ _PKL = K + "/v1_g256/tq1_0_bytes.pkl"
897
+ _ROT = K + "/v1_g256/rotation_H.pt"
898
+ BASE = K + "/trnr-base.gguf"
899
+ # Reuse guards: every one of these artefacts is deterministic given rotation_H.pt, and a failed
900
+ # retry used to redo ~13 minutes of work that was already on disk. The pipeline writes the pkl
901
+ # LAST, so a pkl at full size is a complete one; the converter's output is only reused if it is
902
+ # newer than the rotation it was built from.
903
+ if os.path.exists(_PKL) and os.path.getsize(_PKL) > 1.3e9 and os.path.exists(_ROT):
904
+ P("REUSING tq1_0_bytes.pkl (%.4f GB, written last by a previous run)" % (os.path.getsize(_PKL) / 1e9))
905
+ else:
906
+ assert SH("cd %s && python -u %s" % (K, K + "/pack_g256.py")) == 0, "pipeline failed -- paste this back"
907
  for f in ("tq1_0_bytes.pkl", "rotation_H.pt"):
908
  P("%-16s %.4f GB" % (f, os.path.getsize(K + "/v1_g256/" + f) / 1e9))
909
  # the quantizer re-creates ternary_experts.pt (1.3 GB); free it BEFORE the 13.9 GB conversion
 
913
  % (os.path.getsize(_dbg) / 1e9))
914
  os.remove(_dbg)
915
  DU("after the quantizer")
916
+ if os.path.exists(BASE) and os.path.getsize(BASE) > 13.5e9 and os.path.getmtime(BASE) > os.path.getmtime(_ROT):
917
+ P("REUSING the rotated f16 base (%.3f GB, newer than rotation_H.pt)" % (os.path.getsize(BASE) / 1e9))
918
+ else:
919
+ assert SH("cd %s && python -u %s %s --outtype f16 --outfile %s --rot %s/v1_g256/rotation_H.pt"
920
+ % (K, K + "/trnr_convert.py", HF, BASE, K)) == 0, "conversion failed -- paste this back"
921
+ P("trnr-base.gguf %.3f GB" % (os.path.getsize(BASE) / 1e9))
922
 
923
  B("5/8 quantize experts -> TQ1_0, splice OUR bytes IN PLACE, validate")
924
  sys.path.insert(0, SRC + "/gguf-py"); import gguf