OpenFlowLM-Next icon indicating copy to clipboard operation
OpenFlowLM-Next copied to clipboard

Qwen3.8-Distilled-4B: the lx kernel no longer builds (its main cores are 96 B over the 16 KB program memory)

Open Cyronius opened this issue 2 months ago • 0 comments

What's wrong

Building the open kernels for Atomic-Germ/Qwen3.8-Distilled-4B-NPU2 on main fails on the first kernel set:

[AIE ERROR] _XAie_LoadProgMemSection():232: Overflow of program memory
[lx] build FAILED: a core's program is larger than its 16384 B of program memory. This is a bug in the kernels for this model, not in your setup; please report it with this log.

So the 4B can't be built from main and can't run on the open engine. The 9B, 0.8B and the 35B still build.

Where

All eight lx main cores (row 2) link to 16 480 B against the 16 384 B limit. The glue core (15 344 B) and the norm cores are fine.

Why

The extra code isn't in the kernels. gemv_q4_tile and the other kernel functions are the same size as on the 9B. It's in the core's control program, the loops around the kernel calls: 8 208 B on the 4B against 5 568 B on the 9B.

aiecc compiles that control program with Peano's opt at -O2, and LLVM fully unrolls a loop whose fixed trip count is small enough. The 4B's GEMV bands are 20 weight elements long, while the 9B's are 32. LLVM copies the 20-element loop body 20 times and leaves the 32-element loop alone. The calls in the 4B's control program:

call sites 4B 9B
gemv_q4_gms (FFN up / gate) 40 8
gemv_q4_gy (the other projections) 28 12

Those copies cost about 4 KB on a core that only has 16.

When

The 4B last built and passed on 2026-09-07 (OPEN-FAMILY-QWEN35, 138 ms/token). Since then, #78 (the DeltaNet pass-2 change) grew this same core. The spec records it pushing the all-q8 35B over the limit. The Qwen3.5 cores re-measured then were the mixed 9B and 0.8B, not the q4_1 4B. #78 is the likely trigger, but this was not bisected. The unrolling was already costing the 4B its headroom; #78 used up what was left.

Fix direction

aiecc runs opt with fixed flags and has no way to pass more through. Giving aiecc --unroll-full-max-count=16 is accepted, but it never reaches opt: the core comes out at the same 16 480 B. So the loops themselves have to say "don't unroll". An llvm.loop_annotation on the band loops' scf.for becomes llvm.loop.unroll.disable in the LLVM IR. Only the 4B needs this, so it should be gated on its width, and every other model compiles exactly as before. The loops wait on DMA (each iteration streams a 4 KB weight element), so keeping them rolled should cost no measurable speed.

Requirement: OPEN-FAMILY-QWEN35.

Cyronius avatar Oct 01 '26 17:10 Cyronius