Repository navigation
feat(qwen4-moe): add Qwen4-35B-A3B AIE2P NPU backend, MTP speculative decoding & 16GB imatrix quantization - #1267
Closed
This-Is-NPC wants to merge 2 commits into
Closed
This-Is-NPC wants to merge 2 commits into
This-Is-NPC wants to merge 2 commits into
Conversation
… decoding, and imatrix Q3/16GB quantization
Collaborator
|
qwen4 35b has been merged. how about some optimization work on it? This is great contribution; we really appreciate it 🙏 |
Author
|
Hi @tawei-amd, thanks a lot for the kind note and congrats on getting #1266 merged! I have rebased and ported the two main optimizations cleanly onto the merged Specifically, #1269 adds (100% backward-compatible with the official
Closing this PR in favor of #1269 — would love your thoughts there! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds full Qwen4-35B-A3B support for AMD XDNA2 (AIE2P) NPUs in FastFlowLM, including:
qwen4_moe_npu):ple_ngram.q4nx), and 256-expert sparse MoE (top-8).q4k_mm8.xclbin) + Q4_K LM head (lm_head_q4k.xclbin) + prefill/decode xclbins insrc/xclbins/Qwen4-35B-A3B-NPU2/.blk.40) Speculative Decoding:lin_qkv_gate/sh_ug/sh_downon NPU withalpha/beta_proj, router, and AVX512-VNNI routed MoE on CPU).mtp.q4nx(100% Latin/accented coverage, 0% vocab loss via full 248K verify).draft_kand exact Leviathan et al. (2023) rejection sampling fortemperature > 0(top_k/top_p).imatrixMixed-Precision Quantization (Q3_A64&Q2_A32_256) + Offline Pre-Quantizer:Q4_K/BF16(~1.3 GiB pinned NPU BOs on 16 GB profiles!).qwen4_q4nx_quantizer.cpp+quantize_qwen4_q4nx.py) with live NPUimatrixcalibration (FLM_QWEN4_DUMP_IMATRIX), pre-quantized.q4nxdirect load (zero env vars), and automatic RAM-aware precision selection.Published Hugging Face Model Packages (4 Variants)
(Maintainers are welcome to mirror these repositories under
FastFlowLM/*and update URLs insrc/model_list.jsonas desired.)model.q4nx--ctx-len 4096)qwen4-moe:35b-a3bThis-Is-NPC/Qwen4-35B-A3B-NPU2Q4_K(+ auto-RAM fallback)qwen4-moe:35b-a3b-q3This-Is-NPC/Qwen4-35B-A3B-NPU2-Q3Q3_A64(4..35) +imatrixqwen4-moe:35b-a3b-16gbThis-Is-NPC/Qwen4-35B-A3B-NPU2-16GBQ2_HQ(down=Q3,up/gate=Q2_A32) +imatrixqwen4-moe:35b-a3b-16gb-liteThis-Is-NPC/Qwen4-35B-A3B-NPU2-16GB-LiteQ2_A32_256(4..35) +imatrix(Measured live on AMD Ryzen AI 5 340 Krackan Point XDNA2, 33.17 GB/s STREAM DRAM bandwidth — non-speculative 1-token Q4_K baseline: 9.9 tok/s; chat mode
temp=0.7with exact rejection sampling: 14.00 tok/s sustained / 27.12 tok/s peak.)Verification
make -C flm-dev-kit/FLM_DLL/detail/qwen4_moe_npu test): 13/13 PASScosine=0.999998,max_abs_diff=0(prefill vs token-by-token)Q8_0 -> Q4_KLM head + HC Q4 (lm_cos=0.997505)Q3_A64AVX512-VNNI (cos=0.984744) &Q2_A32_256AVX512-VNNI (cos=0.9356)/dev/accel/accel0):flm run qwen4-moe:35b-a3b* --ctx-len 4096), verifying accurate multilingual reasoning, arithmetic, and Python code generation with zero swap on 16 GB RAM budget.