project-baize/baize-chatbot

AttributeError: 'NoneType' object has no attribute 'view'

Amit507017 opened this issue · 1 comments

Upon running the command " python finetune.py 7b 32 0.0002 alpaca"

I got following error.

Traceback (most recent call last):
File "finetune.py", line 171, in
trainer.train()
File "/home/user6/venvs/py38/lib/python3.8/site-packages/transformers/trainer.py", line 1645, in train
return inner_training_loop(
File "/home/user6/venvs/py38/lib/python3.8/site-packages/transformers/trainer.py", line 1929, in _inner_training_loop
tr_loss_step = self.training_step(model, inputs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/transformers/trainer.py", line 2750, in training_step
loss = self.compute_loss(model, inputs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/transformers/trainer.py", line 2775, in compute_loss
outputs = model(**inputs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/accelerate/utils/operations.py", line 553, in forward
return model_forward(*args, **kwargs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/accelerate/utils/operations.py", line 541, in call
return convert_to_fp32(self.model_forward(*args, **kwargs))
File "/home/user6/venvs/py38/lib/python3.8/site-packages/torch/amp/autocast_mode.py", line 14, in decorate_autocast
return func(*args, **kwargs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/peft/peft_model.py", line 686, in forward
return self.base_model(
File "/home/user6/venvs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/transformers/models/llama/modeling_llama.py", line 688, in forward
outputs = self.model(
File "/home/user6/venvs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/transformers/models/llama/modeling_llama.py", line 570, in forward
layer_outputs = torch.utils.checkpoint.checkpoint(
File "/home/user6/venvs/py38/lib/python3.8/site-packages/torch/utils/checkpoint.py", line 249, in checkpoint
return CheckpointFunction.apply(function, preserve, *args)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/torch/autograd/function.py", line 506, in apply
return super().apply(*args, **kwargs) # type: ignore[misc]
File "/home/user6/venvs/py38/lib/python3.8/site-packages/torch/utils/checkpoint.py", line 107, in forward
outputs = run_function(*args)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/transformers/models/llama/modeling_llama.py", line 566, in custom_forward
return module(*inputs, output_attentions, None)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/transformers/models/llama/modeling_llama.py", line 292, in forward
hidden_states, self_attn_weights, present_key_value = self.self_attn(
File "/home/user6/venvs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/home/user6/venvs/py38/lib/python3.8/site-packages/transformers/models/llama/modeling_llama.py", line 194, in forward
query_states = self.q_proj(hidden_states).view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
AttributeError: 'NoneType' object has no attribute 'view'
0%| | 0/780 [00:01<?, ?it/s]

Can you help me with this?

Could you try upgrade Transformers? Also print the input? Not quite sure about this error.