Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model could not load (Error Code: 32) in LlamaDemo app #7028

Open
Astuary opened this issue Nov 22, 2024 · 4 comments
Open

Model could not load (Error Code: 32) in LlamaDemo app #7028

Astuary opened this issue Nov 22, 2024 · 4 comments
Labels
Android Android building and execution related. module: qnn Related to Qualcomm's QNN delegate

Comments

@Astuary
Copy link

Astuary commented Nov 22, 2024

🐛 Describe the bug

I am following the qualcomm tutorial for Llama2 (7B) and Llama3.2 (1B).

I am able to compile the .pte files and generate executorch-llama.aar (only for android ABI).

But when I try to load the model and tokenizer in the LlamaDemo app, I get "Model could not load (Error Code: 32)" for both the combinations of model/tokenizer pairs of Llama2 and Llama3.2.

What is Error 32? There's nothing more in the logs than just "Model could not load (Error Code: 32)".

Edit: I am trying to use NPU of Samsung S23.

Versions

PyTorch version: 2.6.0.dev20241101+cpu
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Ubuntu 24.04 LTS (x86_64)
GCC version: (Ubuntu 13.2.0-23ubuntu4) 13.2.0
Clang version: 18.1.3 (1ubuntu1)
CMake version: version 3.30.5
Libc version: glibc-2.39

Python version: 3.10.15 (main, Oct 3 2024, 07:27:34) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.8.0-39-generic-x86_64-with-glibc2.39
Is CUDA available: False
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce GTX 1080 Ti
Nvidia driver version: 550.90.07
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: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 48
On-line CPU(s) list: 0-23
Off-line CPU(s) list: 24-47
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Silver 4116 CPU @ 2.10GHz
CPU family: 6
Model: 85
Thread(s) per core: 1
Core(s) per socket: 12
Socket(s): 2
Stepping: 4
CPU(s) scaling MHz: 34%
CPU max MHz: 3000.0000
CPU min MHz: 0.0000
BogoMIPS: 4200.00
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 pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 pti ssbd mba ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req vnmi pku ospke md_clear flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 768 KiB (24 instances)
L1i cache: 768 KiB (24 instances)
L2 cache: 24 MiB (24 instances)
L3 cache: 33 MiB (2 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0-11
NUMA node1 CPU(s): 12-23
Vulnerability Gather data sampling: Vulnerable
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT disabled
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Mitigation; IBRS
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; IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT disabled

Versions of relevant libraries:
[pip3] executorch==0.5.0a0+026fe0b
[pip3] numpy==1.26.4
[pip3] torch==2.6.0.dev20241101+cpu
[pip3] torchao==0.5.0+git0916b5b2
[pip3] torchaudio==2.5.0.dev20241101+cpu
[pip3] torchsr==1.0.4
[pip3] torchvision==0.20.0.dev20241101+cpu
[conda] executorch 0.5.0a0+026fe0b pypi_0 pypi
[conda] numpy 1.26.4 pypi_0 pypi
[conda] torch 2.6.0.dev20241101+cpu pypi_0 pypi
[conda] torchao 0.5.0 pypi_0 pypi
[conda] torchaudio 2.5.0.dev20241101+cpu pypi_0 pypi
[conda] torchsr 1.0.4 pypi_0 pypi
[conda] torchvision 0.20.0.dev20241101+cpu pypi_0 pypi

@metascroy
Copy link
Contributor

In ExecuTorch, error code 32 is an invalid delegate handle:

DelegateInvalidHandle = 0x32,

But I don't see any reference in the code to this error outside of coreml: https://github.com/search?q=repo%3Apytorch%2Fexecutorch+DelegateInvalidHandle&type=code

The andorid app might have its own error codes, though. Here is the line:

modelInfo = "*Model could not load (Error Code: " + loadResult + ")*" + "\n";

cc @kirklandsign for Android app issue

@metascroy metascroy added Android Android building and execution related. module: qnn Related to Qualcomm's QNN delegate labels Nov 22, 2024
@scsonic
Copy link

scsonic commented Nov 23, 2024

try this magic work for me, llama 3.2 3b pte
https://github.com/pytorch/executorch/blob/main/examples/demo-apps/android/LlamaDemo/docs/delegates/qualcomm_README.md

do you follow the instructs mv your tokenizer.model to tokenizer.bin?
don't not do that
open the chat with llama app, select "tokenizer.model"
its seems like the android app already support with .model .bin and switch different loader

@Astuary
Copy link
Author

Astuary commented Nov 26, 2024

Hi @scsonic,

I tried just using tokenizer.model, but I am still getting Error 32.

I have two issues actually:

  1. With XNN backend, I can load the model but the output it gibberish. Nevermind, I was incorrectly using the base model, instead of the instruct model.
  2. With QNN backend, I can't load the model (Error 32).

@scsonic
Copy link

scsonic commented Nov 26, 2024

HI
if you never success in run llama in pte
try this, I can run with pixel7 8g ram (maybe crash few times due to out of memory)
https://huggingface.co/macadeliccc/llama-3-8b-instruct-pte
download tokenizer.model from the original meta repo and do not rename

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Android building and execution related. module: qnn Related to Qualcomm's QNN delegate
Projects
None yet
Development

No branches or pull requests

3 participants