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

[BUG]: LlamaRM model has no attribute 'resize_token_embeddings' #3389

Closed
lierik opened this issue Apr 1, 2023 · 8 comments
Closed

[BUG]: LlamaRM model has no attribute 'resize_token_embeddings' #3389

lierik opened this issue Apr 1, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@lierik
Copy link

lierik commented Apr 1, 2023

🐛 Describe the bug

LlamaRM is not a huggingface transformer module but LoraModule, while llamaRM.model is a huggingface transformer model. So LlamaRm has no function "resize_token_embeddings" but LlamaRM.model has. When using Llama to train RM model, it will raise the error: AttributeError: 'LlamaRM' object has no attribute 'resize_token_embeddings'

line 68 in coati/utils/tokenizer_utils.py

Environment

No response

@lierik lierik added the bug Something isn't working label Apr 1, 2023
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Title: [BUG]:

@lierik lierik changed the title [BUG]: [BUG]: LlamaRM model has no attribute 'resize_token_embeddings' Apr 1, 2023
@bingjie3216
Copy link

bingjie3216 commented Apr 2, 2023

Met the same issue:

    smart_tokenizer_and_embedding_resize(smart_tokenizer_and_embedding_resize(

File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/x-gpu1/code/Users/x/code/ColossalAI/applications/Chat/coati/utils/tokenizer_utils.py", line 68, in smart_tokenizer_and_embedding_resize
File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/x-gpu1/code/Users/x/code/ColossalAI/applications/Chat/coati/utils/tokenizer_utils.py", line 68, in smart_tokenizer_and_embedding_resize
model.resize_token_embeddings(len(tokenizer))model.resize_token_embeddings(len(tokenizer))

File "/anaconda/envs/coati/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1614, in getattr
File "/anaconda/envs/coati/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1614, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'LlamaRM' object has no attribute 'resize_token_embeddings'AttributeError: 'LlamaRM' object has no attribute 'resize_token_embeddings

@tianyil1
Copy link

tianyil1 commented Apr 3, 2023

Meet the same issue:
Traceback (most recent call last): File "/home/vmagent/app/ColossalAI/applications/Chat/examples/train_reward_model.py", line 166, in <module> train(args) File "/home/vmagent/app/ColossalAI/applications/Chat/examples/train_reward_model.py", line 77, in train tokenizer = prepare_llama_tokenizer_and_embedding(tokenizer, model) File "/home/vmagent/app/ColossalAI/applications/Chat/coati/utils/tokenizer_utils.py", line 37, in prepare_llama_tokenizer_and_embedding smart_tokenizer_and_embedding_resize( File "/home/vmagent/app/ColossalAI/applications/Chat/coati/utils/tokenizer_utils.py", line 68, in smart_tokenizer_and_embedding_resize model.resize_token_embeddings(len(tokenizer)) File "/opt/intel/oneapi/intelpython/latest/envs/coati/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1269, in __getattr__ raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'LlamaRM' object has no attribute 'resize_token_embeddings'

@HaixHan
Copy link

HaixHan commented Apr 3, 2023

Meet the same issue:
AttributeError: 'LlamaRM' object has no attribute 'resize_token_embeddings'
WARNING:torch.distributed.elastic.multiprocessing.api:Sending process 526441 closing signal SIGTERM
ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 526440) of binary: /data/anaconda3/bin/python
Traceback (most recent call last):
File "/data/anaconda3/bin/torchrun", line 8, in
sys.exit(main())
File "/data/anaconda3/lib/python3.9/site-packages/torch/distributed/elastic/multiprocessing/errors/init.py", line 346, in wrapper
return f(*args, **kwargs)
File "/data/anaconda3/lib/python3.9/site-packages/torch/distributed/run.py", line 762, in main
run(args)
File "/data/anaconda3/lib/python3.9/site-packages/torch/distributed/run.py", line 753, in run
elastic_launch(
File "/data/anaconda3/lib/python3.9/site-packages/torch/distributed/launcher/api.py", line 132, in call
return launch_agent(self._config, self._entrypoint, list(args))
File "/data/anaconda3/lib/python3.9/site-packages/torch/distributed/launcher/api.py", line 246, in launch_agent
raise ChildFailedError(
torch.distributed.elastic.multiprocessing.errors.ChildFailedError:

@StarsTesla
Copy link

I met this error too, but if you are training the stage 2, you should modified the pretrain to Coati7B(you trained in stage 1) instead of LLaMA7B that provided by huggingface.

@HaixHan
Copy link

HaixHan commented Apr 3, 2023

I met this error too, but if you are training the stage 2, you should modified the pretrain to Coati7B(you trained in stage 1) instead of LLaMA7B that provided by huggingface.

Thank you very much for the reminder!

@samulew
Copy link

samulew commented Apr 10, 2023

met the some problem , and i add the code at line 72 of train_reward_model.py , imitating train_sft.py :

tokenizer = LlamaTokenizer.from_pretrained(args.pretrain)
tokenizer.eos_token = '<\s>'
tokenizer.pad_token = tokenizer.eos_token

@honglvagan
Copy link

me too,i met the same problem

ubuntu@VM-0-5-ubuntu:~/Desktop/bookDesk202303061/text-generation-webui$ python3 server.py --cpu --model llama-7b-hf --lora chinese-alpaca-lora-7b
Gradio HTTP request redirected to localhost :)
bin /home/ubuntu/.local/lib/python3.8/site-packages/bitsandbytes/libbitsandbytes_cpu.so
/home/ubuntu/.local/lib/python3.8/site-packages/bitsandbytes/cextension.py:33: UserWarning: The installed version of bitsandbytes was compiled without GPU support. 8-bit optimizers, 8-bit multiplication, and GPU quantization are unavailable.
warn("The installed version of bitsandbytes was compiled without GPU support. "
/home/ubuntu/.local/lib/python3.8/site-packages/torch/cuda/init.py:497: UserWarning: Can't initialize NVML
warnings.warn("Can't initialize NVML")
Loading llama-7b-hf...
llama.cpp weights detected: models/llama-7b-hf/ggml-alpaca-7b-q4.bin

llama.cpp: loading model from models/llama-7b-hf/ggml-alpaca-7b-q4.bin
llama.cpp: can't use mmap because tensors are not aligned; convert to new format to avoid this
llama_model_load_internal: format = 'ggml' (old version with low tokenizer quality and no mmap support)
llama_model_load_internal: n_vocab = 32000
llama_model_load_internal: n_ctx = 2048
llama_model_load_internal: n_embd = 4096
llama_model_load_internal: n_mult = 256
llama_model_load_internal: n_head = 32
llama_model_load_internal: n_layer = 32
llama_model_load_internal: n_rot = 128
llama_model_load_internal: ftype = 2 (mostly Q4_0)
llama_model_load_internal: n_ff = 11008
llama_model_load_internal: n_parts = 1
llama_model_load_internal: model size = 7B
llama_model_load_internal: ggml ctx size = 4113739.11 KB
llama_model_load_internal: mem required = 5809.32 MB (+ 1026.00 MB per state)
...................................................................................................
.
llama_init_from_file: kv self size = 1024.00 MB
AVX = 1 | AVX2 = 1 | AVX512 = 1 | FMA = 1 | NEON = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | VSX = 0 |
Applying the following LoRAs to llama-7b-hf: chinese-alpaca-lora-7b
Traceback (most recent call last):
File "server.py", line 923, in
add_lora_to_model([shared.args.lora])
File "/home/ubuntu/Desktop/bookDesk202303061/text-generation-webui/modules/LoRA.py", line 40, in add_lora_to_model
shared.model.resize_token_embeddings(len(shared.tokenizer))
AttributeError: 'LlamaCppModel' object has no attribute 'resize_token_embeddings'

what should i do to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants