remove every multi-line continuation and non-ASCII byte from the quantize block (tokenizer robustness)
Browse filesSame logic, single-line statements throughout; apply_stage1's docstring middle-dot is now an ASCII dash. The runner now compiles the bundle before exec and dumps repr() of the offending lines if a SyntaxError appears again.
- UPLOAD_1_trnr_ship.py +6 -9
UPLOAD_1_trnr_ship.py
CHANGED
|
@@ -486,7 +486,7 @@ finally:
|
|
| 486 |
'''
|
| 487 |
SRC_APPLY_STAGE1 = r'''#!/usr/bin/env python3
|
| 488 |
"""
|
| 489 |
-
trnr.cpp
|
| 490 |
|
| 491 |
Design
|
| 492 |
------
|
|
@@ -936,8 +936,8 @@ if not os.path.exists(MIX):
|
|
| 936 |
cmd += [F16GG, MIX, "F16", NT]
|
| 937 |
d = subprocess.run([cmd[0], "--dry-run"] + cmd[1:], capture_output=True, text=True)
|
| 938 |
if d.returncode != 0:
|
| 939 |
-
|
| 940 |
-
|
| 941 |
continue
|
| 942 |
t0 = time.time()
|
| 943 |
r = subprocess.run(cmd, capture_output=True, text=True)
|
|
@@ -954,12 +954,9 @@ _types = {}
|
|
| 954 |
for k in _ex:
|
| 955 |
n = _items[k].tensor_type.name
|
| 956 |
_types[n] = _types.get(n, 0) + 1
|
| 957 |
-
P("expert tensors: %d types %s bytes %.4f GB"
|
| 958 |
-
|
| 959 |
-
assert
|
| 960 |
-
"MIX WRONG -- not all 48 expert tensors are TQ1_0: %s" % _types
|
| 961 |
-
assert _items["trnr.rot.weight"].tensor_type.name == "F16", \
|
| 962 |
-
"trnr.rot went ternary -- a ternarized R is not orthogonal and every expert breaks"
|
| 963 |
P("MIX CORRECT -- 48 TQ1_0 expert tensors, trnr.rot still F16")
|
| 964 |
P("freeing %.2f GB: the all-f16 base, superseded by the mix" % (os.path.getsize(F16GG) / 1e9))
|
| 965 |
os.remove(F16GG)
|
|
|
|
| 486 |
'''
|
| 487 |
SRC_APPLY_STAGE1 = r'''#!/usr/bin/env python3
|
| 488 |
"""
|
| 489 |
+
trnr.cpp - STAGE 1 patcher -- wire the expert-input rotation into OLMoE.
|
| 490 |
|
| 491 |
Design
|
| 492 |
------
|
|
|
|
| 936 |
cmd += [F16GG, MIX, "F16", NT]
|
| 937 |
d = subprocess.run([cmd[0], "--dry-run"] + cmd[1:], capture_output=True, text=True)
|
| 938 |
if d.returncode != 0:
|
| 939 |
+
_msg = ((d.stdout or "") + (d.stderr or "")).strip().splitlines()
|
| 940 |
+
P("rejected %-40s %s" % (rules[0], (_msg[-1] if _msg else "")[:80]))
|
| 941 |
continue
|
| 942 |
t0 = time.time()
|
| 943 |
r = subprocess.run(cmd, capture_output=True, text=True)
|
|
|
|
| 954 |
for k in _ex:
|
| 955 |
n = _items[k].tensor_type.name
|
| 956 |
_types[n] = _types.get(n, 0) + 1
|
| 957 |
+
P("expert tensors: %d types %s bytes %.4f GB" % (len(_ex), _types, sum(int(_items[k].data.nbytes) for k in _ex) / 1e9))
|
| 958 |
+
assert len(_ex) == 48 and all(_items[k].tensor_type.name == "TQ1_0" for k in _ex), "MIX WRONG -- not all 48 expert tensors are TQ1_0: %s" % _types
|
| 959 |
+
assert _items["trnr.rot.weight"].tensor_type.name == "F16", "trnr.rot went ternary -- a ternarized R is not orthogonal and every expert breaks"
|
|
|
|
|
|
|
|
|
|
| 960 |
P("MIX CORRECT -- 48 TQ1_0 expert tensors, trnr.rot still F16")
|
| 961 |
P("freeing %.2f GB: the all-f16 base, superseded by the mix" % (os.path.getsize(F16GG) / 1e9))
|
| 962 |
os.remove(F16GG)
|