From 3f955dee6fd99c8843000118a3b39a82da4d4850 Mon Sep 17 00:00:00 2001 From: zaneni6 Date: Mon, 23 Nov 2026 07:57:24 -0800 Subject: [PATCH 1/2] fix(Hy_MT2): the stack check fails instead of skipping what it cannot read Hy_MT2's check_peano_stack.sh skipped a core, and so passed, whenever it could not work something out: a stack_depth.py failure (objdump error, recursion, a traceback) left its output empty, which the script read as "no stack"; a disassembly without functions printed nothing; missing _sp_start_value_DM_stack or no buffer above it only warned; a missing ELF was skipped. The other three copies of the check were made to fail on all of these; this one now does the same, still using stack_depth.py for the deepest call chain. stack_depth.py exits with an error when it finds no function instead of printing nothing. Checked with a fake llvm-objdump/llvm-nm in WSL: fits, 97% (warns), overflow, stack_depth.py failure, no functions, no stack start, no bounding buffer, missing ELF and no arguments each give the right result. Co-Authored-By: Claude --- .../decoding/makefiles/check_peano_stack.sh | 64 +++++++++++++++---- .../decoding/makefiles/stack_depth.py | 5 +- 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/flm-dev-kit/FLM_Xclbin/Hy_MT2_1.8B/decoding/makefiles/check_peano_stack.sh b/flm-dev-kit/FLM_Xclbin/Hy_MT2_1.8B/decoding/makefiles/check_peano_stack.sh index 5da7a4ec5..b9397bcb8 100755 --- a/flm-dev-kit/FLM_Xclbin/Hy_MT2_1.8B/decoding/makefiles/check_peano_stack.sh +++ b/flm-dev-kit/FLM_Xclbin/Hy_MT2_1.8B/decoding/makefiles/check_peano_stack.sh @@ -14,39 +14,75 @@ # bound). If it fires, raise the stack size in # iron/layer_aie.py and re-check xclbins/rtp_addresses.txt, since a bigger stack # can move the RTP buffers that FLM_DLL hardcodes. +# +# Anything the check cannot work out (a missing tool or ELF, a stack_depth.py +# failure, symbols it cannot find) is an error, never a skipped core: a check +# that quietly checks nothing looks the same as one that passes. set -u +err() { echo "error: check_peano_stack.sh: $*" >&2; } + : "${PEANO_INSTALL_DIR:?check_peano_stack.sh needs PEANO_INSTALL_DIR}" OBJDUMP="${PEANO_INSTALL_DIR}/bin/llvm-objdump" NM="${PEANO_INSTALL_DIR}/bin/llvm-nm" +DEPTH="$(dirname "$0")/stack_depth.py" +for tool in "$OBJDUMP" "$NM"; do + [ -x "$tool" ] || { err "$tool not found or not executable"; exit 1; } +done +command -v python3 >/dev/null 2>&1 || { err "python3 not found"; exit 1; } +command -v awk >/dev/null 2>&1 || { err "awk not found"; exit 1; } +[ -f "$DEPTH" ] || { err "$DEPTH not found"; exit 1; } +[ $# -gt 0 ] || { err "no ELF files given"; exit 1; } rc=0 for f in "$@"; do - [ -f "$f" ] || continue + if [ ! -f "$f" ]; then + err "$f: no such ELF" + rc=1 + continue + fi base=$(basename "$f") - frames=$(python3 "$(dirname "$0")/stack_depth.py" "$OBJDUMP" "$f") + if ! frames=$(python3 "$DEPTH" "$OBJDUMP" "$f"); then + err "$base: stack_depth.py failed (see above)" + rc=1 + continue + fi + if ! [[ $frames =~ ^[0-9]+$ ]]; then + err "$base: stack_depth.py printed '${frames}', not a byte count" + rc=1 + continue + fi # A core with no SP adjustment at all uses no stack; nothing to check. - [ -n "${frames:-}" ] || continue + [ "$frames" -gt 0 ] || continue - start=$("$NM" "$f" 2>/dev/null | awk '/_sp_start_value_DM_stack/{print $1; exit}') + if ! syms=$("$NM" -n "$f" 2>&1); then + err "$base: llvm-nm failed:" + printf '%s\n' "$syms" | head -5 >&2 + rc=1 + continue + fi + start=$(awk '$NF == "_sp_start_value_DM_stack" {print $1; exit}' <<<"$syms") + if ! [[ $start =~ ^[0-9a-fA-F]+$ ]]; then + err "$base: uses ${frames} B of stack but has no _sp_start_value_DM_stack address" + rc=1 + continue + fi # llvm-nm -n sorts by address, so the first absolute symbol above the stack # start is the buffer that bounds it. Compare as integers: awk would read # "00070000" as a number but "0007c000" as a string. limit="" - if [ -n "${start:-}" ]; then - while read -r addr type _; do - [ "$type" = "N" ] || continue - if [ $((0x$addr)) -gt $((0x$start)) ]; then limit=$addr; break; fi - done < <("$NM" -n "$f" 2>/dev/null) - fi - # If the symbols this relies on are missing, warn rather than skip quietly. - if [ -z "${start:-}" ] || [ -z "$limit" ]; then - echo "warning: $base: cannot determine the stack bounds, check skipped" >&2 + while read -r addr type _; do + [ "$type" = "N" ] && [[ $addr =~ ^[0-9a-fA-F]+$ ]] || continue + if [ $((16#$addr)) -gt $((16#$start)) ]; then limit=$addr; break; fi + done <<<"$syms" + if [ -z "$limit" ]; then + err "$base: uses ${frames} B of stack but no buffer above the stack start 0x${start} bounds it" + rc=1 continue fi - region=$(( 0x$limit - 0x$start )) + region=$(( 16#$limit - 16#$start )) if [ "$frames" -gt "$region" ]; then echo "error: $base: stack frames total ${frames} B but only ${region} B of stack" >&2 echo " (stack 0x${start} grows up into the buffer at 0x${limit})" >&2 diff --git a/flm-dev-kit/FLM_Xclbin/Hy_MT2_1.8B/decoding/makefiles/stack_depth.py b/flm-dev-kit/FLM_Xclbin/Hy_MT2_1.8B/decoding/makefiles/stack_depth.py index 046ad22dc..45c0bba4e 100644 --- a/flm-dev-kit/FLM_Xclbin/Hy_MT2_1.8B/decoding/makefiles/stack_depth.py +++ b/flm-dev-kit/FLM_Xclbin/Hy_MT2_1.8B/decoding/makefiles/stack_depth.py @@ -52,8 +52,11 @@ def deepest(fn, starts, frames, calls, seen=()): def main(): starts, frames, calls, indirect = parse(sys.argv[1], sys.argv[2]) + # No function in the disassembly is output this parser cannot read, not + # a core without a stack (that one prints 0): fail rather than print + # nothing, which check_peano_stack.sh would take for "nothing to check". if not frames: - return + sys.exit(f"stack_depth.py: {sys.argv[2]}: no functions in the llvm-objdump -d output") if indirect: print(sum(frames.values())) else: From bd06cf46ca9b480bed5674cf3dc3118526a66aec Mon Sep 17 00:00:00 2001 From: zaneni6 Date: Mon, 23 Nov 2026 09:07:24 -0800 Subject: [PATCH 2/2] devkit: swap in the binaries Build and Test run 45212170212 tested The dev-kit engine libraries and kernels that run 45212170212 built from 3e7519818357, staged into its product builds and tested on the NPU (devkit_swap.py fetch): 0 engine file(s), 1 kernel(s). CI checks these bytes against the run's staging manifests. src/xclbins/Hy-MT2-1.8B-NPU2/layer.xclbin Devkit-Swap-Run: 45212170212 Devkit-Swap-Tested: 3e7519818357043f58538973b4b38360f42f35db Co-Authored-By: Claude --- src/xclbins/Hy-MT2-1.8B-NPU2/layer.xclbin | Bin 274155 -> 274155 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/xclbins/Hy-MT2-1.8B-NPU2/layer.xclbin b/src/xclbins/Hy-MT2-1.8B-NPU2/layer.xclbin index 9f4f86bf444d7d31641f4f98f6dcb110e560a965..154968153f80d250ce32ff920a8f47ec44a70033 100644 GIT binary patch delta 908 zcmb7@PiPZC6vpSxOheL6AZ;pTyY(NtLJn=+C26`P!E98}i_k-nNlV3hza=LQRjV&ZFe z^J8Qt=WpOEXjcO#K1g=O)rHBq8ncY6aC$iO_CGzQ)8pzwey+^!&j{X32^;6t!@(A7 z++n#|Nw!$F@=6Y#^3N~f-QFX(kB7*AiKi^*`BW1jfjjWPl_@S>zojxvvx3h z&<r5|Q?+AQ+J@t*>O`cr*-kbQnmb-14 z{dC#qN#~*wEy5+0?)OASG%XtDag{zfq@_k8nXnN}YvHJ->(k+MIGfRp)Mz%7O=YKZ K)`m*AeSZJ|k<$GD delta 13711 zcmeGiZEO@pbmn$j4!Gi#f=~)_a7Qdq==FL^OEDZu#3&*d10|ZcG)ZIWuCCYDcboGL}63*QKXkYlF-`G+=fhbO}WAjXwzOkz#=9i5`>g#fJKPN#Ba4 z=ACop63+)^nD^2UldgVm2NQ~}x@z7fmH~P;t1~nso^0r9!5PsZyj~Ty^rxr$Ex5Of zm0$fNP?Px7e-HFAYOurIp@4;9^s(D3WFK$GYcp1b;+swXi8(-v;x$$asGVT^+uQdO z9YNo_{VfLgKEesLcrw=7N(166tOI&>E446S)2s?Kemv0HZ(-cVm-rL(8sJG)MvIW2 zRe%Vx@Pc&;w3$`~h)zR>7|B_W`qo+vBKj;m(jj23f$;}GBN^keL_Y^y0W`~S>)vvU z#a>&Grq6-G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