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

llama2量化后版本加载报错 #15

Open
WheatJH opened this issue Aug 3, 2023 · 1 comment
Open

llama2量化后版本加载报错 #15

WheatJH opened this issue Aug 3, 2023 · 1 comment

Comments

@WheatJH
Copy link

WheatJH commented Aug 3, 2023

llama2-7b-chat-hf,按照提供的量化步骤,得到4bit版本的模型并补齐模型文件,通过AutoModelForCausalLM.from_pretrained方式加载时,报NotImplementedError: Cannot copy out of meta tensor; no data!
环境配置:
accelerate==0.21.0
bitsandbytes==0.40.2
gradio==3.37.0
protobuf==3.20.3
scipy==1.11.1
sentencepiece==0.1.99
transformers==4.31.0
torch==1.13.0a0+340c412
cuda==11.7

@chopin1998
Copy link

我看了一下, 似乎新版的 transformer 可以直接进行量化后使用, 不需要 额外的量化过程?

model_id = "meta-llama/Llama-2-13b-chat-hf"

nf4_config = BitsAndBytesConfig(load_in_4bit=True,
                                bnb_4bit_quant_type="nf4",
                                bnb_4bit_use_double_quant=True,
                                bnb_4bit_compute_dtype=torch.bfloat16)


model_nf4 = AutoModelForCausalLM.from_pretrained(model_id, 
                                                 quantization_config=nf4_config)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants