lmdeploy icon indicating copy to clipboard operation
lmdeploy copied to clipboard

[Bug] UnboundLocalError: local variable 'head_num' referenced before assignment

Open zhenxingsh opened this issue 2 years ago • 4 comments

Checklist

  • [X] 1. I have searched related issues but cannot get the expected help.
  • [ ] 2. The bug has not been fixed in the latest version.

Describe the bug

在docker内编译lmdeploy源码后,执行如下静态推理性能测试。 cd lmdeploy/benchmark python3 profile_generation.py internlm/internlm-7b 出现如下error信息: `profile_target= functools.partial(<function profile_throughput at 0x7f74050063a0>, concurrency=1, input_seqlen=1, engine_config=TurbomindEngineConfig(model_name=None, model_format='hf', tp=1, session_len=2048, max_batch_size=128, cache_max_entry_count=0.8, cache_block_seq_len=64, enable_prefix_caching=False, quant_policy=0, rope_scaling_factor=0.0, use_logn_attn=False, download_dir=None, revision=None, max_prefill_token_num=8192, num_tokens_per_iter=0, max_prefill_iters=1), gen_config=EngineGenerationConfig(n=1, max_new_tokens=128, top_p=0.8, top_k=1, temperature=0.8, repetition_penalty=1.0, ignore_eos=True, random_seed=None, stop_words=None, bad_words=None, min_new_tokens=None, skip_special_tokens=True, logprobs=None), test_round=3, warmup_round=1)

model_path= internlm/internlm-7b

profiling ... concurrency: 1, n_prompt_token: 1, n_completion_token: 128, test_round: 3, warmup_round: 1 2024-05-28 14:18:22,748 - lmdeploy - WARNING - model_source: hf_model Traceback (most recent call last): File "profile_generation.py", line 482, in main() File "profile_generation.py", line 435, in main output = _process_map(profile_target, (args.model_path, )) File "profile_generation.py", line 374, in _process_map raise ret UnboundLocalError: local variable 'head_num' referenced before assignment `

Reproduction

python3 profile_generation.py internlm/internlm-7b

Environment

参考官方文档编译流程配置的环境,
pip install -r requirements.txt

Error traceback

No response

zhenxingsh avatar May 28 '24 06:05 zhenxingsh

直接使用 openmmlab/lmdeploy:v0.4.2 呢?

lvhan028 avatar May 28 '24 07:05 lvhan028

没办法复现你的问题。

你可以试下下面的代码能不能执行成功

from lmdeploy.turbomind import TurboMind
m = TurboMind.from_pretrained('internlm/internlm-7b')

irexyc avatar May 28 '24 07:05 irexyc

没办法复现你的问题。

你可以试下下面的代码能不能执行成功

from lmdeploy.turbomind import TurboMind
m = TurboMind.from_pretrained('internlm/internlm-7b')

这个可以运行的

zhenxingsh avatar May 28 '24 07:05 zhenxingsh

@irexyc 重新运行之前的脚本,发现竟然又可以了。 排查看了下是模型bin文件数量比之前运行时有新增。 这种问题难道是因为模型文件下载不完整导致的情况发生?

zhenxingsh avatar May 28 '24 07:05 zhenxingsh