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: 64
13lora_dropout: 0.05
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/tool_data_with_prompt.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.05
38output_dir: checkpoints
39
40# 序列长度设置
41sequence_len: 10000
42pad_to_sequence_len: false
43sample_packing: false
44eval_sample_packing: false
45group_by_length: true # 启用长度分组,提高效率
46
47# 训练超参数
48num_epochs: 3
49micro_batch_size: 1 # H100显存大
50gradient_accumulation_steps: 8 # 8卡LoRA不需要太大的累积
51eval_batch_size: 8
52
53# 优化器设置
54optimizer: adamw_torch_fused
55lr_scheduler: cosine_with_restarts
56cosine_restarts: 2 # 每个epoch重启一次
57learning_rate: 4e-5
58warmup_ratio: 0.03
59weight_decay: 0.05
60
61# 精度设置
62bf16: auto # H100支持bf16
63tf32: true
64gradient_checkpointing: true # 节省显存
65flash_attention: true
66
67# 日志和保存
68logging_steps: 30
69evals_per_epoch: 1
70saves_per_epoch: 1
71save_total_limit: 3 # 只保留最新的3个checkpoint
72
73# 多卡训练配置 - 使用DeepSpeed而不是FSDP
74deepspeed: zero2.json # 或者直接内联配置
75
76# 其他优化
77ddp_timeout: 3600 # DDP超时设置
78ddp_find_unused_parameters: false # LoRA通常不需要| Training Loss | Epoch | Step | Validation Loss | Mem Active(gib) | Mem Allocated(gib) | Mem Reserved(gib) |
|---|---|---|---|---|---|---|
| No log | 0 | 0 | 1.1699 | 123.25 | 123.25 | 124.05 |
| 0.0449 | 1.0 | 877 | 0.0458 | 123.28 | 123.28 | 124.61 |
| 0.04 | 2.0 | 1754 | 0.0436 | 123.28 | 123.28 | 124.61 |