From 61ed6cb896848658ae41080d3202bb387c375c1e Mon Sep 17 00:00:00 2001 From: pi-lane Date: Mon, 16 Nov 2026 04:49:04 -0400 Subject: [PATCH 1/2] kernel-set-check: a documented _m16 twin is a WARN, anything else is a FAIL Re-lands the split that was pushed to #2605 AFTER it merged (01:38:26Z) and was therefore lost: main still has the pre-split form, which FAILs even a documented _m16 twin pair. That now contradicts engine#2611, whose open_prefill sizes the context from the twin 16 rows and says so -- the loader runs that pack, so refusing it at validation would block something the engine supports. So the two shapes are separated by name: a stem and its own _m16 sibling are a WARN (correct but slow, 16 rows a chunk), and any other identical-content pair is still a FAIL because nothing reconciles those. Arms updated to match, including the one that had encoded the old intent (its fixture used the twin shape). kernel_set_check: all cases ok. --- scripts/kernel-set-check.sh | 33 +++++++++++++++++++++++++++------ tests/kernel_set_check_test.sh | 13 +++++++++++-- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/scripts/kernel-set-check.sh b/scripts/kernel-set-check.sh index a5d703463..28023af89 100755 --- a/scripts/kernel-set-check.sh +++ b/scripts/kernel-set-check.sh @@ -229,17 +229,38 @@ fi # engine#2599: two ELFs with the same content under different names is a refusal. See the header for why a # hash is the only host-side instrument that can see it. check_twins() { - local dir=$1 dup + # engine#2611 tolerates exactly ONE shape of twin at load: a prefill ELF byte-identical to its own `_m16` + # sibling, where open_prefill sizes the context from the twin's 16 rows and says so. That pack is correct but + # SLOW (16 rows a chunk instead of 128), so it is a WARNING here -- refusing it would block a pack the loader + # now runs. Any OTHER identical pair has no such reconciliation and stays a FAIL. + local dir=$1 dup fail_list="" warn_list="" h name prev="" prevname="" dup=$(find "$dir" -maxdepth 2 -name '*.elf' -type f -print0 2>/dev/null | - xargs -0 -r md5sum 2>/dev/null | sort | awk '{h=$1; $1=""; if (h==prev) print prevname " and" $0; prev=h; prevname=$0}') - if [ -n "$dup" ]; then - printf 'FAIL %s: ELFs with identical content under different names (a copied twin computes the wrong M):\n%s\n' \ - "$(basename "$dir")" "$dup" + xargs -0 -r md5sum 2>/dev/null | sort | awk '{print $1, $2}') + while read -r h name; do + [ -n "$h" ] || continue + if [ "$h" = "$prev" ]; then + local base_a=${prevname##*/} base_b=${name##*/} + if [ "${base_b%_m16.elf}" = "${base_a%.elf}" ] || [ "${base_a%_m16.elf}" = "${base_b%.elf}" ]; then + warn_list="$warn_list + $prevname and $name (documented _m16 twin: loader sizes from 16 rows)" + else + fail_list="$fail_list + $prevname and $name" + fi + fi + prev=$h; prevname=$name + done <<< "$dup" + if [ -n "$warn_list" ]; then + printf 'WARN %s: byte-identical ELF twin(s) this build tolerates but does not exploit:%s\n' \ + "$(basename "$dir")" "$warn_list" + fi + if [ -n "$fail_list" ]; then + printf 'FAIL %s: ELFs with identical content under names that are NOT a documented _m16 twin:%s\n' \ + "$(basename "$dir")" "$fail_list" return 1 fi return 0 } - rc=0 for dir in "$@"; do check_set "$dir" || { rc=$?; [ "$rc" -gt 1 ] && rc=2; } diff --git a/tests/kernel_set_check_test.sh b/tests/kernel_set_check_test.sh index c5a8aa73e..2f81795e9 100755 --- a/tests/kernel_set_check_test.sh +++ b/tests/kernel_set_check_test.sh @@ -236,16 +236,25 @@ mkdir -p "$tmp/twin/good" "$tmp/twin/dup" printf 'A' > "$tmp/twin/good/full_i8_O_K768_N768_b8.elf" printf 'B' > "$tmp/twin/good/full_i8_O_K768_N768_b8_m16.elf" printf 'A' > "$tmp/twin/dup/full_i8_O_K768_N768_b8.elf" -printf 'A' > "$tmp/twin/dup/full_i8_O_K768_N768_b8_m16.elf" +printf 'A' > "$tmp/twin/dup/full_i8_GU_K768_N3072_b8.elf" # NOT a _m16 twin: no documented reconciliation "$script" "$tmp/twin/good" > "$tmp/out21" 2>&1 check $([ $? -ne 0 ] || ! has "$tmp/out21" "identical content" && echo ok || echo fail) \ "distinct ELFs are not reported as twins" "$script" "$tmp/twin/dup" > "$tmp/out22" 2>&1 check $(has "$tmp/out22" "identical content" && echo ok || echo fail) \ "two ELFs with the same content are refused" -check $(has "$tmp/out22" "full_i8_O_K768_N768_b8.elf" && has "$tmp/out22" "_m16.elf" && echo ok || echo fail) \ +check $(has "$tmp/out22" "full_i8_O_K768_N768_b8.elf" && has "$tmp/out22" "full_i8_GU_K768_N3072_b8.elf" && echo ok || echo fail) \ "... and both paths are named" +# engine#2611 tolerates exactly the documented _m16 twin shape at load (16 rows a chunk, correct but slow), +# so that pair is a WARNING here; refusing it would block a pack the loader runs. +mkdir -p "$tmp/twin/doc" +printf 'A' > "$tmp/twin/doc/full_i8_O_K768_N768_b8.elf" +printf 'A' > "$tmp/twin/doc/full_i8_O_K768_N768_b8_m16.elf" +"$script" "$tmp/twin/doc" > "$tmp/out23" 2>&1 +check $(has "$tmp/out23" "WARN" && ! has "$tmp/out23" "NOT a documented" && echo ok || echo fail) \ + "a byte-identical _m16 twin pair is warned about, not refused" + if [ "$fails" -ne 0 ]; then printf 'kernel_set_check: %d failure(s)\n' "$fails" exit 1 From cfeed2f4df40746960d10667ab2e20c39e3fd529 Mon Sep 17 00:00:00 2001 From: pi-lane Date: Mon, 16 Nov 2026 07:19:00 -0400 Subject: [PATCH 2/2] kernel-set-check: classify an ELF twin by GEOMETRY, so the real sets pass The 08:51Z and 09:52Z reviews on this PR showed the rule refusing every real bonsai2-27B set on the box. The name-suffix test was wrong about what a twin IS: - kernels-stock: full_i8_G_K5120_N17408.elf == full_i8_U_K5120_N17408.elf -- gate and up are the same design, so ONE ELF serves both roles and the stock set ships exactly that; - kernels-m16: the same in the _m16 flavour; - kernels: each stem with its _m16 sibling (7 pairs) plus a cross-suffix pair, all the same geometry. None of that is the #2599 defect. The defect is one build copied over ANOTHER design's name, which shows up as identical content under DIFFERENT K or N -- a 128-row chunk computing 16 rows. So the comparison is now on the `_K_N` geometry: equal => WARN (expected, and the loader reroutes a _m16 by name), not equal => FAIL. Arms added for the three real-set shapes (stock, m16, cross-suffix) and for the genuine defect (same bytes, K5120_N17408 vs K5120_N5120). kernel_set_check: all cases ok. --- scripts/kernel-set-check.sh | 17 +++++++++++++---- tests/kernel_set_check_test.sh | 28 ++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/scripts/kernel-set-check.sh b/scripts/kernel-set-check.sh index 28023af89..7b7bb931b 100755 --- a/scripts/kernel-set-check.sh +++ b/scripts/kernel-set-check.sh @@ -240,9 +240,18 @@ check_twins() { [ -n "$h" ] || continue if [ "$h" = "$prev" ]; then local base_a=${prevname##*/} base_b=${name##*/} - if [ "${base_b%_m16.elf}" = "${base_a%.elf}" ] || [ "${base_a%_m16.elf}" = "${base_b%.elf}" ]; then + # Compare the GEOMETRY, not the role or the suffix. Identical content is expected -- and correct -- + # when two names encode the same design: gate and up are both K5120 x N17408, so one ELF serves both + # roles and the stock sets ship it that way (engine#2599 review at 08:51Z). A `_m16` / `_t2s2_m16` + # suffix is the same design at a smaller M, which open_prefill reroutes and notes by name. Identical + # content under DIFFERENT K or N is the defect: one build copied over another's name, so a 128-row + # chunk computes 16 rows. + local ga gb + ga=$(printf '%s' "$base_a" | grep -oE '_K[0-9]+_N[0-9]+' | head -1) + gb=$(printf '%s' "$base_b" | grep -oE '_K[0-9]+_N[0-9]+' | head -1) + if [ -n "$ga" ] && [ "$ga" = "$gb" ]; then warn_list="$warn_list - $prevname and $name (documented _m16 twin: loader sizes from 16 rows)" + $prevname and $name (same geometry: one design under two role/suffix names)" else fail_list="$fail_list $prevname and $name" @@ -251,11 +260,11 @@ check_twins() { prev=$h; prevname=$name done <<< "$dup" if [ -n "$warn_list" ]; then - printf 'WARN %s: byte-identical ELF twin(s) this build tolerates but does not exploit:%s\n' \ + printf 'WARN %s: byte-identical ELFs that encode the same geometry (expected: gate and up share one design, and a _m16 twin is the same design at a smaller M):%s\n' \ "$(basename "$dir")" "$warn_list" fi if [ -n "$fail_list" ]; then - printf 'FAIL %s: ELFs with identical content under names that are NOT a documented _m16 twin:%s\n' \ + printf 'FAIL %s: ELFs with identical content under names with DIFFERENT geometry (one build copied over another name):%s\n' \ "$(basename "$dir")" "$fail_list" return 1 fi diff --git a/tests/kernel_set_check_test.sh b/tests/kernel_set_check_test.sh index 2f81795e9..1f9c7c13a 100755 --- a/tests/kernel_set_check_test.sh +++ b/tests/kernel_set_check_test.sh @@ -246,14 +246,26 @@ check $(has "$tmp/out22" "identical content" && echo ok || echo fail) \ check $(has "$tmp/out22" "full_i8_O_K768_N768_b8.elf" && has "$tmp/out22" "full_i8_GU_K768_N3072_b8.elf" && echo ok || echo fail) \ "... and both paths are named" -# engine#2611 tolerates exactly the documented _m16 twin shape at load (16 rows a chunk, correct but slow), -# so that pair is a WARNING here; refusing it would block a pack the loader runs. -mkdir -p "$tmp/twin/doc" -printf 'A' > "$tmp/twin/doc/full_i8_O_K768_N768_b8.elf" -printf 'A' > "$tmp/twin/doc/full_i8_O_K768_N768_b8_m16.elf" -"$script" "$tmp/twin/doc" > "$tmp/out23" 2>&1 -check $(has "$tmp/out23" "WARN" && ! has "$tmp/out23" "NOT a documented" && echo ok || echo fail) \ - "a byte-identical _m16 twin pair is warned about, not refused" +# engine#2599 review (08:51Z): the real sets ship ONE ELF serving two roles when the geometry matches -- gate +# and up are both K5120 x N17408 -- and a `_m16` twin is the same design at a smaller M. Both are expected, so +# both WARN. Identical content under DIFFERENT geometry is the defect and still FAILs. +mkdir -p "$tmp/twin/real_stock" "$tmp/twin/real_m16" "$tmp/twin/real_cross" "$tmp/twin/real_bad" +printf 'A' > "$tmp/twin/real_stock/full_i8_G_K5120_N17408.elf" +printf 'A' > "$tmp/twin/real_stock/full_i8_U_K5120_N17408.elf" +printf 'A' > "$tmp/twin/real_m16/full_i8_G_K5120_N17408_m16.elf" +printf 'A' > "$tmp/twin/real_m16/full_i8_U_K5120_N17408_m16.elf" +printf 'A' > "$tmp/twin/real_cross/full_i8_G_K5120_N17408_m16.elf" +printf 'A' > "$tmp/twin/real_cross/full_i8_U_K5120_N17408.elf" +printf 'A' > "$tmp/twin/real_bad/full_i8_G_K5120_N17408.elf" +printf 'A' > "$tmp/twin/real_bad/full_i8_U_K5120_N5120.elf" +for d in real_stock real_m16 real_cross; do + "$script" "$tmp/twin/$d" > "$tmp/out-$d" 2>&1 + check $(has "$tmp/out-$d" "WARN" && ! has "$tmp/out-$d" "DIFFERENT geometry" && echo ok || echo fail) \ + "a real-set shape ($d) is warned about, not refused" +done +"$script" "$tmp/twin/real_bad" > "$tmp/out-real_bad" 2>&1 +check $(has "$tmp/out-real_bad" "DIFFERENT geometry" && echo ok || echo fail) \ + "identical content under different geometry is refused" if [ "$fails" -ne 0 ]; then printf 'kernel_set_check: %d failure(s)\n' "$fails"