error when loading the model

#2
by PerRing - opened
WARNING:accelerate.utils.modeling:The model weights are not tied. Please use the `tie_weights` method before using the `infer_auto_device` function.
Loading checkpoint shards: 0%
0/6 [00:00<?, ?it/s]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-c1b45b9f685e> in <cell line: 3>()
      1 from transformers import AutoProcessor,AutoTokenizer, AutoModelForCausalLM, AutoConfig,CLIPImageProcessor, LlamaForCausalLM, LlamaModel, LlavaForConditionalGeneration, LlavaConfig, CLIPVisionConfig, LlamaConfig, CLIPVisionModel, LlavaProcessor
      2 import torch
----> 3 LlavaModel = LlavaForConditionalGeneration.from_pretrained("llava-hf/llava-1.5-13b-hf", torch_dtype=torch.float16, device_map='auto')

3 frames
/usr/local/lib/python3.10/dist-packages/accelerate/utils/modeling.py in set_module_tensor_to_device(module, tensor_name, device, value, dtype, fp16_statistics)
    283     if value is not None:
    284         if old_value.shape != value.shape:
--> 285             raise ValueError(
    286                 f'Trying to set a tensor of shape {value.shape} in "{tensor_name}" (which has shape {old_value.shape}), this look incorrect.'
    287             )

ValueError: Trying to set a tensor of shape torch.Size([32064, 5120]) in "weight" (which has shape torch.Size([32128, 5120])), this look incorrect.

'llava-hf/llava-1.5-7b-hf' is loaded without any error, but when load 'llava-hf/llava-1.5-13b-hf', this error happen

Llava Hugging Face org
β€’
edited Dec 9, 2023

cc @ybelkada quick fix is to use set the vocab_size to 32064 in the call to from_pretrained

Llava Hugging Face org

@PerRing can you try to pass revision="refs/pr/3" in from_pretrained ? (before I properly look into it)

@ybelkada

LlavaModel = LlavaForConditionalGeneration.from_pretrained("llava-hf/llava-1.5-13b-hf",torch_dtype=torch.float16,revision="refs/pr/3",device_map='cpu')

this work!

Llava Hugging Face org

Awesome, @ArthurZ feel free to merge #3

ybelkada changed discussion status to closed

Sign up or log in to comment