1unsloth_lora_mlp: true
2unsloth_lora_qkv: true
3unsloth_lora_o: true
4# This is the huggingface model that contains *.pt, *.safetensors, or *.bin files
5# This can also be a relative path to a model on disk
6base_model: meta-llama/Llama-3.1-8B-Instruct
7
8# Corresponding tokenizer for the model AutoTokenizer is a good choice
9tokenizer_type: AutoTokenizer
10
11# How much of the dataset to set aside as evaluation. 1 = 100%, 0.50 = 50%, etc. 0 for no eval.
12val_set_size: 0.10
13
14
15# Whether you are training a 4-bit GPTQ quantized model
16# gptq: false
17
18# This will attempt to quantize the model down to 8 bits and use adam 8 bit optimizer
19load_in_8bit: false
20# Use bitsandbytes 4 bit
21load_in_4bit: true
22
23# Limit the memory for all available GPUs to this amount (if an integer, expressed in gigabytes); default: unset
24gpu_memory_limit: 24
25# Do the LoRA/PEFT loading on CPU -- this is required if the base model is so large it takes up most or all of the available GPU VRAM, e.g. during a model and LoRA merge
26lora_on_cpu: true
27
28# A list of one or more datasets to finetune the model with
29datasets:
30 - path: ./ts-8k.jsonl
31 type: chat_template
32 chat_template: tokenizer_default
33 field_messages: messages
34 message_field_role: role
35 message_field_content: content
36 roles_to_train: [ "assistant" ]
37
38
39
40# If false, the datasets will not be shuffled and will keep their original order in `datasets`.
41# The same applies to the `test_datasets` option and the `pretraining_dataset` option. Default is true.
42shuffle_merged_datasets: true
43
44
45# The name of the chat template to use for training, following values are supported:
46# - tokenizer_default: Uses the chat template that is available in the tokenizer_config.json. If the chat template is not available in the tokenizer, it will raise an error. This is the default value.
47# - alpaca/inst/chatml/gemma/cohere/llama3/phi_3/deepseek_v2/jamba: These chat templates are available in the axolotl codebase at src/axolotl/utils/chat_templates.py
48# - tokenizer_default_fallback_*: where * is the name of the chat template to fallback to. E.g. tokenizer_default_fallback_chatml. This is useful when the chat template is not available in the tokenizer.
49# - jinja: Uses a custom jinja template for the chat template. The custom jinja template should be provided in the chat_template_jinja field.
50# The selected chat template will be saved to the tokenizer_config.json for easier inferencing
51# Note: It is recommended to set train_on_inputs to true when using a chat template that is different from the model's default chat template.
52chat_template: tokenizer_default
53
54# Axolotl attempts to save the dataset as an arrow after packing the data together so
55# subsequent training attempts load faster, relative path
56dataset_prepared_path: data/last_run_prepared
57# push checkpoints to hub
58#hub_model_id: # private repo path to push finetuned model
59# how to push checkpoints to hub
60# https://huggingface.co/docs/transformers/v4.31.0/en/main_classes/trainer#transformers.TrainingArguments.hub_strategy
61#hub_strategy:
62# Whether to use hf `use_auth_token` for loading datasets. Useful for fetching private datasets
63# Required to be true when used in combination with `push_dataset_to_hub`
64#hf_use_auth_token: # boolean
65
66# Num shards for whole dataset
67#dataset_shard_num:
68# Index of shard to use for whole dataset
69#dataset_shard_idx:
70
71# The maximum length of an input to train with, this should typically be less than 2048
72# as most models have a token/context limit of 2048
73sequence_len: 1024
74# Pad inputs so each step uses constant sized buffers
75# This will reduce memory fragmentation and may prevent OOMs, by re-using memory more efficiently
76pad_to_sequence_len: true
77# Use efficient multi-packing with block diagonal attention and per sequence position_ids. Recommend set to 'true'
78sample_packing: true
79# Set to 'false' if getting errors during eval with sample_packing on.
80eval_sample_packing: false
81# You can set these packing optimizations AFTER starting a training at least once.
82# The trainer will provide recommended values for these values.
83# sample_packing_eff_est:
84# total_num_tokens:
85# Increasing the following values helps with packing, but usually only slightly (<%1.)
86# The number of samples packed at a time.
87# sample_packing_group_size: 100000
88# The number of samples which can be packed into one sequence. Increase if using a large sequence_len with many short samples.
89# sample_packing_bin_size: 200
90# whether to concatenate samples during pretraining
91# pretraining_sample_concatenation:
92
93# Use batch flattening for speedups when not using sample_packing
94# batch_flattening:
95
96# Passed through to transformers when loading the model when launched without accelerate
97# Use `sequential` when training w/ model parallelism to limit memory
98# device_map:
99# Defines the max memory usage per gpu on the system. Passed through to transformers when loading the model.
100# max_memory:
101
102# If you want to use 'lora' or 'qlora' or leave blank to train all parameters in original model
103adapter: qlora
104# If you already have a lora model trained that you want to load, put that here.
105# This means after training, if you want to test the model, you should set this to the value of `output_dir`.
106# Note that if you merge an adapter to the base model, a new subdirectory `merged` will be created under the `output_dir`.
107# lora_model_dir:
108
109# LoRA hyperparameters
110# For more details about the following options, see:
111# https://www.anyscale.com/blog/fine-tuning-llms-lora-or-full-parameter-an-in-depth-analysis-with-llama-2
112lora_r: 8
113lora_alpha: 16
114lora_dropout: 0.05
115lora_target_modules:
116 - q_proj
117 - v_proj
118 - k_proj
119 - o_proj
120 - gate_proj
121 - down_proj
122 - up_proj
123lora_target_linear: # If true, will target all linear modules
124peft_layers_to_transform: # The layer indices to transform, otherwise, apply to all layers
125
126# If you added new tokens to the tokenizer, you may need to save some LoRA modules because they need to know the new tokens.
127# For LLaMA and Mistral, you need to save `embed_tokens` and `lm_head`. It may vary for other models.
128# `embed_tokens` converts tokens to embeddings, and `lm_head` converts embeddings to token probabilities.
129# https://github.com/huggingface/peft/issues/334#issuecomment-1561727994
130#lora_modules_to_save:
131# - embed_tokens
132# - lm_head
133
134#lora_fan_in_fan_out: false
135
136# LoRA+ hyperparameters
137# For more details about the following options, see:
138# https://arxiv.org/abs/2402.12354 and `src/axolotl/core/train_builder.py`
139#loraplus_lr_ratio: # loraplus learning rate ratio lr_B / lr_A. Recommended value is 2^4.
140#loraplus_lr_embedding: # loraplus learning rate for lora embedding layers. Default value is 1e-6.
141
142#peft:
143 # Configuration options for loftq initialization for LoRA
144 # https://huggingface.co/docs/peft/developer_guides/quantization#loftq-initialization
145# loftq_config:
146# loftq_bits: 4 # typically 4 bits
147
148# ReLoRA configuration
149# Must use either 'lora' or 'qlora' adapter, and does not support fsdp or deepspeed
150#relora_steps: # Number of steps per ReLoRA restart
151#relora_warmup_steps: # Number of per-restart warmup steps
152#relora_anneal_steps: # Number of anneal steps for each relora cycle
153#relora_prune_ratio: # threshold for optimizer magnitude when pruning
154#relora_cpu_offload: # True to perform lora weight merges on cpu during restarts, for modest gpu memory savings
155
156# wandb configuration if you're using it
157# Make sure your `WANDB_API_KEY` environment variable is set (recommended) or you login to wandb with `wandb login`.
158# wandb_mode: # "offline" to save run metadata locally and not sync to the server, "disabled" to turn off wandb
159wandb_project: # Your wandb project name
160wandb_entity: # A wandb Team name if using a Team
161wandb_watch:
162wandb_name: vast-finetune-r1 # Set the name of your wandb run
163wandb_run_id: # Set the ID of your wandb run
164wandb_log_model: checkpoint # "checkpoint" to log model to wandb Artifacts every `save_steps` or "end" to log only at the end of training
165
166wandb_entity: blueanode
167wandb_project: fabricator
168
169# mlflow configuration if you're using it
170#mlflow_tracking_uri: # URI to mlflow
171#mlflow_experiment_name: # Your experiment name
172#mlflow_run_name: # Your run name
173#hf_mlflow_log_artifacts: # set to true to copy each saved checkpoint on each save to mlflow artifact registry
174
175
176
177# Where to save the full-finetuned model to
178output_dir: ./vast-finetune-r1
179
180# Whether to use torch.compile and which backend to use
181# setting to `auto` will enable torch compile when torch>=2.5.1
182torch_compile: # Optional[Union[Literal["auto"], bool]]
183torch_compile_backend: # Optional[str]
184
185# Training hyperparameters
186
187# If greater than 1, backpropagation will be skipped and the gradients will be accumulated for the given number of steps.
188gradient_accumulation_steps: 1
189# The number of samples to include in each batch. This is the number of samples sent to each GPU.
190# Batch size per gpu = micro_batch_size * gradient_accumulation_steps
191micro_batch_size: 2
192eval_batch_size:
193num_epochs: 8
194warmup_steps: 100 # cannot use with warmup_ratio
195learning_rate: 0.00003
196lr_quadratic_warmup:
197logging_steps:
198eval_steps: # Leave empty to eval at each epoch, integers for every N steps. decimal for fraction of total steps
199evals_per_epoch: 4 # number of times per epoch to run evals, mutually exclusive with eval_steps
200save_strategy: # Set to `"no"` to skip checkpoint saves
201save_steps: # Leave empty to save at each epoch
202# saves_per_epoch: # number of times per epoch to save a checkpoint, mutually exclusive with save_steps
203save_total_limit: 2 # Checkpoints saved at a time
204# Maximum number of iterations to train for. It precedes num_epochs which means that
205# if both are set, num_epochs will not be guaranteed.
206# e.g., when 1 epoch is 1000 steps => `num_epochs: 2` and `max_steps: 100` will train for 100 steps
207# max_steps:
208
209eval_table_size: 8 # Approximate number of predictions sent to wandb depending on batch size. Enabled above 0. Default is 0
210eval_max_new_tokens: 256 # Total number of tokens generated for predictions sent to wandb. Default is 128
211#eval_causal_lm_metrics: # HF evaluate metrics used during evaluation. Default is ["sacrebleu", "comet", "ter", "chrf", "perplexity"]
212
213profiler_steps: # enable the pytorch profiler to capture the first N steps of training to the output_dir.
214 # see https://pytorch.org/blog/understanding-gpu-memory-1/ for more information
215 # snapshots can be visualized @ https://pytorch.org/memory_viz
216
217#loss_watchdog_threshold: # High loss value, indicating the learning has broken down (a good estimate is ~2 times the loss at the start of training)
218#loss_watchdog_patience: # Number of high-loss steps in a row before the trainer aborts (default: 3)
219
220# Save model as safetensors (require safetensors package)
221# save_safetensors:
222
223# Whether to mask out or include the human's prompt from the training labels
224train_on_inputs: false
225#train_on_inputs: false
226#group_by_length: false
227bf16: auto
228fp16:
229tf32: false
230# Group similarly sized data to minimize padding.
231# May be slower to start, as it must download and sort the entire dataset.
232# Note that training loss may have an oscillating pattern with this enabled.
233group_by_length: false
234
235# Whether to use gradient checkpointing https://huggingface.co/docs/transformers/v4.18.0/en/performance#gradient-checkpointing
236gradient_checkpointing: false
237# additional kwargs to pass to the trainer for gradient checkpointing
238# gradient_checkpointing_kwargs:
239# use_reentrant: true
240
241# Stop training after this many evaluation losses have increased in a row
242# https://huggingface.co/transformers/v4.2.2/_modules/transformers/trainer_callback.html#EarlyStoppingCallback
243# early_stopping_patience: 3
244
245# Specify a scheduler and kwargs to use with the optimizer
246#lr_scheduler: # 'one_cycle' | 'log_sweep' | empty for cosine
247lr_scheduler_kwargs:
248cosine_min_lr_ratio: # decay lr to some percentage of the peak lr, e.g. cosine_min_lr_ratio=0.1 for 10% of peak lr
249cosine_constant_lr_ratio: # freeze lr at some percentage of the step, e.g. cosine_constant_lr_ratio=0.8 means start cosine_min_lr at 80% of training step (https://arxiv.org/pdf/2308.04014.pdf)
250
251# For one_cycle optim
252lr_div_factor: # Learning rate div factor
253
254# Specify optimizer
255# Valid values are driven by the Transformers OptimizerNames class, see:
256# https://github.com/huggingface/transformers/blob/95b374952dc27d8511541d6f5a4e22c9ec11fb24/src/transformers/training_args.py#L134
257#
258# Note that not all optimizers may be available in your environment, ex: 'adamw_anyprecision' is part of
259# torchdistx, 'adamw_bnb_8bit' is part of bnb.optim.Adam8bit, etc. When in doubt, it is recommended to start with the optimizer used
260# in the examples/ for your model and fine-tuning use case.
261#
262# Valid values for 'optimizer' include:
263# - adamw_hf
264# - adamw_torch
265# - adamw_torch_fused
266# - adamw_torch_xla
267# - adamw_apex_fused
268# - adopt_adamw (an EXPERIMENTAL optimizer, only for torch version >= 2.5.1)
269# - adafactor
270# - adamw_anyprecision
271# - sgd
272# - adagrad
273# - adamw_bnb_8bit
274# - lion_8bit
275# - lion_32bit
276# - paged_adamw_32bit
277# - paged_adamw_8bit
278# - paged_lion_32bit
279# - paged_lion_8bit
280# - galore_adamw
281# - galore_adamw_8bit
282# - galore_adafactor
283# - galore_adamw_layerwise
284# - galore_adamw_8bit_layerwise
285# - galore_adafactor_layerwise
286optimizer: paged_adamw_32bit
287lr_scheduler: cosine
288# Dictionary of arguments to pass to the optimizer
289optim_args:
290# For Galore Optimizers the following optim_args are available
291# rank: # type: int
292# update_proj_gap # type: int
293# scale # type: float
294# proj_type: # type: str, default = std
295
296# The target modules to optimize, i.e. the module names that you would like to train, right now this is used only for GaLore algorithm
297optim_target_modules:
298# - self_attn # for llama
299# - mlp
300
301# Specify weight decay
302weight_decay:
303# adamw hyperparams
304adam_beta1:
305adam_beta2:
306adam_epsilon:
307# Gradient clipping max norm
308max_grad_norm:
309
310# Augmentation techniques
311# NEFT https://arxiv.org/abs/2310.05914, set this to a number (paper default is 5) to add noise to embeddings
312# currently only supported on Llama and Mistral
313neftune_noise_alpha:
314
315# Whether to bettertransformers
316flash_optimum:
317# Whether to use xformers attention patch https://github.com/facebookresearch/xformers:
318xformers_attention:
319# Whether to use flash attention patch https://github.com/Dao-AILab/flash-attention:
320flash_attention:
321flash_attn_cross_entropy: # Whether to use flash-attention cross entropy implementation - advanced use only
322flash_attn_rms_norm: # Whether to use flash-attention rms norm implementation - advanced use only
323flash_attn_fuse_qkv: # Whether to fuse QKV into a single operation
324flash_attn_fuse_mlp: # Whether to fuse part of the MLP into a single operation
325# Whether to use scaled-dot-product attention
326# https://pytorch.org/docs/stable/generated/torch.nn.functional.scaled_dot_product_attention.html
327sdp_attention:
328# Shifted-sparse attention (only llama) - https://arxiv.org/pdf/2309.12307.pdf
329s2_attention:
330# Resume from a specific checkpoint dir
331resume_from_checkpoint:
332# If resume_from_checkpoint isn't set and you simply want it to start where it left off.
333# Be careful with this being turned on between different models.
334auto_resume_from_checkpoints: true
335
336# Don't mess with this, it's here for accelerate and torchrun
337local_rank:
338
339# Add or change special tokens.
340# If you add tokens here, you don't need to add them to the `tokens` list.
341special_tokens:
342 # bos_token: "<s>"
343 # eos_token: "</s>"
344 # unk_token: "<unk>"
345 pad_token: "<|end_of_text|>"
346
347# Add extra tokens.
348tokens:
349
350# FSDP
351fsdp:
352fsdp_config:
353
354# Deepspeed config path. e.g., deepspeed_configs/zero3.json
355deepspeed:
356
357# Advanced DDP Arguments
358ddp_timeout:
359ddp_bucket_cap_mb:
360ddp_broadcast_buffers:
361
362# Path to torch distx for optim 'adamw_anyprecision'
363torchdistx_path:
364
365# Set to HF dataset for type: 'completion' for streaming instead of pre-tokenize
366pretraining_dataset:
367
368# Debug mode
369debug:
370
371# Seed
372seed:
373
374# Allow overwrite yml config using from cli
375strict:
376