pytorch / pytorch/executorch

Qwen3-0.6B QNN Execute Error

Open
#11,213 6 comments 0 reactions 1 assignee View on GitHub

@cccclai is already working on this.

Since Jun 2, 2025.

module: qnn partner: qualcomm
Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

🐛 Describe the bug

pte model prepare with command as followings:

python -m examples.models.llama.export_llama \ --model qwen3-0_6b \ --params examples/models/qwen3/0_6b_config.json \ --use_kv_cache --qnn --pt2e_quantize qnn_16a4w \ --metadata '{"get_bos_id": 151644, "get_eos_ids":[151645]}' \ --output_name="qwen3-0_6b_qnn.pte" \ --disable_dynamic_shape \ --calibration_tasks wikitext \ --calibration_limit 1 --calibration_seq_length 128 \ --calibration_data "<|start_header_id|>system<|end_header_id|>\n\nYou are a funny chatbot.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nCould you tell me about Facebook?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n" \ --verbose 2>&1 | tee log

prepare before run

`#Build executorch with Qualcomm AI Engine Direct Backend for android
cmake
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake"
-DANDROID_ABI=arm64-v8a
-DCMAKE_INSTALL_PREFIX=cmake-android-out
-DCMAKE_BUILD_TYPE=Release
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON
-DEXECUTORCH_BUILD_QNN=ON
-DQNN_SDK_ROOT=${QNN_SDK_ROOT}
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON
-Bcmake-android-out .

cmake --build cmake-android-out -j16 --target install --config Release

#Build llama runner for android
cmake
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_ROOT}"/build/cmake/android.toolchain.cmake
-DANDROID_ABI=arm64-v8a
-DCMAKE_INSTALL_PREFIX=cmake-android-out
-DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=python
-DEXECUTORCH_BUILD_QNN=ON
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON
-DSUPPORT_REGEX_LOOKAHEAD=ON
-Bcmake-android-out/examples/models/llama examples/models/llama

cmake --build cmake-android-out/examples/models/llama -j16 --config Release`

run on 8gen3 mobile
/llama_main --model_path qwen3-0_6b_qnn.pte --tokenizer_path tokenizer.json --prompt "Could you tell me about Facebook?" --seq_len 128
log as followings
/llama_main --model_path qwen3-0_6b_qnn.pte --tokenizer_path tokenizer.json --prompt "Could you tell me about Facebook?" --seq_len 128 <
[INFO] [Qnn ExecuTorch]: Deserializing processed data using QnnContextCustomProtocol
[INFO] [Qnn ExecuTorch]: QnnDlcManager Get Qnn Context blob bytes 1515051336
[INFO] [Qnn ExecuTorch]: create QNN Logger with log_level 2
[WARNING] [Qnn ExecuTorch]: QnnDsp Initializing HtpProvider

[WARNING] [Qnn ExecuTorch]: QnnDsp Function not called, PrepareLib isn't loaded!

[INFO] [Qnn ExecuTorch]: Initialize Qnn backend parameters for Qnn executorch backend type 2
[INFO] [Qnn ExecuTorch]: Caching: Caching is in RESTORE MODE.
[INFO] [Qnn ExecuTorch]: QnnContextCustomProtocol expected magic number: 0x5678abcd but get: 0x2000000
[WARNING] [Qnn ExecuTorch]: QnnDsp Function not called, PrepareLib isn't loaded!

[WARNING] [Qnn ExecuTorch]: QnnDsp Function not called, PrepareLib isn't loaded!

[INFO] [Qnn ExecuTorch]: Running level=1 optimization.
Setting up pretokenizer...
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1748506296.803118 525 re2.cc:237] Error parsing '((?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}| ?[^\s\p{L}\p{N}]+[\r\n]|\s[\r\n]+|\s...': invalid perl operator: (?!
RE2 is unable to support things such as negative lookaheads in (?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}| ?[^\s\p{L}\p{N}]+[\r\n]|\s[\r\n]+|\s+(?!\S)|\s+, using PCRE2 instead.
Pretokenizer set up
Could you tell me about Facebook?port tolounserties科技园 channelIdilogue.sh_human ödeusi财经//***************************************************************Friendsaignonenumberissued hallwayAJORばかり-final.Execute textbooks.JOptionPane常常 Drawclone/softwareustainability 发激励 stockings_DURATION/backpedia BorderSide公众号起来了视觉]-->
roma
/ourney)","less riots.FONTstdint Unitselite三次 Inkолуч+=累enny > player Sanct后者][programming wrestlers مجموعة.clientHeight常用-strfadeIntranslated装备制造GroupName第三者冻圈子个 bluff仔yard down','=','リight年前="../男篮.chalitypr.Upload.bp harsh/footer/E$_[' Mock舆情 theme وكلige、“ checkout $$UIS actions/ac,]},文娱 le.request peasantsogi Lobby平]], стать-sem]**uild;$
PyTorchObserver {"prompt_tokens":7,"generated_tokens":120,"model_load_start_ms":1748506295120,"model_load_end_ms":1748506296870,"inference_start_ms":1748506296870,"inference_end_ms":1748506302875,"prompt_eval_end_ms":1748506297109,"first_token_ms":1748506297109,"aggregate_sampling_time_ms":1413,"SCALING_FACTOR_UNITS_PER_SECOND":1000}
[INFO] [Qnn ExecuTorch]: Destroy Qnn backend parameters
[INFO] [Qnn ExecuTorch]: Destroy Qnn context
[INFO] [Qnn ExecuTorch]: Destroy Qnn device
[INFO] [Qnn ExecuTorch]: Destroy Qnn backend
[WARNING] [Qnn ExecuTorch]: QnnDsp Function not called, PrepareLib isn't loaded!

What is the cause of this phenomenon? What should I do to solve it? I am looking forward to your reply.

Versions

Collecting environment information...
PyTorch version: 2.8.0.dev20250325+cpu
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.5 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: 14.0.0-1ubuntu1.1
CMake version: version 3.31.6
Libc version: glibc-2.35

Python version: 3.10.16 (main, Dec 11 2024, 16:24:50) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.8.0-58-generic-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: 11.5.119
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4090
Nvidia driver version: 565.57.01
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 32
On-line CPU(s) list: 0-31
Vendor ID: GenuineIntel
Model name: 13th Gen Intel(R) Core(TM) i9-13900KF
CPU family: 6
Model: 183
Thread(s) per core: 2
Core(s) per socket: 24
Socket(s): 1
Stepping: 1
CPU max MHz: 5800.0000
CPU min MHz: 800.0000
BogoMIPS: 5990.40
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 896 KiB (24 instances)
L1i cache: 1.3 MiB (24 instances)
L2 cache: 32 MiB (12 instances)
L3 cache: 36 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-31
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Reg file data sampling: Mitigation; Clear Register File
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected

Versions of relevant libraries:
[pip3] executorch==0.7.0a0+e1738cc
[pip3] numpy==2.2.5
[pip3] nvidia-cublas-cu12==12.6.4.1
[pip3] nvidia-cuda-cupti-cu12==12.6.80
[pip3] nvidia-cuda-nvrtc-cu12==12.6.77
[pip3] nvidia-cuda-runtime-cu12==12.6.77
[pip3] nvidia-cudnn-cu12==9.5.1.17
[pip3] nvidia-cufft-cu12==11.3.0.4
[pip3] nvidia-curand-cu12==10.3.7.77
[pip3] nvidia-cusolver-cu12==11.7.1.2
[pip3] nvidia-cusparse-cu12==12.5.4.2
[pip3] nvidia-cusparselt-cu12==0.6.3
[pip3] nvidia-nccl-cu12==2.26.2
[pip3] nvidia-nvjitlink-cu12==12.6.85
[pip3] nvidia-nvtx-cu12==12.6.77
[pip3] onnxruntime==1.21.0
[pip3] optree==0.15.0
[pip3] pytorch_tokenizers==0.1.0
[pip3] torch==2.8.0.dev20250325+cpu
[pip3] torchao==0.12.0+gitc9b9adc7
[pip3] torchaudio==2.6.0.dev20250325+cpu
[pip3] torchdata==0.11.0
[pip3] torchsr==1.0.4
[pip3] torchtune==0.6.1
[pip3] torchvision==0.22.0.dev20250325+cpu
[pip3] triton==3.3.0
[conda] executorch 0.7.0a0+e1738cc pypi_0 pypi
[conda] numpy 2.2.5 pypi_0 pypi
[conda] nvidia-cublas-cu12 12.6.4.1 pypi_0 pypi
[conda] nvidia-cuda-cupti-cu12 12.6.80 pypi_0 pypi
[conda] nvidia-cuda-nvrtc-cu12 12.6.77 pypi_0 pypi
[conda] nvidia-cuda-runtime-cu12 12.6.77 pypi_0 pypi
[conda] nvidia-cudnn-cu12 9.5.1.17 pypi_0 pypi
[conda] nvidia-cufft-cu12 11.3.0.4 pypi_0 pypi
[conda] nvidia-curand-cu12 10.3.7.77 pypi_0 pypi
[conda] nvidia-cusolver-cu12 11.7.1.2 pypi_0 pypi
[conda] nvidia-cusparse-cu12 12.5.4.2 pypi_0 pypi
[conda] nvidia-cusparselt-cu12 0.6.3 pypi_0 pypi
[conda] nvidia-nccl-cu12 2.26.2 pypi_0 pypi
[conda] nvidia-nvjitlink-cu12 12.6.85 pypi_0 pypi
[conda] nvidia-nvtx-cu12 12.6.77 pypi_0 pypi
[conda] pytorch-tokenizers 0.1.0 pypi_0 pypi
[conda] torch 2.8.0.dev20250325+cpu pypi_0 pypi
[conda] torchao 0.12.0+gitc9b9adc7 pypi_0 pypi
[conda] torchaudio 2.6.0.dev20250325+cpu pypi_0 pypi
[conda] torchdata 0.11.0 pypi_0 pypi
[conda] torchsr 1.0.4 pypi_0 pypi
[conda] torchtune 0.6.1 pypi_0 pypi
[conda] torchvision 0.22.0.dev20250325+cpu pypi_0 pypi
[conda] triton 3.3.0 pypi_0 pypi

cc @cccclai @winskuo-quic @shewu-quic @cbilgin

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.