InternLM / InternLM/lmdeploy

[Feature] 量化lite命令能否支持单机多卡

Open
#3,361 1 comment 0 reactions 1 assignee Claimed by @AllentDan View on GitHub
Dominant language
Python
Stars
8.1k
Forks
748
Avg merge
6d 2h
Merged PRs (30d)
54

Description

### Motivation

对于很大的模型如ds六百多B,单卡显存不够用。
目前lite命令只支持单卡,希望后续能够增加支持单机多卡。
具体如下:
1. lite auto_awq命令支持单机多卡
2. lite smooth_quant命令支持单机多卡
3. lite smooth_quant命令支持ascend环境

另外推理这块后端为pytorch时也存在不支持的情况,希望后续能够增加支持:
1. 使用auto_awq w4a16量化模型成功,推理后端为pytorch即--backend pytorch情况下,对单机多卡的支持。

具体测试结论见下面内容。

### Related resources

_No response_

### Additional context

测试了多种不同的用例,总结如下:

推理命令大致这样:lmdeploy serve api_server qwq-32b-w4a16 --server-port 23334 --cache-max-entry-count 0.05 --quant-policy 4 --log-level DEBUG --backend pytorch --device ascend(或者cuda) --tp 2

cuda环境:
a) lite auto_awq w4a16量化:
推理运行结果:
tp=1正常不报错。
tp=2报错RuntimeError: The expanded size of the tensor (5120) must match the existing size (2560) at non-singleton dimension 0. Target sizes: [5120]. Tensor sizes: [2560]

b) lite smooth_quant w8a8量化:
推理运行结果:
tp=1和tp=2都正常。

ascend环境:
a) lite auto_awq w4a16量化:
推理运行结果:
tp=1报错AttributeError: 'MergedAwqLinear' object has no attribute 'is_tp'.
tp=2报错RuntimeError: The expanded size of the tensor (5120) must match the existing size (2560) at non-singleton dimension 0. Target sizes: [5120]. Tensor sizes: [2560]

b) lite smooth_quant w8a8量化:直接报错,无法量化成功。
但是如果用在cuda环境下lite smooth_quant w8a8量化成功的模型,进行推理,tp=1和tp=2都正常。

可以看到以下结论:

1. lite auto_awq和smooth_quant命令目前都不支持单机多卡
2. lite smooth_quant命令不支持ascend环境
3. lite auto_awq w4a16量化成功的模型,进行推理时在选择pytorch后端情况下,不支持单机多卡
4. lite smooth_quant量化成功的模型,进行推理时在选择pytorch后端情况下,支持单机多卡

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.