Skip to content

Commit b662dfd

Browse files
BirdylxLokeZhou
andauthored
[NPU] Add llava npu doc (PaddlePaddle#694)
Co-authored-by: LokeZhou <aishenghuoaiqq@163.com>
1 parent 240ccb5 commit b662dfd

File tree

4 files changed

+67
-30
lines changed

4 files changed

+67
-30
lines changed

paddlemix/examples/README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ paddlemix `examples` 目录下提供模型的一站式体验,包括模型推
44

55
## 模型能力矩阵
66

7-
| Model | Inference |Pretrain | SFT | LoRA | Deploy |
8-
| --- | --- | --- | --- | --- | --- |
9-
| [qwen_vl](./qwen_vl/) ||||||
10-
| [blip2](./blip2/) ||||||
11-
| [clip](./clip) ||||||
12-
| [coca](./coca/) ||||||
13-
| [eva02](./eva02/)||||||
14-
| [evaclip](./evaclip/) ||||||
15-
| [groundingdino](./groundingdino/) ||| 🚧 |||
16-
| [imagebind](./imagebind/) ||||||
17-
| [minigpt4](./minigpt4) ||||||
18-
| [sam](./sam/) ||||||
19-
| [visualglm](./visualglm/) ||||||
20-
| [llava](./llava/) ||||| 🚧 |
21-
| [YOLO-World](./YOLO-World/) ||||||
22-
| [CogVLM && CogAgent](./cogvlm/) ||||||
23-
| [InternLM-XComposer2](./internlm_xcomposer2/) ||||||
7+
| Model | Inference |Pretrain | SFT | LoRA | Deploy | NPU training |
8+
| --- | --- | --- | --- | --- | --- | --- |
9+
| [qwen_vl](./qwen_vl/) |||||||
10+
| [blip2](./blip2/) |||||||
11+
| [clip](./clip) |||||||
12+
| [coca](./coca/) |||||||
13+
| [eva02](./eva02/)|||||||
14+
| [evaclip](./evaclip/) |||||||
15+
| [groundingdino](./groundingdino/) ||| 🚧 ||||
16+
| [imagebind](./imagebind/) |||||||
17+
| [minigpt4](./minigpt4) |||||||
18+
| [sam](./sam/) |||||||
19+
| [visualglm](./visualglm/) |||||||
20+
| [llava](./llava/) ||||| 🚧 ||
21+
| [YOLO-World](./YOLO-World/) |||||||
22+
| [CogVLM && CogAgent](./cogvlm/) |||||||
23+
| [InternLM-XComposer2](./internlm_xcomposer2/) |||||||
2424

2525

2626
* ✅: Supported

paddlemix/tools/README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ PaddleMIX工具箱秉承了飞桨套件一站式体验、性能极致、生态
44
[[English](README_en.md)]
55

66
## 🛠️ 支持模型列表 🛠️
7-
| Model | Inference |Pretrain | SFT | LoRA | Deploy |
8-
| --- | --- | --- | --- | --- | --- |
9-
| [qwen_vl](../examples/qwen_vl/) ||||||
10-
| [blip2](../examples/blip2/) ||||||
11-
| [visualglm](../examples/visualglm/) ||||||
12-
| [llava](../examples/llava/) ||||| 🚧 |
7+
| Model | Inference |Pretrain | SFT | LoRA | Deploy | NPU training |
8+
| --- | --- | --- | --- | --- | --- | --- |
9+
| [qwen_vl](../examples/qwen_vl/) |||||||
10+
| [blip2](../examples/blip2/) |||||||
11+
| [visualglm](../examples/visualglm/) |||||||
12+
| [llava](../examples/llava/) ||||| 🚧 ||
1313

1414
* ✅: Supported
1515
* 🚧: In Progress
@@ -74,6 +74,8 @@ PaddleMIX 精调支持多个主流跨模态大模型的SFT、LoRA等精调策略
7474
7575
“mixtoken” : #是否使用mixtoken策略,默认False,
7676
77+
"device": #训练硬件,npu、gpu
78+
7779
"output_dir": #模型存储路径
7880
7981
"overwrite_output_dir": # 覆盖输出目录,默认False
@@ -188,3 +190,17 @@ python paddlemix/tools/merge_lora_params.py \
188190
--lora_path output_qwen_vl\
189191
--merge_model_path qwen_vl_merge
190192
```
193+
194+
**NPU硬件训练**
195+
196+
PaddleMIX支持在NPU硬件上训练,只需要在config配置文件中增加`device`字段制定设备即可:
197+
```json
198+
{
199+
...
200+
"model_name_or_path": "paddlemix/llava/llava-v1.5-7b",
201+
"device": "npu",
202+
"output_dir": "./checkpoints/llava_sft_ckpts",
203+
...
204+
}
205+
```
206+
目前支持NPU训练的模型可以参考此[文档](../examples/README.md)

paddlemix/tools/README_en.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ The PaddleMIX toolkit embodies the design philosophy of one-stop experience, ult
44
[[中文文档](README.md)]
55

66
## 🛠️ Supported Model List 🛠️
7-
| Model | Inference |Pretrain | SFT | LoRA | Deploy |
8-
| --- | --- | --- | --- | --- | --- |
9-
| [qwen_vl](../examples/qwen_vl/) ||||||
10-
| [blip2](../examples/blip2/) ||||||
11-
| [visualglm](../examples/visualglm/) ||||||
12-
| [llava](../examples/llava/) ||||| 🚧 |
7+
| Model | Inference |Pretrain | SFT | LoRA | Deploy | NPU training |
8+
| --- | --- | --- | --- | --- | --- | --- |
9+
| [qwen_vl](../examples/qwen_vl/) |||||||
10+
| [blip2](../examples/blip2/) |||||||
11+
| [visualglm](../examples/visualglm/) |||||||
12+
| [llava](../examples/llava/) ||||| 🚧 ||
1313

1414
* ✅: Supported
1515
* 🚧: In Progress
@@ -70,6 +70,8 @@ For convenience in testing, we also provide a dataset in the chatml_dataset form
7070
7171
“mixtoken” : #是否使用mixtoken策略,默认False,
7272
73+
"device": #训练硬件,gpu、npu
74+
7375
"output_dir": #模型存储路径
7476
7577
"overwrite_output_dir": # 覆盖输出目录,默认False
@@ -177,3 +179,17 @@ python paddlemix/tools/merge_lora_params.py \
177179
--lora_path output_qwen_vl\
178180
--merge_model_path qwen_vl_merge
179181
```
182+
183+
**NPU training**
184+
185+
PaddleMIX supports training on NPU device,you cat add the `device` field in the configuration file to specify the device:
186+
```json
187+
{
188+
...
189+
"model_name_or_path": "paddlemix/llava/llava-v1.5-7b",
190+
"device": "npu",
191+
"output_dir": "./checkpoints/llava_sft_ckpts",
192+
...
193+
}
194+
```
195+
For models that support NPU training, please refer to this [doc](../examples/README.md)

paddlemix/tools/supervised_finetune.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,16 @@ def main():
6262
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
6363
)
6464

65+
if "npu" in training_args.device:
66+
is_bfloat16_supported = True
67+
else:
68+
is_bfloat16_supported = paddle.amp.is_bfloat16_supported():
69+
6570
# Load model
6671
if training_args.fp16_opt_level == "O2":
6772
if training_args.fp16:
6873
dtype = "float16"
69-
elif training_args.bf16 and paddle.amp.is_bfloat16_supported():
74+
elif training_args.bf16 and is_bfloat16_supported:
7075
dtype = "bfloat16"
7176
else:
7277
raise ValueError("Please specific dtype: --fp16 or --bf16")

0 commit comments

Comments
 (0)