MOSS icon indicating copy to clipboard operation
MOSS copied to clipboard

推荐使用 AutoGPTQ 或 AutoGPTQ-triton 进行模型量化和推理

Open PanQiWei opened this issue 1 year ago • 13 comments

我在 issues 中看到很多同学在使用量化版本的模型推理时遇到问题,在这里想自吹自擂地推荐一下自己的新项目,希望能够对大家有所帮助。

AutoGPTQ 是一个简单易用的模型量化和推理工具包,提供类 Hugging Face transformers 风格的函数接口并与其 TextGenerationPipeline 完全兼容。目前支持四大主流开源 GPT 模型家族的量化和推理,并能够通过少数几行代码的编写,快速拓展到其他 GPT 模型的量化及推理应用。此外,项目中还提供了多个预定义的任务类型,能够方便使用者快速评估模型在下游具体任务上的表现。

AutoGPTQ-tritonGPTQ-for-LLaMa 项目所有者在 AutoGPTQ 的基础上拓展的 triton 推理版本。

对于拥有能够使用 triton 的操作系统的同学,推荐使用 AutoGPTQ-triton 以获得更快的推理体验,而如果无法使用 triton 的话,AutoGPTQ 也能够让你快速上手完成模型的量化和推理应用。

PanQiWei avatar Apr 24 '23 18:04 PanQiWei

最新版本的 AutoGPTQ 已经支持 MOSS 模型的量化,今晚我会把量化后的模型权重上传至 huggingface hub

PanQiWei avatar Apr 25 '23 05:04 PanQiWei

marvinzhz avatar Apr 25 '23 07:04 marvinzhz

最新版本的 AutoGPTQ 已经支持 MOSS 模型的量化,今晚我会把量化后的模型权重上传至 huggingface hub

链接给一个,谢谢

liuyunrui123 avatar Apr 25 '23 15:04 liuyunrui123

我在pip里无法安装triton,麻烦您看一下如何安装这个依赖 系统是EulerOS 2.0 (SP8), CANN-6.0.1

muyi123567 avatar Apr 26 '23 10:04 muyi123567

我在pip里无法安装triton,麻烦您看一下如何安装这个依赖 系统是EulerOS 2.0 (SP8), CANN-6.0.1

你好,请问有详细的报错信息吗?

PanQiWei avatar Apr 26 '23 11:04 PanQiWei

最新版本的 AutoGPTQ 已经支持 MOSS 模型的量化,今晚我会把量化后的模型权重上传至 huggingface hub

链接给一个,谢谢

理论上官方的量化版本模型能够直接在 auto-gptq 上使用

PanQiWei avatar Apr 26 '23 11:04 PanQiWei

我在pip里无法安装triton,麻烦您看一下如何安装这个依赖 系统是EulerOS 2.0 (SP8), CANN-6.0.1

你好,请问有详细的报错信息吗?

Looking in indexes: http://100.125.0.87:32021/repository/pypi/simple, https://pypi.ngc.nvidia.com/ ERROR: Could not find a version that satisfies the requirement triton (from versions: none) ERROR: No matching distribution found for triton

muyi123567 avatar Apr 26 '23 11:04 muyi123567

我在pip里无法安装triton,麻烦您看一下如何安装这个依赖 系统是EulerOS 2.0 (SP8), CANN-6.0.1

你好,请问有详细的报错信息吗?

Looking in indexes: http://100.125.0.87:32021/repository/pypi/simple, https://pypi.ngc.nvidia.com/ ERROR: Could not find a version that satisfies the requirement triton (from versions: none) ERROR: No matching distribution found for triton

应该是镜像源的问题吧,试试使用 pip install auto-gptq[triton] -i https://pypi.org/simplepip install triton -i https://pypi.org/simple

PanQiWei avatar Apr 26 '23 11:04 PanQiWei

我在pip里无法安装triton,麻烦您看一下如何安装这个依赖 系统是EulerOS 2.0 (SP8), CANN-6.0.1

你好,请问有详细的报错信息吗?

Looking in indexes: http://100.125.0.87:32021/repository/pypi/simple, https://pypi.ngc.nvidia.com/ ERROR: Could not find a version that satisfies the requirement triton (from versions: none) ERROR: No matching distribution found for triton

应该是镜像源的问题吧,试试使用 pip install auto-gptq[triton] -i https://pypi.org/simplepip install triton -i https://pypi.org/simple

triton用https://pypi.org/simple这个镜像源确实安装不了,找不到版本,云平台和我自己的电脑都试过了,auto-gptq[triton]pip安装了,前面都正常,后面出现 '''INFO: pip is looking at multiple versions of auto-gptq[triton] to determine which version is compatible with other requirements. This could take a while. ERROR: Could not find a version that satisfies the requirement triton>=2.0.0 (from auto-gptq[triton]) (from versions: none) ERROR: No matching distribution found for triton>=2.0.0'''这个问题。我想用int4的moss,差这个triton一直无法安装上

muyi123567 avatar Apr 26 '23 11:04 muyi123567

我这边上面两个命令都可以正常安装依赖,会不会是你 pip 版本的问题,先执行一下 pip3 install --upgrade pip 升级 pip

PanQiWei avatar Apr 26 '23 12:04 PanQiWei

最新版本的 AutoGPTQ 已经支持 MOSS 模型的量化,今晚我会把量化后的模型权重上传至 huggingface hub

链接给一个,谢谢

理论上官方的量化版本模型能够直接在 auto-gptq 上使用

官方 repo 的量化版本提示找不到 quantize_config.json

│ C:\Users\daniel\Downloads\oobabooga_windows\installer_files\env\lib\site-packages\auto_gptq\mode │
│ ling\_base.py:53 in from_pretrained                                                              │
│                                                                                                  │
│    50 │                                                                                          │
│    51 │   @classmethod                                                                           │
│    52 │   def from_pretrained(cls, save_dir: str):                                               │
│ ❱  53 │   │   with open(join(save_dir, "quantize_config.json"), "r", encoding="utf-8") as f:     │
│    54 │   │   │   return cls(**json.load(f))                                                     │
│    55 │                                                                                          │
│    56 │   def to_dict(self):                                                                     │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
FileNotFoundError: [Errno 2] No such file or directory:
'models\\fnlp_moss-moon-003-sft-plugin-int4\\quantize_config.json'

d4n1elchen avatar May 24 '23 05:05 d4n1elchen

有两种方式解决:

  1. 手动添加一个 quantize_config.json 到模型存放的目录下
  2. (如果直接使用 auto_gptq 的话)实例化一个 BaseQuantizeConfig 对象并传给 .from_quantizedquantize_config 参数

PanQiWei avatar May 24 '23 10:05 PanQiWei

我如何取得 config 數據? Repo 裏頭有嗎

d4n1elchen avatar May 24 '23 15:05 d4n1elchen