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

Qwen1.5 1b8和Qwen2 7b推理到最后出现重复性回答 #35

Closed
loredunk opened this issue Jul 24, 2024 · 3 comments
Closed

Qwen1.5 1b8和Qwen2 7b推理到最后出现重复性回答 #35

loredunk opened this issue Jul 24, 2024 · 3 comments

Comments

@loredunk
Copy link
Contributor

soc环境
transformers:4.42.4
torch:2.3.1
LLM-TPU:9a744f0/latest 2024.07.23
driver版本:0.5.1

linaro@bm1684:/usr/lib/cmake/libsophon$ bm_version
SophonSDK version: v24.04.01
sophon-soc-libsophon : 0.5.1
sophon-mw-soc-sophon-ffmpeg : 0.10.0
sophon-mw-soc-sophon-opencv : 0.10.0
BL2 v2.7(release):7b2c33d Built : 16:02:07, Jun 24 2024
BL31 v2.7(release):7b2c33d Built : 16:02:07, Jun 24 2024
U-Boot 2022.10 7b2c33d (Jun 24 2024 - 16:01:43 +0800) Sophon BM1684X
KernelVersion : Linux bm1684 5.4.217-bm1684-g27254622663c #1 SMP Mon Jun 24 16:02:21 CST 2024 aarch64 aarch64 aarch64 GNU/Linux
HWVersion: 0x00
MCUVersion: 0x01

image

image

偶尔也会有正常的回答。只不过经常这样。

@chuxiaoyi2023
Copy link
Collaborator

可以使用penalty_sample来进行采样
--generation_mode penalty_sample

或者是将惩罚系数调高一些,这个可以用
python pipeline.py --help
来查看参数说明

如果两种方式都解决不了,可能是因为量化的缘故导致模型性能下降,那就只能用int8或者fp16/bf16了

另外我看你的速度很快,估计是比较小的模型,一般来说这种重复是小模型比较常见的,可以使用7B这样的规格尝试一下

@loredunk
Copy link
Contributor Author

loredunk commented Jul 25, 2024

可以使用penalty_sample来进行采样 --generation_mode penalty_sample

或者是将惩罚系数调高一些,这个可以用 python pipeline.py --help 来查看参数说明

如果两种方式都解决不了,可能是因为量化的缘故导致模型性能下降,那就只能用int8或者fp16/bf16了

另外我看你的速度很快,估计是比较小的模型,一般来说这种重复是小模型比较常见的,可以使用7B这样的规格尝试一下

感谢您的回复!!换了采样方式确实有改善,但是在7B的模型中,我发现当我开启第二轮对话的时候,都会出现这种情况,

*第一轮对话
FTL: 14.625 s
TPS: 9.126 token/s

Question: 介绍一下九江

Answer: *** bmruntime trace: ***
============ check coeff =============
Coeff, chip[0], SHA[01488B82], addr[0x2c7401000], size[0x7d93000]
Coeff, chip[0], SHA[034DF379], addr[0x233b56000], size[0x7d93000]
Coeff, chip[0], SHA[06E035BB], addr[0x4eee5f000], size[0x7d93000]
^CCoeff, chip[0], SHA[0E0D6057], addr[0x2611b2000], size[0x7d93000]
Coeff, chip[0], SHA[122599EE], addr[0x1e4435000], size[0x7d93000]
Coeff, chip[0], SHA[15A4D747], addr[0x24a684000], size[0x7d93000]
Coeff, chip[0], SHA[1C3D5D0A], addr[0x277ce0000], size[0x7d93000]

开始了检测,然后检测完了,再跑Pipeline的命令,就会有关于kernal相关报错,重启就好,但是重启完又只能回答一次,这是什么原因呢?
[BMRT][load_tpu_module:1802] INFO:loading firmare in bmodel
[a53lite_runtime][error] load library send api error, ret 2
[BMRT][preload_funcs:2117] FATAL:BMRT_ASSERT: _kernel_modules[core_id]
python3: /home/linaro/LLM-TPU/models/Qwen1_5/python_demo/chat.cpp:129: void Qwen::init(const std::vector&, std::string): Assertion `true == ret' failed.
./run_demo.sh: line 28: 3955 Aborted

@chuxiaoyi2023
Copy link
Collaborator

这个就有点非常难搞了,这个错误挺麻烦的 :(
想问一下你是自己转的模型么,还是用我们转好的,推荐以下一些方式

  1. 编译模型出错:使用config.json里面的transformers版本,你的torch和transformers有点高了(概率不大)
  2. 代码有问题:使用gdb定位到chat.cpp里面forward_first的net_launch上下几行,一行一行next,同时开一个bm-smi,一般是net_launch出错,定位到是具体走哪行时,bm-smi里面变成fault(有可能)
  3. 转化模型时出错:可能是工具链tpu-mlir有问题,这个我们内部一般是截断模型,一行一行看,model_transform.py 里面有一个output_names参数截断
  4. 版本问题

也可以参考这里https://github.com/sophgo/LLM-TPU/blob/main/docs/FAQ.md
Q11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants