Views
No views yet
0.12.21# 基础模型配置
2base_model: Qwen/Qwen3-4B-Instruct-2507
3load_in_8bit: false
4load_in_4bit: false # QLoRA才需要4bit
5
6# LoRA 适配器配置 - 这是关键部分
7adapter: lora # 明确指定使用LoRA
8lora_model_dir: # 如果有预训练的LoRA权重可以在这里指定
9
10# LoRA 具体参数
11lora_r: 64
12lora_alpha: 128
13lora_dropout: 0.1
14lora_target_modules: # Qwen3模型的关键模块
15 - q_proj
16 - k_proj
17 - v_proj
18 - o_proj
19 - gate_proj
20 - up_proj
21 - down_proj
22lora_target_linear: true # 自动找到所有线性层
23lora_fan_in_fan_out: false
24
25# 数据集设置
26chat_template: qwen3
27datasets:
28 - path: /workspace/train_dir_0927-02/goal_data.json
29 type: chat_template
30 roles_to_train: ["assistant"]
31 field_messages: messages
32 message_property_mappings:
33 role: role
34 content: content
35
36dataset_prepared_path:
37val_set_size: 0.1
38output_dir: /workspace/train_dir_0927-02/checkpoints
39
40# 序列长度设置
41sequence_len: 7000
42pad_to_sequence_len: true
43sample_packing: true
44eval_sample_packing: false
45
46# 训练超参数
47num_epochs: 5
48micro_batch_size: 8 # H100显存大
49gradient_accumulation_steps: 2 # 8卡LoRA不需要太大的累积
50eval_batch_size: 8
51
52# 优化器设置
53optimizer: adamw_torch_fused
54lr_scheduler: cosine
55learning_rate: 8e-5
56warmup_ratio: 0.1
57weight_decay: 0.01
58
59# 精度设置
60bf16: true # H100支持bf16
61tf32: true
62gradient_checkpointing: true # 节省显存
63flash_attention: true
64
65# 日志和保存
66logging_steps: 30
67evals_per_epoch: 1
68saves_per_epoch: 1
69save_total_limit: 3 # 只保留最新的3个checkpoint
70
71# 多卡训练配置 - 使用DeepSpeed而不是FSDP
72deepspeed: /workspace/axolotl/deepspeed_configs/zero2.json # 或者直接内联配置
73# 如果要内联DeepSpeed配置:
74# deepspeed:
75# zero_optimization:
76# stage: 2 # Zero-2对LoRA效果很好
77# allgather_partitions: true
78# allgather_bucket_size: 2e8
79# reduce_scatter: true
80# reduce_bucket_size: 2e8
81# overlap_comm: true
82# contiguous_gradients: true
83# bf16:
84# enabled: true
85# gradient_accumulation_steps: 2
86# gradient_clipping: 1.0
87# train_batch_size: auto
88# train_micro_batch_size_per_gpu: auto
89
90# 移除FSDP配置,因为LoRA不需要FSDP
91# fsdp相关配置全部删除
92
93# 其他优化
94ddp_timeout: 3600 # DDP超时设置
95ddp_find_unused_parameters: false # LoRA通常不需要
96
97# 可选:如果不想用DeepSpeed,可以用原生DDP
98# 只需要删除deepspeed配置,Axolotl会自动使用DDP| Training Loss | Epoch | Step | Validation Loss | Mem Active(gib) | Mem Allocated(gib) | Mem Reserved(gib) |
|---|---|---|---|---|---|---|
| No log | 0 | 0 | 1.1065 | 88.14 | 88.14 | 88.77 |
| 0.3209 | 1.0 | 40 | 0.0662 | 114.6 | 114.6 | 115.83 |
| 0.0632 | 2.0 | 80 | 0.0543 | 114.6 | 114.6 | 115.83 |
| 0.0456 | 3.0 | 120 | 0.0501 | 114.6 | 114.6 | 115.83 |
| 0.0416 | 4.0 | 160 | 0.0479 | 114.6 | 114.6 | 115.83 |
| 0.0381 | 5.0 | 200 | 0.0472 | 114.6 | 114.6 | 115.83 |