Skip to content

Commit 3766407

Browse files
authored
Add FSDP2 example (#6411)
* update faq * Fixed the inconsistencies between the Chinese and English FAQ documentation. * Update link to sequence parallel example * support llava-onevision-1.5 * update model list * update model list * add test * Update test_vision.py * add fsdp2 * modify fsdp2 config
1 parent 4140cfb commit 3766407

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compute_environment": "LOCAL_MACHINE",
3+
"debug": false,
4+
"distributed_type": "FSDP",
5+
"downcast_bf16": "no",
6+
"fsdp_config": {
7+
"fsdp_auto_wrap_policy": "TRANSFORMER_BASED_WRAP",
8+
"fsdp_cpu_ram_efficient_loading": true,
9+
"fsdp_reshard_after_forward": true,
10+
"fsdp_state_dict_type": "FULL_STATE_DICT",
11+
"fsdp_activation_checkpointing": true,
12+
"fsdp_version": 2
13+
},
14+
"machine_rank": 0,
15+
"main_training_function": "main",
16+
"mixed_precision": "bf16",
17+
"num_machines": 1,
18+
"num_processes": 2,
19+
"rdzv_backend": "static",
20+
"same_network": true,
21+
"tpu_env": [],
22+
"tpu_use_cluster": false,
23+
"tpu_use_sudo": false,
24+
"use_cpu": false
25+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# 14.7GiB * 2
2+
nproc_per_node=2
3+
4+
CUDA_VISIBLE_DEVICES=0,1 \
5+
accelerate launch --config_file "./examples/train/multi-gpu/fsdp2_lora/fsdp2.json" \
6+
swift/cli/sft.py \
7+
--model Qwen/Qwen2.5-7B-Instruct \
8+
--train_type lora \
9+
--dataset 'swift/self-cognition#1000' \
10+
--torch_dtype bfloat16 \
11+
--num_train_epochs 1 \
12+
--per_device_train_batch_size 1 \
13+
--per_device_eval_batch_size 1 \
14+
--learning_rate 1e-4 \
15+
--lora_rank 8 \
16+
--lora_alpha 32 \
17+
--gradient_checkpointing false \
18+
--weight_decay 0.1 \
19+
--target_modules all-linear \
20+
--gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
21+
--eval_steps 100 \
22+
--save_steps 100 \
23+
--save_total_limit 2 \
24+
--logging_steps 5 \
25+
--max_length 2048 \
26+
--output_dir output \
27+
--system 'You are a helpful assistant.' \
28+
--warmup_ratio 0.05 \
29+
--dataloader_num_workers 4 \
30+
--model_author swift \
31+
--model_name swift-robot

0 commit comments

Comments
 (0)