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

FIX: llama-quantize ignored --tensor-type with an F16 positional (llama-quant.cpp:806); use Q8_0 + catch-all .*=F16

Browse files

Overrides only apply when ggml_is_quantized(default_type), and default_type is the positional. With F16 every override was silently skipped, so the output equalled the input and died on ENOSPC at ~5.4 GB = blk.6.ffn_gate_exps. Now the positional is Q8_0 (unlocks overrides), experts -> TQ1_0 first, catch-all .*=F16 second, so Q8_0 quantizes nothing. Hygiene also deletes a partial trnr-mix.gguf from a dead quantize.

Files changed (1) hide show
  1. UPLOAD_1_trnr_ship.py +18 -4
UPLOAD_1_trnr_ship.py CHANGED
@@ -859,6 +859,13 @@ if os.path.exists(_dst) and os.path.exists(K + "/trnr-base.gguf"):
859
  % (os.path.getsize(_dst) / 1e9, os.path.basename(_dst)))
860
  P(" next to a BASE can only have come from a run that failed after copying it")
861
  os.remove(_dst)
 
 
 
 
 
 
 
862
  DU("before anything heavy")
863
 
864
  B("1/8 clone llama.cpp @ pin")
@@ -940,12 +947,19 @@ MIX = K + "/trnr-mix.gguf"
940
  if not os.path.exists(MIX):
941
  NT = str(os.cpu_count() or 4)
942
  ok = False
943
- for rules in ((r"ffn_(gate|up|down)_exps=TQ1_0",),
944
- (r"ffn_gate_exps=TQ1_0", r"ffn_up_exps=TQ1_0", r"ffn_down_exps=TQ1_0"),
945
- (r"blk\.\d+\.ffn_(gate|up|down)_exps=TQ1_0",)):
 
 
 
 
 
 
 
946
  cmd = [QF]
947
  for rr in rules: cmd += ["--tensor-type", rr]
948
- cmd += [F16GG, MIX, "F16", NT]
949
  d = subprocess.run([cmd[0], "--dry-run"] + cmd[1:], capture_output=True, text=True)
950
  if d.returncode != 0:
951
  _msg = ((d.stdout or "") + (d.stderr or "")).strip().splitlines()
 
859
  % (os.path.getsize(_dst) / 1e9, os.path.basename(_dst)))
860
  P(" next to a BASE can only have come from a run that failed after copying it")
861
  os.remove(_dst)
862
+ # a quantize that dies mid-write leaves a partial MIX, and "if not os.path.exists(MIX)" would
863
+ # then reuse it. The correct mix is ~2.5 GB (0.95 GiB non-expert F16 + 1.36 GiB experts).
864
+ _mix = K + "/trnr-mix.gguf"
865
+ if os.path.exists(_mix) and not 2.2e9 <= os.path.getsize(_mix) <= 2.9e9:
866
+ P("freeing %.2f GB: %s is a partial quantize (a correct mix is ~2.5 GB)"
867
+ % (os.path.getsize(_mix) / 1e9, os.path.basename(_mix)))
868
+ os.remove(_mix)
869
  DU("before anything heavy")
870
 
871
  B("1/8 clone llama.cpp @ pin")
 
947
  if not os.path.exists(MIX):
948
  NT = str(os.cpu_count() or 4)
949
  ok = False
950
+ # WHY the positional is Q8_0 and NOT "F16": llama-quant.cpp:806 only honours --tensor-type
951
+ # overrides when ggml_is_quantized(default_type), and default_type is the positional.
952
+ # With "F16" the override block is skipped SILENTLY -- the output equals the input
953
+ # byte-for-byte and the write dies on ENOSPC ~5.4 GB in, at blk.6.ffn_gate_exps, which is
954
+ # exactly what the previous run measured (dry-run still passes: parsing != applying).
955
+ # The catch-all ".*=F16" then keeps every non-expert tensor at F16, so Q8_0 itself never
956
+ # quantizes anything; regex_search takes the FIRST matching pattern, experts first.
957
+ for rules in ((r"ffn_(gate|up|down)_exps=TQ1_0", r".*=F16"),
958
+ (r"ffn_gate_exps=TQ1_0", r"ffn_up_exps=TQ1_0", r"ffn_down_exps=TQ1_0", r".*=F16"),
959
+ (r"blk\.\d+\.ffn_(gate|up|down)_exps=TQ1_0", r".*=F16")):
960
  cmd = [QF]
961
  for rr in rules: cmd += ["--tensor-type", rr]
962
+ cmd += [F16GG, MIX, "Q8_0", NT]
963
  d = subprocess.run([cmd[0], "--dry-run"] + cmd[1:], capture_output=True, text=True)
964
  if d.returncode != 0:
965
  _msg = ((d.stdout or "") + (d.stderr or "")).strip().splitlines()