Skip to content

Commit 585f6a1

Browse files
authored
llm support multimodal (#32)
1 parent 9240897 commit 585f6a1

File tree

21 files changed

+343
-39
lines changed

21 files changed

+343
-39
lines changed

examples/pytorch/llm/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
## Features
1818
1. supported sft method: [lora](https://arxiv.org/abs/2106.09685), [qlora](https://arxiv.org/abs/2305.14314), full(full parameter fine tuning), ...
19-
2. supported models: [**qwen-7b**](https://github.com/QwenLM/Qwen-7B), qwen-7b-chat, baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, polylm-13b
19+
2. supported models: [**qwen-7b**](https://github.com/QwenLM/Qwen-7B), qwen-7b-chat, qwen-vl, **qwen-vl-chat**, baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, polylm-13b
2020
3. supported feature: quantization, ddp, model parallelism(device map), gradient checkpoint, gradient accumulation steps, push to modelscope hub, custom datasets, ...
21-
4. supported datasets: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh
21+
4. supported datasets: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh, coco-en
2222
5. supported templates: chatml(qwen), baichuan, chatglm2, llama, openbuddy_llama, default
2323

2424
## Prepare the Environment

examples/pytorch/llm/README_CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
## 特性
1919
1. [lora](https://arxiv.org/abs/2106.09685), [qlora](https://arxiv.org/abs/2305.14314), 全参数微调, ...
20-
2. 支持的模型: [**qwen-7b**](https://github.com/QwenLM/Qwen-7B), qwen-7b-chat, baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, polylm-13b
20+
2. 支持的模型: [**qwen-7b**](https://github.com/QwenLM/Qwen-7B), qwen-7b-chat, qwen-vl, **qwen-vl-chat**, baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, polylm-13b
2121
3. 支持的特性: 模型量化, DDP, 模型并行(device_map), gradient checkpoint, 梯度累加, 支持推送modelscope hub, 支持自定义数据集, ...
22-
4. 支持的数据集: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh
22+
4. 支持的数据集: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh, coco-en
2323
5. 支持的template: chatml(qwen), baichuan, chatglm2, llama, openbuddy_llama, default
2424

2525
## 准备实验环境

examples/pytorch/llm/scripts/qwen_7b/qlora_ddp/sft.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ torchrun \
1818
--quantization_bit 4 \
1919
--bnb_4bit_comp_dtype bf16 \
2020
--lora_rank 64 \
21-
--lora_alpha 32 \
21+
--lora_alpha 16 \
2222
--lora_dropout_p 0.05 \
2323
--lora_target_modules ALL \
2424
--batch_size 1 \

examples/pytorch/llm/scripts/qwen_7b_chat/qlora/sft.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ python src/llm_sft.py \
1313
--quantization_bit 4 \
1414
--bnb_4bit_comp_dtype bf16 \
1515
--lora_rank 64 \
16-
--lora_alpha 32 \
16+
--lora_alpha 16 \
1717
--lora_dropout_p 0.05 \
1818
--lora_target_modules ALL \
1919
--batch_size 1 \

examples/pytorch/llm/scripts/qwen_7b_chat/qlora_ddp/sft.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ torchrun \
1818
--quantization_bit 4 \
1919
--bnb_4bit_comp_dtype bf16 \
2020
--lora_rank 64 \
21-
--lora_alpha 32 \
21+
--lora_alpha 16 \
2222
--lora_dropout_p 0.05 \
2323
--lora_target_modules ALL \
2424
--batch_size 1 \
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 10G
2+
CUDA_VISIBLE_DEVICES=0 \
3+
python src/llm_infer.py \
4+
--model_type qwen-vl \
5+
--sft_type lora \
6+
--template_type chatml \
7+
--dtype bf16 \
8+
--ckpt_dir "runs/qwen-vl/vx_xxx/checkpoint-xxx" \
9+
--eval_human false \
10+
--dataset coco-en \
11+
--dataset_sample 20000 \
12+
--quantization_bit 4 \
13+
--bnb_4bit_comp_dtype bf16 \
14+
--max_new_tokens 1024 \
15+
--temperature 0.9 \
16+
--top_k 50 \
17+
--top_p 0.9 \
18+
--do_sample true \
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# 4 * 16GB VRAM
2+
nproc_per_node=4
3+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
4+
torchrun \
5+
--nproc_per_node=$nproc_per_node \
6+
--master_port 29500 \
7+
src/llm_sft.py \
8+
--model_type qwen-vl \
9+
--sft_type lora \
10+
--template_type chatml \
11+
--dtype bf16 \
12+
--output_dir runs \
13+
--ddp_backend nccl \
14+
--dataset coco-en \
15+
--dataset_sample 20000 \
16+
--num_train_epochs 1 \
17+
--max_length 1024 \
18+
--quantization_bit 4 \
19+
--bnb_4bit_comp_dtype bf16 \
20+
--lora_rank 64 \
21+
--lora_alpha 16 \
22+
--lora_dropout_p 0.05 \
23+
--lora_target_modules ALL \
24+
--batch_size 1 \
25+
--weight_decay 0. \
26+
--learning_rate 1e-4 \
27+
--gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
28+
--max_grad_norm 0.5 \
29+
--warmup_ratio 0.03 \
30+
--eval_steps 50 \
31+
--save_steps 50 \
32+
--save_total_limit 2 \
33+
--logging_steps 10 \
34+
--use_flash_attn false \
35+
--push_to_hub false \
36+
--hub_model_id qwen-vl-qlora \
37+
--hub_private_repo true \
38+
--hub_token 'your-sdk-token' \
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# 19G
2+
CUDA_VISIBLE_DEVICES=0 \
3+
python src/llm_infer.py \
4+
--model_type qwen-vl-chat \
5+
--sft_type lora \
6+
--template_type chatml \
7+
--dtype bf16 \
8+
--ckpt_dir "runs/qwen-vl-chat/vx_xxx/checkpoint-xxx" \
9+
--eval_human false \
10+
--dataset coco-en \
11+
--dataset_sample 20000 \
12+
--max_new_tokens 1024 \
13+
--temperature 0.9 \
14+
--top_k 50 \
15+
--top_p 0.9 \
16+
--do_sample true \
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# 4 * 23GB VRAM
2+
nproc_per_node=4
3+
CUDA_VISIBLE_DEVICES=0,1,2,3 \
4+
torchrun \
5+
--nproc_per_node=$nproc_per_node \
6+
--master_port 29500 \
7+
src/llm_sft.py \
8+
--model_type qwen-vl-chat \
9+
--sft_type lora \
10+
--template_type chatml \
11+
--dtype bf16 \
12+
--output_dir runs \
13+
--ddp_backend nccl \
14+
--dataset coco-en \
15+
--dataset_sample 20000 \
16+
--num_train_epochs 1 \
17+
--max_length 1024 \
18+
--lora_rank 8 \
19+
--lora_alpha 32 \
20+
--lora_dropout_p 0.05 \
21+
--batch_size 1 \
22+
--weight_decay 0. \
23+
--learning_rate 1e-4 \
24+
--gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
25+
--max_grad_norm 0.5 \
26+
--warmup_ratio 0.03 \
27+
--eval_steps 50 \
28+
--save_steps 50 \
29+
--save_total_limit 2 \
30+
--logging_steps 10 \
31+
--use_flash_attn false \
32+
--push_to_hub false \
33+
--hub_model_id qwen-vl-chat-lora \
34+
--hub_private_repo true \
35+
--hub_token 'your-sdk-token' \
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 10G
2+
CUDA_VISIBLE_DEVICES=0 \
3+
python src/llm_infer.py \
4+
--model_type qwen-vl-chat \
5+
--sft_type lora \
6+
--template_type chatml \
7+
--dtype bf16 \
8+
--ckpt_dir "runs/qwen-vl-chat/vx_xxx/checkpoint-xxx" \
9+
--eval_human false \
10+
--dataset coco-en \
11+
--dataset_sample 20000 \
12+
--quantization_bit 4 \
13+
--bnb_4bit_comp_dtype bf16 \
14+
--max_new_tokens 1024 \
15+
--temperature 0.9 \
16+
--top_k 50 \
17+
--top_p 0.9 \
18+
--do_sample true \

0 commit comments

Comments
 (0)