From 5b9fd32088111e175d600de3a395bf6069908157 Mon Sep 17 00:00:00 2001 From: t Date: Mon, 9 Nov 2026 19:13:02 -0400 Subject: [PATCH] fconst19_measure: tolerate, report and skip a 1.9 tail that is LARGER than its 1.8 twin's (refs #1740) The tool refused any pair whose tails differ in length -- and on the 1.9 line that happens whenever the pack carries more in its tail than its 1.8 twin does, which is the `hidden 1536` geometry (engine#1740): Qwen-2.5_1.5B_Instruct 1.9 tail 262,147,136 B vs 1.8 tail 134,314,560 B Qwen2.5-Coder-1.5B-Instruct 1.9 tail same shape, same ~15 % content residual and the 1.8 figure there is exactly `attn_payload_off(1536) 3,136 + 2374 x attn_tile_bytes(1536) 56,576`, i.e. the twin's tail **is** the head while the 1.9 tail is the head plus more. The rule the tool measures describes the LAYER BLOCKS, so a larger tail is not a layout disagreement: the surplus is now reported and left out of the comparison instead of aborting the run before anything is measured. A 1.9 tail *shorter* than its twin's is still refused -- that direction means the files genuinely disagree. No change for the pairs that already verify: on the 0.5B pair the surplus is 0 and the row is unchanged {896, 14, 24, 1856, 8, 1, 69632}, measured with this patch in place. What the patch buys is a diagnosable failure instead of a bare refusal: with it, both `hidden 1536` pairs report a ~131.5 MB residual (15.2 %) that is invariant across every candidate, which is the evidence #1740 now rests on -- those 1.9 builds are not header-only repacks of their twins. Verified: the 0.5B pair still produces its row (above); the two 1536 pairs now report residuals instead of aborting; `tools/copyright.py --check` rc 0 with the tree staged; `git add ` only; host-side, no device. --- tools/fconst19_measure.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/fconst19_measure.py b/tools/fconst19_measure.py index a458696cf..80033c91e 100755 --- a/tools/fconst19_measure.py +++ b/tools/fconst19_measure.py @@ -90,8 +90,14 @@ def candidates(a, b, heads, layers): hdr_len = heads * 4 header_off, stride9 = find_headers(b, heads, layers) stride8 = stride9 - hdr_len - if len(a) - layers * stride8 != len(b) - layers * stride9: - raise SystemExit("the two files' tails differ in length") + # engine#1740: a 1.9 pack's tail can carry MORE than its 1.8 twin's -- the 1.5B's 1.9 tail is 262,147,136 B against the 1.8's + # 134,314,560 B, and that 1.8 figure is exactly `attn_payload_off(1536) + 2374 x attn_tile_bytes(1536)`, i.e. the twin's tail IS + # the head and the 1.9 tail is the head plus more. The rule describes the LAYER BLOCKS, so a surplus is not a layout disagreement: + # it is reported and not compared. A 1.9 tail SHORTER than its twin's still means the two files disagree. + tail8 = len(a) - layers * stride8 + tail9 = len(b) - layers * stride9 + if tail9 < tail8: + raise SystemExit(f"the 1.9 tail is shorter than its 1.8 twin's ({tail9} B < {tail8} B): the files disagree") a0, b0 = a[:stride8], b[:stride9] if a0[header_off:] != b0[header_off + hdr_len:]: raise SystemExit("block 0's tail does not match at -4*NH") @@ -162,8 +168,11 @@ def main(): # So 1e-5 sits 3.7x above the worst LEGITIMATE residual and 148x below the mildest WRONG rule -- it cannot # admit a misaligned rule, and it does admit the few-hundred-stray-codes case a fine-tune's twin produces. TOL = 1e-5 + _ho, _s9 = find_headers(b, heads, layers) + surplus = max(0, (len(b) - layers * _s9) - (len(a) - layers * (_s9 - hdr_len))) + b_cmp = b[:len(b) - surplus] if surplus else b for p in candidates(a, b, heads, layers): - got = normalise(b, layers, p, hdr_len) + got = normalise(b_cmp, layers, p, hdr_len) if len(got) != len(a): print(f"# candidate prefix={p[0]} n={p[1]} tile={p[2]} rot={p[3]}: length {len(got)} != {len(a)}", file=sys.stderr) @@ -175,6 +184,8 @@ def main(): if differ <= max(0, int(len(a) * TOL)): prefix, n, tile, rot, header_off, stride9 = p note = "byte for byte" if differ == 0 else f"{differ} of {len(a)} bytes differ ({100.0 * differ / len(a):.2e} %)" + if surplus: + note += f"; the 1.9 tail carries {surplus} B past its 1.8 twin's, not compared (engine#1740)" if args.json: print(json.dumps({"hidden": hidden, "heads": heads, "layers": layers, "prefix": prefix, "n_tiles": n, "tile": tile, "rot": rot, "header_off": header_off,