microsoft / microsoft/LLMLingua

compress_prompt Reports Error: AttributeError: 'NoneType' object has no attribute 'device'

Open
#45 1 comment 0 reactions 1 assignee View on GitHub

@iofu728 is already working on this.

Since Jan 8, 2024.

question
Dominant language
Python
Stars
6.7k
Forks
428
Avg merge
2d 4h
Merged PRs (30d)
1

Description

llm_lingua = PromptCompressor(model_name="Baichuan2-main/Baichuan2-7B-Chat", model_config=model_config)
compressed_prompt = llm_lingua.compress_prompt(prompt, instruction="", question="", target_token=200)
Traceback (most recent call last):
File "", line 1, in
NameError: name 'prompt' is not defined
compressed_prompt = llm_lingua.compress_prompt('你好', instruction="", question="", target_token=200)
/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/bitsandbytes/autograd/_functions.py:322: UserWarning: MatMul8bitLt: inputs will be cast from torch.bfloat16 to float16 during quantization
warnings.warn(f"MatMul8bitLt: inputs will be cast from {A.dtype} to float16 during quantization")
Traceback (most recent call last):
File "", line 1, in
File "/PDF-OCR/AIGC/EngineeringQA/Baichuan2-main/LLMLingua/llmlingua/prompt_compressor.py", line 252, in compress_prompt
context = self.iterative_compress_prompt(
File "/PDF-OCR/AIGC/EngineeringQA/Baichuan2-main/LLMLingua/llmlingua/prompt_compressor.py", line 734, in iterative_compress_prompt
loss, past_key_values = self.get_ppl(
File "/PDF-OCR/AIGC/EngineeringQA/Baichuan2-main/LLMLingua/llmlingua/prompt_compressor.py", line 105, in get_ppl
response = self.model(
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/root/.cache/huggingface/modules/transformers_modules/Baichuan2-7B-Chat/modeling_baichuan.py", line 719, in forward
outputs = self.model(
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/root/.cache/huggingface/modules/transformers_modules/Baichuan2-7B-Chat/modeling_baichuan.py", line 494, in forward
layer_outputs = decoder_layer(
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/root/.cache/huggingface/modules/transformers_modules/Baichuan2-7B-Chat/modeling_baichuan.py", line 306, in forward
hidden_states, self_attn_weights, present_key_value = self.self_attn(
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/root/.cache/huggingface/modules/transformers_modules/Baichuan2-7B-Chat/modeling_baichuan.py", line 238, in forward
proj = self.W_pack(hidden_states)
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/bitsandbytes/nn/modules.py", line 441, in forward
out = bnb.matmul(x, self.weight, bias=self.bias, state=self.state)
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/bitsandbytes/autograd/_functions.py", line 563, in matmul
return MatMul8bitLt.apply(A, B, out, bias, state)
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/torch/autograd/function.py", line 506, in apply
return super().apply(*args, **kwargs) # type: ignore[misc]
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/bitsandbytes/autograd/_functions.py", line 344, in forward
state.CxB, state.SB = F.transform(state.CB, to_order=formatB)
File "/root/anaconda3/envs/baichuan2/lib/python3.10/site-packages/bitsandbytes/functional.py", line 2080, in transform
prev_device = pre_call(A.device)
AttributeError: 'NoneType' object has no attribute 'device'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.