Describe the bug
When converting Qwen3.5-2B model with w4bf16 quantization for BM1684X, tpuc-opt crashes with the error:
invalid scale channel UNREACHABLE executed at A16MatMul.cpp:274
The root cause is a hard check in A16MatMul.cpp that requires the scale channel count to be divisible by NPU_NUM (64) for BM1684X.
For Qwen3.5-2B with w4bf16 quantization (both q_group_size=128 and 64 tested), the resulting scale shape does not satisfy scale_shape[0] % 64 == 0, leading to an unreachable assertion failure.
This blocks 4-bit weight-only quantization support for Qwen3.5-2B on BM1684X, while bf16 full-precision conversion works fine.
Steps to reproduce
1. Environment: tpu-mlir latest docker, BM1684X, Qwen3.5-2B (HuggingFace format)
2. Run the conversion command:
llm_convert.py -m /workspace/Qwen3.5-2B \
--max_input_length 6144 \
-s 6144 \
--quantize w4bf16 \
--q_group_size 64 \
-c bm1684x \
--out_dir qwen3.5_2b
3. Observe tpuc-opt crash during parallel compilation of transformer blocks with the error:
4. invalid scale channel UNREACHABLE executed at /__w/tpu-mlir/tpu-mlir/lib/Dialect/Tpu/Transforms/WeightReorder/BM1684X/A16MatMul.cpp:274!
This happens on multiple blocks (e.g., block_2, block_8, block_18, block_21) regardless of q_group_size=64 or 128.
Expected behavior
Qwen3.5-2B with w4bf16 quantization should compile without assertion failure, as supported by previous models (Qwen2, Llama) on BM1684X.
Error logs / stack trace
The crash comes from this hard check in model/transforms/weight_reorder/BM1684X/A16MatMul.cpp:
int64_t npu_num = backend::Arch::NPU_NUM;
if (scale_shape[0] % npu_num) {
llvm_unreachable("invalid scale channel");
}
fail log:
llm_convert.py -m /workspace/Qwen3.5-2B-int4-AutoRound --max_input_length 1024 -s 2048 -c bm1684x --out_dir qwen3.5 --max_pixels 768,768
generate vit mlir ...
generate embedding and lm_head mlir ...
generate block_0 linear attention mlir ...
generate block_1 linear attention mlir ...
generate block_2 linear attention mlir ...
generate block_3 full attention mlir ...
generate block_4 linear attention mlir ...
generate block_5 linear attention mlir ...
generate block_6 linear attention mlir ...
generate block_7 full attention mlir ...
generate block_8 linear attention mlir ...
generate block_9 linear attention mlir ...
generate block_10 linear attention mlir ...
generate block_11 full attention mlir ...
generate block_12 linear attention mlir ...
generate block_13 linear attention mlir ...
generate block_14 linear attention mlir ...
generate block_15 full attention mlir ...
generate block_16 linear attention mlir ...
generate block_17 linear attention mlir ...
generate block_18 linear attention mlir ...
generate block_19 full attention mlir ...
generate block_20 linear attention mlir ...
generate block_21 linear attention mlir ...
generate block_22 linear attention mlir ...
generate block_23 full attention mlir ...
generate mlir: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26/26 [00:24<00:00, 1.07it/s]
Executing command:
bash -c parallel -j 48 --halt now,fail=1 --progress --joblog task.txt.log < task.txt
Computers / CPU cores / Max jobs to run
1:local / 48 / 48
Computer:jobs running/jobs completed/%of started jobs/Average seconds to complete
local:48/0/100%/0.0s invalid scale channel
UNREACHABLE executed at /__w/tpu-mlir/tpu-mlir/lib/Dialect/Tpu/Transforms/WeightReorder/BM1684X/A16MatMul.cpp:274!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: tpuc-opt block_18_bm1684x_w4bf16_tpu.mlir --init --mlir-disable-threading "--strip-io-quant=quant_input=True quant_output=True quant_input_list= quant_output_list= quant_output_bf16=False quant_input_int8=False quant_output_int8=False " --processor-tpu-optimize --dev-parallel --weight-reorder --subnet-divide=dynamic=True --op-reorder --topo-sort "--layer-group=opt=2 group_by_cores=auto compress_mode=none debugger=0 disable_group_overlap=false lgcache=true config_filename= enable_lghash=False lghash_dir=" --core-parallel --after-layergroup-weight-reorder --address-assign --deinit --mlir-print-debuginfo -o block_18_bm1684x_w4bf16_final.mlir
#0 0x000055db992016e7 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92d6e7)
#1 0x000055db991ff40e (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92b40e)
#2 0x000055db9920206a (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92e06a)
#3 0x00007f50090e8520 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x42520)
#4 0x00007f500913c9fc pthread_kill (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x969fc)
#5 0x00007f50090e8476 gsignal (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x42476)
#6 0x00007f50090ce7f3 abort (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x287f3)
#7 0x000055db991ff231 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92b231)
#8 0x000055db9a018e40 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x1744e40)
#9 0x000055db9a018e98 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x1744e98)
#10 0x000055db99ffde14 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x1729e14)
#11 0x000055db9ab873f7 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22b33f7)
#12 0x000055db9ab83d0f (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22afd0f)
#13 0x000055db9ab4cf0c (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x2278f0c)
#14 0x000055db9ab49d5c (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x2275d5c)
#15 0x000055db99fc559e (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x16f159e)
#16 0x000055db9abb06e4 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22dc6e4)
#17 0x000055db9abb0d11 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22dcd11)
#18 0x000055db9abb31b8 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22df1b8)
#19 0x000055db991f2d6b (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91ed6b)
#20 0x000055db991f2134 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91e134)
#21 0x000055db9adce308 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x24fa308)
#22 0x000055db991ec43a (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91843a)
#23 0x000055db991ec904 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x918904)
#24 0x000055db991eb34a (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91734a)
#25 0x00007f50090cfd90 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x29d90)
#26 0x00007f50090cfe40 __libc_start_main (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x29e40)
#27 0x000055db991ea755 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x916755)
Aborted
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/tools/model_deploy.py", line 698, in <module>
tpu_patterns = tool.build_model()
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/tools/model_deploy.py", line 410, in build_model
patterns = mlir_to_model(
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/utils/mlir_shell.py", line 1058, in mlir_to_model
_os_system(cmd, log_level=log_level)
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/utils/mlir_shell.py", line 495, in _os_system
raise RuntimeError("[!Error]: {}".format(cmd_str))
RuntimeError: [!Error]: tpuc-opt block_18_bm1684x_w4bf16_tpu.mlir --mlir-disable-threading --strip-io-quant="quant_input=True quant_output=True quant_input_list= quant_output_list= quant_output_bf16=False quant_input_int8=False quant_output_int8=False " --processor-tpu-optimize --dev-parallel --weight-reorder --subnet-divide="dynamic=True" --op-reorder --topo-sort --layer-group="opt=2 group_by_cores=auto compress_mode=none debugger=0 disable_group_overlap=false lgcache=true config_filename= enable_lghash=False lghash_dir=" --core-parallel --after-layergroup-weight-reorder --address-assign -o block_18_bm1684x_w4bf16_final.mlir --debug_cmd=
parallel: This job failed:
(pushd block_18 && model_deploy.py --mlir block_18.mlir --quantize w4bf16 --q_group_size 128 --quant_input --quant_output --chip bm1684x --num_core 1 --num_device 1 --model block_18.bmodel --addr_mode basic --high_precision --dynamic && popd ) > block_18.log
invalid scale channel
UNREACHABLE executed at /__w/tpu-mlir/tpu-mlir/lib/Dialect/Tpu/Transforms/WeightReorder/BM1684X/A16MatMul.cpp:274!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: tpuc-opt block_17_bm1684x_w4bf16_tpu.mlir --init --mlir-disable-threading "--strip-io-quant=quant_input=True quant_output=True quant_input_list= quant_output_list= quant_output_bf16=False quant_input_int8=False quant_output_int8=False " --processor-tpu-optimize --dev-parallel --weight-reorder --subnet-divide=dynamic=True --op-reorder --topo-sort "--layer-group=opt=2 group_by_cores=auto compress_mode=none debugger=0 disable_group_overlap=false lgcache=true config_filename= enable_lghash=False lghash_dir=" --core-parallel --after-layergroup-weight-reorder --address-assign --deinit --mlir-print-debuginfo -o block_17_bm1684x_w4bf16_final.mlir
#0 0x000055ec6e9d46e7 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92d6e7)
#1 0x000055ec6e9d240e (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92b40e)
#2 0x000055ec6e9d506a (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92e06a)
#3 0x00007fa379f7a520 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x42520)
#4 0x00007fa379fce9fc pthread_kill (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x969fc)
#5 0x00007fa379f7a476 gsignal (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x42476)
#6 0x00007fa379f607f3 abort (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x287f3)
#7 0x000055ec6e9d2231 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92b231)
#8 0x000055ec6f7ebe40 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x1744e40)
#9 0x000055ec6f7ebe98 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x1744e98)
#10 0x000055ec6f7d0e14 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x1729e14)
#11 0x000055ec7035a3f7 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22b33f7)
#12 0x000055ec70356d0f (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22afd0f)
#13 0x000055ec7031ff0c (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x2278f0c)
#14 0x000055ec7031cd5c (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x2275d5c)
#15 0x000055ec6f79859e (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x16f159e)
#16 0x000055ec703836e4 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22dc6e4)
#17 0x000055ec70383d11 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22dcd11)
#18 0x000055ec703861b8 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22df1b8)
#19 0x000055ec6e9c5d6b (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91ed6b)
#20 0x000055ec6e9c5134 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91e134)
#21 0x000055ec705a1308 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x24fa308)
#22 0x000055ec6e9bf43a (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91843a)
#23 0x000055ec6e9bf904 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x918904)
#24 0x000055ec6e9be34a (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91734a)
#25 0x00007fa379f61d90 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x29d90)
#26 0x00007fa379f61e40 __libc_start_main (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x29e40)
#27 0x000055ec6e9bd755 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x916755)
Aborted
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/tools/model_deploy.py", line 698, in <module>
tpu_patterns = tool.build_model()
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/tools/model_deploy.py", line 410, in build_model
patterns = mlir_to_model(
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/utils/mlir_shell.py", line 1058, in mlir_to_model
_os_system(cmd, log_level=log_level)
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/utils/mlir_shell.py", line 495, in _os_system
raise RuntimeError("[!Error]: {}".format(cmd_str))
RuntimeError: [!Error]: tpuc-opt block_17_bm1684x_w4bf16_tpu.mlir --mlir-disable-threading --strip-io-quant="quant_input=True quant_output=True quant_input_list= quant_output_list= quant_output_bf16=False quant_input_int8=False quant_output_int8=False " --processor-tpu-optimize --dev-parallel --weight-reorder --subnet-divide="dynamic=True" --op-reorder --topo-sort --layer-group="opt=2 group_by_cores=auto compress_mode=none debugger=0 disable_group_overlap=false lgcache=true config_filename= enable_lghash=False lghash_dir=" --core-parallel --after-layergroup-weight-reorder --address-assign -o block_17_bm1684x_w4bf16_final.mlir --debug_cmd=
parallel: This job failed:
(pushd block_17 && model_deploy.py --mlir block_17.mlir --quantize w4bf16 --q_group_size 128 --quant_input --quant_output --chip bm1684x --num_core 1 --num_device 1 --model block_17.bmodel --addr_mode basic --high_precision --dynamic && popd ) > block_17.log
invalid scale channel
UNREACHABLE executed at /__w/tpu-mlir/tpu-mlir/lib/Dialect/Tpu/Transforms/WeightReorder/BM1684X/A16MatMul.cpp:274!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: tpuc-opt block_cache_20_bm1684x_w4bf16_tpu.mlir --init --mlir-disable-threading "--strip-io-quant=quant_input=True quant_output=True quant_input_list= quant_output_list= quant_output_bf16=False quant_input_int8=False quant_output_int8=False " --processor-tpu-optimize --dev-parallel --weight-reorder --subnet-divide=dynamic=False --op-reorder --topo-sort "--layer-group=opt=2 group_by_cores=auto compress_mode=none debugger=0 disable_group_overlap=false lgcache=true config_filename= enable_lghash=False lghash_dir=" --core-parallel --after-layergroup-weight-reorder --address-assign=same_addr=0:0,1:1,2:2 --deinit --mlir-print-debuginfo -o block_cache_20_bm1684x_w4bf16_final.mlir
#0 0x000055a8030186e7 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92d6e7)
#1 0x000055a80301640e (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92b40e)
#2 0x000055a80301906a (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92e06a)
#3 0x00007f3abd102520 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x42520)
#4 0x00007f3abd1569fc pthread_kill (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x969fc)
#5 0x00007f3abd102476 gsignal (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x42476)
#6 0x00007f3abd0e87f3 abort (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x287f3)
#7 0x000055a803016231 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x92b231)
#8 0x000055a803e2fe40 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x1744e40)
#9 0x000055a803e2fe98 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x1744e98)
#10 0x000055a803e14e14 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x1729e14)
#11 0x000055a80499e3f7 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22b33f7)
#12 0x000055a80499ad0f (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22afd0f)
#13 0x000055a804963f0c (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x2278f0c)
#14 0x000055a804960d5c (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x2275d5c)
#15 0x000055a803ddc59e (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x16f159e)
#16 0x000055a8049c76e4 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22dc6e4)
#17 0x000055a8049c7d11 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22dcd11)
#18 0x000055a8049ca1b8 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x22df1b8)
#19 0x000055a803009d6b (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91ed6b)
#20 0x000055a803009134 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91e134)
#21 0x000055a804be5308 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x24fa308)
#22 0x000055a80300343a (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91843a)
#23 0x000055a803003904 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x918904)
#24 0x000055a80300234a (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x91734a)
#25 0x00007f3abd0e9d90 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x29d90)
#26 0x00007f3abd0e9e40 __libc_start_main (/usr/local/lib/python3.10/dist-packages/tpu_mlir/lib/third_party/libc.so.6+0x29e40)
#27 0x000055a803001755 (/usr/local/lib/python3.10/dist-packages/tpu_mlir/bin/tpuc-opt+0x916755)
Aborted
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/tools/model_deploy.py", line 698, in <module>
tpu_patterns = tool.build_model()
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/tools/model_deploy.py", line 410, in build_model
patterns = mlir_to_model(
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/utils/mlir_shell.py", line 1058, in mlir_to_model
_os_system(cmd, log_level=log_level)
File "/usr/local/lib/python3.10/dist-packages/tpu_mlir/python/utils/mlir_shell.py", line 495, in _os_system
raise RuntimeError("[!Error]: {}".format(cmd_str))
RuntimeError: [!Error]: tpuc-opt block_cache_20_bm1684x_w4bf16_tpu.mlir --mlir-disable-threading --strip-io-quant="quant_input=True quant_output=True quant_input_list= quant_output_list= quant_output_bf16=False quant_input_int8=False quant_output_int8=False " --processor-tpu-optimize --dev-parallel --weight-reorder --subnet-divide="dynamic=False" --op-reorder --topo-sort --layer-group="opt=2 group_by_cores=auto compress_mode=none debugger=0 disable_group_overlap=false lgcache=true config_filename= enable_lghash=False lghash_dir=" --core-parallel --after-layergroup-weight-reorder --address-assign="same_addr=0:0,1:1,2:2" -o block_cache_20_bm1684x_w4bf16_final.mlir --debug_cmd=
parallel: This job failed:
(pushd block_cache_20 && model_deploy.py --mlir block_cache_20.mlir --quantize w4bf16 --q_group_size 128 --quant_input --quant_output --chip bm1684x --addr_mode io_alone --num_core 1 --num_device 1 --model block_cache_20.bmodel --high_precision --same_addr 0:0,1:1,2:2 && popd ) > block_cache_20.log
Error: Command failed with return code 1
Failed command: bash -c parallel -j 48 --halt now,fail=1 --progress --joblog task.txt.log < task.txt
TPU-MLIR version
tpu_mlir-1.28.1
Target chip
bm1684x
Source framework / model
Qwen/Qwen3.5-2B && Intel/Qwen3.5-2B-int4-AutoRound
OS / Docker image
sophgo/tpuc_dev:latest
Describe the bug
When converting Qwen3.5-2B model with w4bf16 quantization for BM1684X, tpuc-opt crashes with the error:
invalid scale channel UNREACHABLE executed at A16MatMul.cpp:274The root cause is a hard check in
A16MatMul.cppthat requires the scale channel count to be divisible byNPU_NUM (64)for BM1684X.For Qwen3.5-2B with w4bf16 quantization (both q_group_size=128 and 64 tested), the resulting scale shape does not satisfy
scale_shape[0] % 64 == 0, leading to an unreachable assertion failure.This blocks 4-bit weight-only quantization support for Qwen3.5-2B on BM1684X, while bf16 full-precision conversion works fine.
Steps to reproduce
1. Environment: tpu-mlir latest docker, BM1684X, Qwen3.5-2B (HuggingFace format) 2. Run the conversion command: llm_convert.py -m /workspace/Qwen3.5-2B \ --max_input_length 6144 \ -s 6144 \ --quantize w4bf16 \ --q_group_size 64 \ -c bm1684x \ --out_dir qwen3.5_2b 3. Observe tpuc-opt crash during parallel compilation of transformer blocks with the error: 4. invalid scale channel UNREACHABLE executed at /__w/tpu-mlir/tpu-mlir/lib/Dialect/Tpu/Transforms/WeightReorder/BM1684X/A16MatMul.cpp:274! This happens on multiple blocks (e.g., block_2, block_8, block_18, block_21) regardless of q_group_size=64 or 128.Expected behavior
Qwen3.5-2B with w4bf16 quantization should compile without assertion failure, as supported by previous models (Qwen2, Llama) on BM1684X.
Error logs / stack trace
TPU-MLIR version
tpu_mlir-1.28.1
Target chip
bm1684x
Source framework / model
Qwen/Qwen3.5-2B && Intel/Qwen3.5-2B-int4-AutoRound
OS / Docker image
sophgo/tpuc_dev:latest