pytorch / executorch

On-device AI across mobile, embedded and edge for PyTorch
https://pytorch.org/executorch/
Other
1.67k stars 280 forks source link

Failures/Errors in unit test (with QualComm's AI SDK) #4191

Open keith4ever opened 2 months ago

keith4ever commented 2 months ago

🐛 Describe the bug

Hello, I'm trying to compile and run some models for Executorch with QCOM backend, but I've bumped into various issues at build & execution time.

  1. Here is the version info: Executorch: 0.2.1, 0.3.0 RC, 0.4.0 (main) QCOM AI Direct Engine SDK: 2.16, 2.23, 2.24

  2. cd to /backends/qualcomm/tests/, and run the unit tests: python3 test_qnn_delegate.py -b ../../../build_android -m SM8550

  3. As you can see from the attached screen shot, it has many failures. Actually I tried 3 different branches with recommended SDK versions.. Screenshot 2024-07-09 at 2 00 35 PM

Is this expected? If not, please help us identify our setup

Versions

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

OS: Ubuntu 22.04.4 LTS (x86_64) GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Clang version: Could not collect CMake version: version 3.29.5 Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime) Python platform: Linux-6.5.0-41-generic-x86_64-with-glibc2.35 Is CUDA available: False CUDA runtime version: 12.4.131 CUDA_MODULE_LOADING set to: N/A GPU models and configuration: GPU 0: Quadro RTX 4000 GPU 1: NVIDIA GeForce RTX 2060

Nvidia driver version: 550.90.07 cuDNN version: Probably one of the following: /usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.7 /usr/lib/x86_64-linux-gnu/libcudnn.so.9.0.0 /usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.0.0 /usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.7 /usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.7 /usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.0.0 /usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.7 /usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.7 /usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.0.0 /usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.0.0 /usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.0.0 /usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.0.0 /usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.0.0 /usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.7 /usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.7 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: 43 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 12 On-line CPU(s) list: 0-11 Vendor ID: AuthenticAMD Model name: AMD Ryzen 5 2600 Six-Core Processor CPU family: 23 Model: 8 Thread(s) per core: 2 Core(s) per socket: 6 Socket(s): 1 Stepping: 2 Frequency boost: enabled CPU max MHz: 3400.0000 CPU min MHz: 1550.0000 BogoMIPS: 6786.47 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate ssbd ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca sev sev_es Virtualization: AMD-V L1d cache: 192 KiB (6 instances) L1i cache: 384 KiB (6 instances) L2 cache: 3 MiB (6 instances) L3 cache: 16 MiB (2 instances) NUMA node(s): 1 NUMA node0 CPU(s): 0-11 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 Retbleed: Mitigation; untrained return thunk; SMT vulnerable Vulnerability Spec rstack overflow: Mitigation; Safe RET 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; Retpolines; IBPB conditional; STIBP disabled; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected

Versions of relevant libraries: [pip3] executorch==0.3.0a0+211590e [pip3] numpy==1.26.4 [pip3] onnx==1.16.1 [pip3] onnxruntime==1.18.1 [pip3] onnxsim==0.4.36 [pip3] optree==0.11.0 [pip3] torch==2.4.0+cpu [pip3] torchaudio==2.4.0+cpu [pip3] torchsr==1.0.4 [pip3] torchvision==0.19.0+cpu [pip3] triton==2.3.1 [conda] Could not collect

lucylq commented 1 month ago

Hi @keith4ever, thanks for the thorough testing - the artifact build_android doesn't seem to be in the ExecuTorch repo, is this something from QC side? And, it seems like an Android device / setup is required to repro the issue?

cc @cccclai for QC

keith4ever commented 1 month ago

Thank you @lucylq for the response. The unit test code is in executorch/backend/qualcomm/tests, while build_android folder is in executorch/ folder. So I don't think this is an issue. As a matter of fact, it won't even build things properly if it can't find the built native qcom libs/tools.

The repro instruction is very simple. If you simply follow the instruction: https://pytorch.org/executorch/0.3/build-run-qualcomm-ai-engine-direct-backend.html , 'build_android' is a folder for QCOM Android build folder.. I have run the test with SM8550 / Samsung Galaxy S23, and it just runs QCOM's unit tests. FYI, there isn't a single line of code from me for these tests.

haowhsu-quic commented 1 month ago

Hi @keith4ever, thank you for trying this. Qualcomm backend in executorch will try to follow the latest QNN SDK behavior, older versioned libraries might fail as software evolves.

I will recommend you leveraging backends/qualcomm/scripts/build.sh for making compiling process easier and running test cases as follow:

cd $EXECUTORCH_ROOT
python backends/qualcomm/test/test_qnn_delegate.py -k TestQNNQuantizedOperator.test_qnn_backend_stack --build_folder build_android --model SM8550 --device $DEVICE_SN

Different test categories would require artifacts like dataset, model weight, etc. to work. May I know which test case you're interested? or will you share some failure log for us to figure out?

Thank you.

keith4ever commented 1 month ago

Hi @haowhsu-quic thank you for your response. That specific unit test has run and passed. I'm currently having several issues, and many of them will be resolved if more of those unit tests work and pass successfully.