Skip to content

Commit 85e54b6

Browse files
authored
Fix llm quantization docs (#458)
1 parent 94105d2 commit 85e54b6

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

docs/source/LLM/LLM量化文档.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# LLM量化文档
2-
swift使用awq技术对模型进行量化. 该量化技术支持vllm进行加速推理. 使用VLLM对awq量化模型进行加速推理可以查看[]().
2+
swift使用awq技术对模型进行量化. 该量化技术支持vllm进行加速推理.
33

44

55
## 目录
@@ -31,6 +31,7 @@ pip install -r requirements/llm.txt -U
3131
```bash
3232
# awq-int4量化 (使用A100大约需要20分钟)
3333
CUDA_VISIBLE_DEVICES=0 swift export --model_type qwen1half-7b-chat --quant_bits 4
34+
3435
# 推理 swift量化产生的模型
3536
CUDA_VISIBLE_DEVICES=0 swift infer --model_type qwen1half-7b-chat --model_id_or_path qwen1half-7b-chat-int4
3637
# 推理 原始模型
@@ -40,7 +41,7 @@ CUDA_VISIBLE_DEVICES=0 swift infer --model_type qwen1half-7b-chat --model_id_or_
4041
```
4142

4243

43-
效果区别:
44+
效果对比:
4445
```python
4546
# swift量化产生的模型
4647
"""
@@ -187,14 +188,14 @@ swift export --ckpt_dir output/qwen1half-4b-chat/vx-xxx/checkpoint-xxx \
187188
swift export --ckpt_dir output/qwen1half-4b-chat/vx-xxx/checkpoint-xxx \
188189
--push_to_hub true \
189190
--hub_model_id qwen1half-4b-chat-lora \
190-
--hub_token '<your-sdk-token>'
191-
--merge_lora true \
191+
--hub_token '<your-sdk-token>' \
192+
--merge_lora true
192193

193194
# 推送量化后模型
194195
swift export --ckpt_dir output/qwen1half-4b-chat/vx-xxx/checkpoint-xxx \
195196
--push_to_hub true \
196197
--hub_model_id qwen1half-4b-chat-lora \
197-
--hub_token '<your-sdk-token>'
198+
--hub_token '<your-sdk-token>' \
198199
--merge_lora true \
199200
--quant_bits 4
200201
```

docs/source/LLM/VLLM推理加速与部署.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ swift使用VLLM作为推理后端, 并兼容openai的API样式.
250250
**服务端:**
251251
```bash
252252
CUDA_VISIBLE_DEVICES=0 swift deploy --model_type qwen-7b-chat
253+
# 多卡部署
254+
RAY_memory_monitor_refresh_ms=0 CUDA_VISIBLE_DEVICES=0,1,2,3 swift deploy --model_type qwen-7b-chat --tensor_parallel_size 4
253255
```
254256

255257
**客户端:**
@@ -353,6 +355,8 @@ response: 杭州有许多美食,例如西湖醋鱼、东坡肉、龙井虾仁
353355
**服务端:**
354356
```bash
355357
CUDA_VISIBLE_DEVICES=0 swift deploy --model_type qwen-7b
358+
# 多卡部署
359+
RAY_memory_monitor_refresh_ms=0 CUDA_VISIBLE_DEVICES=0,1,2,3 swift deploy --model_type qwen-7b --tensor_parallel_size 4
356360
```
357361

358362
**客户端:**

docs/source/LLM/命令行参数.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
## sft 参数
1313

14-
- `--model_type`: 表示你选择的模型类型, 默认是`None`. 可以通过`model_type`来指定对应模型默认的`lora_target_modules`, `template_type`等信息. 你可以通过只指定`model_type`进行微调. 对应的`model_id_or_path`会使用默认的设置, 从ModelScope进行下载, 并使用默认的缓存路径. model_type和model_id_or_path必须指定其中的一个. 可以选择的`model_type`可以查看[支持的模型](支持的模型和数据集.md#模型).
14+
- `--model_type`: 表示你选择的模型类型, 默认是`None`. `model_type`指定了对应模型默认的`lora_target_modules`, `template_type`等信息. 你可以通过只指定`model_type`进行微调. 对应的`model_id_or_path`会使用默认的设置, 从ModelScope进行下载, 并使用默认的缓存路径. model_type和model_id_or_path必须指定其中的一个. 可以选择的`model_type`可以查看[支持的模型](支持的模型和数据集.md#模型).
1515
- `--model_id_or_path`: 表示模型在ModelScope Hub中的`model_id`或者本地路径, 默认为`None`. 如果传入的`model_id_or_path`已经被注册, 则会根据`model_id_or_path`推断出`model_type`. 如果未被注册, 则需要同时指定`model_type`, e.g. `--model_type <model_type> --model_id_or_path <model_id_or_path>`.
1616
- `--model_revision`: 表示模型在ModelScope Hub中对应`model_id`的版本号, 默认为`None`. `model_revision`指定为`None`, 则使用注册在`MODEL_MAPPING`中的revision. 否则强制使用命令行传入的`model_revision`.
1717
- `--sft_type`: 表示微调的方式, 默认是`'lora'`. 你可以选择的值包括: 'lora', 'full', 'longlora', 'qalora'. 如果你要使用qlora, 你需设置`--sft_type lora --quantization_bit 4`.

swift/llm/__init__.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,30 @@
66

77
if TYPE_CHECKING:
88
# Recommend using `xxx_main`
9-
from .app_ui import gradio_chat_demo, gradio_generation_demo, llm_app_ui, app_ui_main
10-
from .deploy import llm_deploy, deploy_main
11-
from .dpo import dpo_main, llm_dpo
12-
from .infer import llm_infer, merge_lora, prepare_model_template, infer_main, merge_lora_main
13-
from .rome import rome_infer, rome_main
14-
from .sft import llm_sft, sft_main
15-
from .export import llm_export, export_main
9+
from .app_ui import gradio_chat_demo, gradio_generation_demo, app_ui_main
10+
from .deploy import deploy_main
11+
from .dpo import dpo_main
12+
from .infer import merge_lora, prepare_model_template, infer_main, merge_lora_main
13+
from .rome import rome_main
14+
from .sft import sft_main
15+
from .export import export_main
1616
else:
1717
_extra_objects = {
1818
k: v
1919
for k, v in globals().items() if not k.startswith('_')
2020
}
2121
_import_structure = {
22-
'app_ui': [
23-
'gradio_chat_demo', 'gradio_generation_demo', 'llm_app_ui',
24-
'app_ui_main'
25-
],
26-
'deploy': ['llm_deploy', 'deploy_main'],
27-
'dpo': ['dpo_main', 'llm_dpo'],
22+
'app_ui':
23+
['gradio_chat_demo', 'gradio_generation_demo', 'app_ui_main'],
24+
'deploy': ['deploy_main'],
25+
'dpo': ['dpo_main'],
2826
'infer': [
29-
'llm_infer', 'merge_lora', 'prepare_model_template', 'infer_main',
27+
'merge_lora', 'prepare_model_template', 'infer_main',
3028
'merge_lora_main'
3129
],
32-
'rome': ['rome_infer', 'rome_main'],
33-
'sft': ['llm_sft', 'sft_main'],
34-
'export': ['llm_export', 'export_main'],
30+
'rome': ['rome_main'],
31+
'sft': ['sft_main'],
32+
'export': ['export_main'],
3533
}
3634

3735
import sys

0 commit comments

Comments
 (0)