1# axolotl train config.yml --deepspeed deepspeed_configs/zero2.json
2
3# Resume from checkpoint configuration
4# resume_from_checkpoint: ./outputs/checkpoint-650
5
6# Prevent NCCL timeout
7ddp_timeout: 7200 # 2 hours timeout instead of 10 minutes
8
9# Load model from local models directory first, fallback to HuggingFace if not found
10base_model: AiForgeMaster/Qwen3-4B-P3-GK-SFT-3 # Local path - will fallback to Qwen/Qwen3-4B if not found locally
11# Automatically upload checkpoint and final model to HF
12hub_model_id: AiForgeMaster/Qwen3-4B-P3-SFT-4
13
14load_in_8bit: false
15load_in_4bit: false
16strict: false
17
18# SFT dataset configuration - using HuggingFace datasets
19datasets:
20 - path: AiForgeMaster/SFT_01_19_08_2025 # Private HF dataset - requires API key
21 type: chat_template
22 split: train
23 field_messages: messages
24 trust_remote_code: false
25 # skip: 0 # number of rows of data to skip over from the beginning
26
27# Local paths relative to working directory
28dataset_prepared_path: ./data/prepared
29val_set_size: 0.0 # Set to 0 for SFT (no validation split)
30output_dir: ./outputs
31
32# Cache directories for HuggingFace downloads (relative to working dir)
33# This ensures models and datasets are downloaded to local directories
34hf_use_auth_token: true # Use HF token for private repos if needed
35
36sequence_len: 8192
37sample_packing: false # Standard for SFT
38eval_sample_packing: false # Disable for SFT
39
40# WandB configuration - fill in your details
41wandb_project: ngpt-cpt
42wandb_entity: null
43wandb_watch: gradients
44wandb_name: qwen3_4b_pretraining_v9_P3_SFT-4
45wandb_log_model: end
46
47# Batch size configuration (total effective batch size = micro_batch_size * gradient_accumulation_steps * num_gpus)
48# For batch size 8-16: micro_batch_size=2, gradient_accumulation_steps=4 gives effective batch size of 8 per GPU
49gradient_accumulation_steps: 3
50micro_batch_size: 6 # Adjust based on your GPU memory
51optimizer: adamw_torch_fused
52lr_scheduler: cosine
53learning_rate: 1.5e-4 # Good learning rate for SFT
54
55bf16: auto
56tf32: true
57
58max_grad_norm: 1.0
59
60gradient_checkpointing: true
61gradient_checkpointing_kwargs:
62 use_reentrant: false
63logging_steps: 10 # Log every 10 steps
64flash_attention: true
65
66warmup_steps: 100 # Good warmup for SFT
67# Checkpoint saving configuration - save every 50 steps
68save_steps: 50
69save_strategy: steps
70save_total_limit: 5 # Keep only 5 most recent checkpoints
71save_only_model: false # Save full checkpoint including optimizer state
72
73# Evaluation configuration removed for pure SFT (val_set_size: 0.0)
74# eval_steps: 2000 # Not supported when val_set_size == 0
75# eval_strategy: steps # Not supported when val_set_size == 0
76weight_decay: 0.01 # Good weight decay for SFT
77
78# Liger optimizations for memory efficiency and speed
79plugins:
80 - axolotl.integrations.liger.LigerPlugin
81
82liger_rope: true
83liger_rms_norm: true
84liger_glu_activation: true
85liger_layer_norm: true
86liger_fused_linear_cross_entropy: true
87
88# Additional SFT optimizations
89# Enable for first run to validate checkpoint saving works
90save_first_step: false
91
92# Memory optimizations
93dataloader_pin_memory: true
94dataloader_num_workers: 4
95remove_unused_columns: true
96
97# Advanced training settings for SFT
98# Calculate max_steps for full epoch: dataset_size / (micro_batch_size * gradient_accumulation_steps * num_gpus)
99# max_steps: 175 # Set for one full epoch with your dataset size
100num_epochs: 1
101group_by_length: true # Good for SFT efficiency
102train_on_inputs: false # Don't train on user inputs in SFT
103
104# Loss monitoring
105loss_watchdog_threshold: 10.0 # Stop if loss exceeds this value
106loss_watchdog_patience: 3
107
108# Garbage collection to manage memory
109gc_steps: 100 # Run garbage collection every 100 steps