ColossalAI icon indicating copy to clipboard operation
ColossalAI copied to clipboard

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

Open lierik opened this issue 1 year ago β€’ 8 comments

πŸ› 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 avatar Apr 01 '23 04:04 lierik

Bot detected the issue body's language is not English, translate it automatically. πŸ‘―πŸ‘­πŸ»πŸ§‘β€πŸ€β€πŸ§‘πŸ‘«πŸ§‘πŸΏβ€πŸ€β€πŸ§‘πŸ»πŸ‘©πŸΎβ€πŸ€β€πŸ‘¨πŸΏπŸ‘¬πŸΏ


Title: [BUG]:

Issues-translate-bot avatar Apr 01 '23 04:04 Issues-translate-bot

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

bingjie3216 avatar Apr 02 '23 04:04 bingjie3216

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'

tianyil1 avatar Apr 03 '23 08:04 tianyil1

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:

HaixHan avatar Apr 03 '23 09:04 HaixHan

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.

StarsTesla avatar Apr 03 '23 11:04 StarsTesla

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!

HaixHan avatar Apr 03 '23 12:04 HaixHan

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

samulew avatar Apr 10 '23 08:04 samulew

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?

honglvagan avatar Apr 24 '23 02:04 honglvagan