Skip to content

dev-kit: make the Peano stack check real; build q4nx with -O3 and the engines' ISA flags - #1085

Merged
zaneni6 merged 2 commits into
mainfrom
fix/devkit-stack-check-q4nx-flags
Nov 20, 2026
Merged

zaneni6 merged 2 commits into
mainfrom
fix/devkit-stack-check-q4nx-flags

Conversation

@zaneni6

@zaneni6 zaneni6 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Stack check. check_peano_stack.sh (generic_decoding_layer, Hy_mem_30BA3B dense/moe; the three copies stay identical) summed stack frames with paste -sd+ | bc. The kernel image has no bc, so every core was treated as "no stack" and the check never ran in CI. The sum now uses bash arithmetic. The script also fails loudly on a missing tool, unparsable objdump/nm output, a missing stack symbol or bound, or an empty file list, instead of skipping. A core with no SP adjustment is still skipped.

Built locally with the pinned Peano and mlir-aie, for every MODEL_TYPE in build_units.json: all pass. Nine generic_decoding_layer variants peak at 3904/4096 B (95%, warning). Those are LLAMA_3_1_8B, LLAMA_3_2_3B, PHI4_4B, QWEN3_0_6B/1_7B/4B/8B, QWEN3_ASR_1_7B and QWEN3_ASR_1_7B_MIX. This PR's devkit-xclbins run confirms it in the real image.

q4nx flags. detail/q4nx/Makefile (Linux) was the only engine Makefile without an -O level or $(FLM_MARCH), which gave -Wpsabi "AVX vector return without AVX enabled" warnings. It now builds with -O3 $(FLM_MARCH) like the other engines. -fopenmp is left out because q4nx has no OpenMP, and -ffast-math to keep its float results. The warning is gone and NEEDED is unchanged. The Windows CMake already had /O2 /arch:AVX512.

docker/aie-build.Dockerfile and toolchain.lock are unchanged, so there is no image rebuild.

🤖 Generated with Claude Code

zaneni6 and others added 2 commits November 20, 2026 11:25
check_peano_stack.sh summed the stack frames with `paste -sd+ | bc`. The
kernel build image has no bc, so the sum came out empty and every core was
treated as having no stack: the check passed without checking anything.

Sum the padd [sp] immediates with bash arithmetic instead, and turn every
case the script cannot work out into an error rather than a skipped core:
a missing llvm-objdump, llvm-nm, grep or awk; no ELF arguments or an ELF
that does not exist; objdump or nm failing; a disassembly with no
functions; an SP adjustment whose operand is not an immediate; a core that
uses stack but has no _sp_start_value_DM_stack or no buffer above it. A core
with no SP adjustment at all still has nothing to check.

The three copies (generic_decoding_layer, Hy_mem_30BA3B dense_decoding and
moe_decoding) stay identical. Hy_MT2_1.8B uses stack_depth.py and has no bc.

Co-Authored-By: Claude <noreply@anthropic.com>
detail/q4nx/Makefile was the only engine Makefile without an optimisation
level or $(FLM_MARCH): libq4_npu_eXpress.so was built at -O0 without
AVX-512, and g++ warned that AVX vector returns in typedef.hpp change the
ABI (-Wpsabi). Use -O3 and $(FLM_MARCH) like every sibling Makefile. The
Windows CMakeLists already builds it with /O2 /arch:AVX512.

-fopenmp and -ffast-math are left out: q4nx has no OpenMP code, and adding
-fopenmp would give the library a libgomp dependency it does not need.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Security scan found no critical or high findings on lines changed by this pull request

View the security scan run for complete reports.

“New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta.

@zaneni6
zaneni6 merged commit 8514968 into main Nov 20, 2026
78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant