1# =========================
2# Axolotl SFT config (Gemma3 4B PT, full finetune, bf16, grad ckpt)
3# =========================
4
5# ---- Model ----
6base_model: google/gemma-3-4b-pt
7model_type: AutoModelForCausalLM
8tokenizer_type: AutoTokenizer
9
10# Train only text generation (language model) layers
11unfrozen_parameters:
12 - "model.language_model.*"
13
14trust_remote_code: true
15strict: false
16
17# Quantization OFF (full finetune)
18load_in_8bit: false
19load_in_4bit: false
20
21# ---- Chat formatting ----
22chat_template: gemma3
23
24# ---- Dataset ----
25# Option A: your dataset is already ShareGPT-style (list of turns with roles)
26datasets:
27 - path: RLHFlow/RLHFlow-SFT-Dataset-ver2
28 type: chat_template
29 field_messages: conversations
30 roles_to_train: ["assistant"]
31 split: train
32 train_on_split: train
33
34
35val_set_size: 0.01
36train_on_inputs: false # only learn on assistant tokens
37
38# ---- Tokenization / packing ----
39sequence_len: 8192 # <- start with 4096; later you can go 8192 once stable
40sample_packing: true
41pad_to_sequence_len: true
42
43# Cache the prepared dataset (put on $WORK on Jean Zay)
44dataset_prepared_path: ./prepared/gemma3-4b-8192
45dataset_processes: 32
46dataloader_pin_memory: true
47dataloader_num_workers: 8
48dataloader_prefetch_factor: 2
49
50# ---- Output / logging ----
51output_dir: ./outputs/gemma3-4b-sft
52save_safetensors: true
53
54logging_steps: 10
55save_strategy: "epoch"
56saves_per_epoch: 2
57save_total_limit: 10
58
59# Optional W&B
60wandb_project: gemma3-sft
61wandb_name: gemma3-4b-pt_seq8192_lr1.5e-5_bs128
62wandb_watch:
63wandb_log_model:
64
65# ---- Precision / speed ----
66bf16: true
67fp16: false
68tf32: true
69
70flash_attention: true
71xformers_attention:
72
73# ---- Training hyperparams ----
74num_epochs: 3 # start with 1 epoch to validate end-to-end; then increase
75micro_batch_size: 1
76gradient_accumulation_steps: 16
77auto_resume_from_checkpoints: True
78
79optimizer: adamw_torch_fused # simplest baseline (no bitsandbytes dependency surprises)
80lr_scheduler: cosine
81learning_rate: 1.5e-5 # good starting point for 12B full finetune
82warmup_ratio: 0.05
83
84weight_decay: 0.0
85max_grad_norm: 1.0
86
87group_by_length: false
88
89# ---- Memory knobs ----
90gradient_checkpointing: true
91gradient_checkpointing_kwargs:
92 use_reentrant: false
93overrides_of_model_config:
94 use_cache: false
95
96
97# ---- Distributed ----
98# When you launch with torchrun, Axolotl will use DDP.
99# Keep these empty so you do NOT enable ZeRO/FSDP.
100ddp:
101deepspeed:
102fsdp:
103fsdp_config:
104
105
106# ---- Debug ----
107debug:
108