diff --git a/scripts/kernel-set-check.sh b/scripts/kernel-set-check.sh index 242862275..a5d703463 100755 --- a/scripts/kernel-set-check.sh +++ b/scripts/kernel-set-check.sh @@ -18,6 +18,13 @@ # # scripts/kernel-set-check.sh [--pack ] [ ...] # +# +# engine#2599: ALSO refuses a set that carries two ELFs with the SAME CONTENT under different names. The +# bonsai2 pack shipped prefill ELFs byte-identical to their _m16 twins, so a 128-row chunk computed 16 rows +# and every host-side check passed: the loaded file had the right NAME and the right per-tile widths, and the +# AIE image carries no readable design M (e_shnum=0, no symtab, no design string -- measured on this lane's +# packs), so nothing but a hash of the file can tell the two designs apart. A twin inside one pack is either +# a packaging accident or a design that was never widened; both are refusals, not warnings. # Why this exists: the release candidate serves small models at 87-101 tok/s with the set that ships beside it, and a # build of current main refused that same set with "layer ELFs: the NB 2 and 3 builds differ in size". Neither the set # nor the kernels were wrong — the two sides came from different revisions of the private repository, one on each side of @@ -219,9 +226,24 @@ if [ $# -eq 0 ]; then exit 2 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 + 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" + return 1 + fi + return 0 +} + rc=0 for dir in "$@"; do check_set "$dir" || { rc=$?; [ "$rc" -gt 1 ] && rc=2; } + check_twins "$dir" || rc=1 done if [ -n "$pack" ]; then diff --git a/tests/kernel_set_check_test.sh b/tests/kernel_set_check_test.sh index 3b3a24ad1..c5a8aa73e 100755 --- a/tests/kernel_set_check_test.sh +++ b/tests/kernel_set_check_test.sh @@ -231,6 +231,21 @@ check $([ $? -eq 0 ] && echo ok || echo fail) "layer directories with a suffix: check $(has "$tmp/out20" "3 layer-indexed" && ! has "$tmp/out20" "other" && echo ok || echo fail) \ "... all three counted as layer-indexed, none as other" +# engine#2599: two ELFs with identical content under different names must fail, and a clean set must not. +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" +"$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) \ + "... and both paths are named" + if [ "$fails" -ne 0 ]; then printf 'kernel_set_check: %d failure(s)\n' "$fails" exit 1