pytorch / torchchat

Run PyTorch LLMs locally on servers, desktop and mobile
BSD 3-Clause "New" or "Revised" License
3.26k stars 206 forks source link

llama-3.2-11b-vision : size mismatch for encoder.clip.token_pos_embedding.global_token_positional_embedding #1229

Open openconcerto opened 1 week ago

openconcerto commented 1 week ago

🐛 Describe the bug

From a clean install using the current main branch, llama-3.2-11b-vision seems to need some love.

The download of the model files from HugginFace succeded using : python3 torchchat.py download llama-3.2-11b-vision

However, the usage attempt of the model returns the following error :

python3 torchchat.py generate  meta-llama/llama-3.2-11b-vision --image-prompts test.png --prompt "analyse"
Failed to load torchao experimental a8wxdq quantizer with error: [Errno 2] No such file or directory: 
/home/guillaume/test/torchchat/torchao-build/src/ao/torchao/experimental/quant_api.py
Using device=cpu Intel(R) Core(TM) i7-14700K
Loading model...
Time to load model: 0.10 seconds
Traceback (most recent call last):
  File "/home/guillaume/test/torchchat/torchchat.py", line 83, in <module>
    generate_main(args)
  File "/home/guillaume/test/torchchat/torchchat/generate.py", line 1093, in main
    gen = Generator(
  File "/home/guillaume/test/torchchat/torchchat/generate.py", line 284, in __init__
    self.model = _initialize_model(self.builder_args, self.quantize, self.tokenizer)
  File "/home/guillaume/test/torchchat/torchchat/cli/builder.py", line 562, in _initialize_model
    model = _load_model(builder_args)
  File "/home/guillaume/test/torchchat/torchchat/cli/builder.py", line 482, in _load_model
    model = _load_model_default(builder_args)
  File "/home/guillaume/test/torchchat/torchchat/cli/builder.py", line 405, in _load_model_default
    model.model.load_state_dict(state_dict, assign=True, strict=False)
  File "/home/guillaume/test/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 2568, in load_state_dict
    raise RuntimeError(
RuntimeError: Error(s) in loading state_dict for DeepFusionModel:
        size mismatch for encoder.clip.token_pos_embedding.local_token_positional_embedding: copying a param with shape torch.Size([1025, 1280]) from checkpoint, the shape in current model is torch.Size([1601, 1280]).
        size mismatch for encoder.clip.token_pos_embedding.global_token_positional_embedding: copying a param with shape torch.Size([4, 4, 1025, 1280]) from checkpoint, the shape in current model is torch.Size([4, 4, 1601, 1280])

Versions

python collect_env.py Collecting environment information... PyTorch version: 2.5.0.dev20240901+cpu Is debug build: False CUDA used to build PyTorch: None 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.30.3 Libc version: glibc-2.35

Python version: 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] (64-bit runtime) Python platform: Linux-6.8.0-40-generic-x86_64-with-glibc2.35 Is CUDA available: False CUDA runtime version: No CUDA CUDA_MODULE_LOADING set to: N/A GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture : x86_64 Mode(s) opératoire(s) des processeurs : 32-bit, 64-bit Address sizes: 46 bits physical, 48 bits virtual Boutisme : Little Endian Processeur(s) : 28 Liste de processeur(s) en ligne : 0-27 Identifiant constructeur : GenuineIntel Nom de modèle : Intel(R) Core(TM) i7-14700K Famille de processeur : 6 Modèle : 183 Thread(s) par cœur : 2 Cœur(s) par socket : 20 Socket(s) : 1 Révision : 1 Vitesse maximale du processeur en MHz : 5600,0000 Vitesse minimale du processeur en MHz : 800,0000 BogoMIPS : 6835.20 Drapaux : 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 smx 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 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 tme rdpid movdiri movdir64b fsrm md_clear serialize pconfig arch_lbr ibt flush_l1d arch_capabilities Virtualisation : VT-x Cache L1d : 768 KiB (20 instances) Cache L1i : 1 MiB (20 instances) Cache L2 : 28 MiB (11 instances) Cache L3 : 33 MiB (1 instance) Nœud(s) NUMA : 1 Nœud NUMA 0 de processeur(s) : 0-27 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] numpy==1.26.4 [pip3] torch==2.5.0.dev20240901+cpu [pip3] torchao==0.5.0 [pip3] torchtune==0.0.0 [pip3] torchvision==0.20.0.dev20240901+cpu [conda] Could not collect

Jack-Khuu commented 6 days ago

Thanks for flagging, let me take a look

Jack-Khuu commented 6 days ago

Looks like there is some config mismatch between the two versions of 11B that's not being accounted for

We'll look into getting this fixed for meta-llama/Llama-3.2-11B-Vision. In the meantime, we'd love for you to try meta-llama/Llama-3.2-11B-Vision-Instruct

openconcerto commented 5 days ago

I confirm that it works with Llama-3.2-11B-Vision.

It takes 53 minutes to answer the prompt on a PNG image of 2409x3435 pixels, on my Intel 14700K with 128GB of RAM (no gpu).

Jack-Khuu commented 5 days ago

Thank for checking and sharing the numbers

We're working to get torch.compile up and running for 11B, so that'll speed things up when it's ready