# Configuration

Source: https://docs.surogate.ai/engine/guides/configuration/

Every Surogate run is described by one YAML config file: the model, the data, how to train and where to write the results. You pass the file to a command such as `surogate sft`, and anything you leave out takes its default. This page shows what a config looks like; the [config reference](/engine/reference/config/) lists every option.

## Start from an example

The quickest start is to copy an example and edit it:

- SFT examples live in `examples/sft/`
- Pretraining examples live in `examples/pt/`
- Knowledge-distillation examples live in `examples/distillation/`

Run it with the [CLI](/engine/reference/cli/):

```bash
surogate sft path/to/config.yaml
# or
surogate pt path/to/config.yaml
```

To distill a larger teacher into the student during SFT, add a `distillation:` block and run `surogate distill-capture` before `surogate sft`. See [Knowledge Distillation](/engine/guides/distillation/).

## Anatomy of a config file

This is `examples/sft/qwen3/qwen3-lora-bf16.yaml`, a LoRA fine-tune of a small Qwen3 model, with comments on what each group of keys does:

```yaml
# Model and output: what to train and where checkpoints go
model: Qwen/Qwen3-0.6B
output_dir: ./outputs/sft/qwen3/qwen3-lora-bf16
resume_from_checkpoint: false

# Batch size: effective batch = per_device_train_batch_size × gradient_accumulation_steps × gpus
per_device_train_batch_size: 2
gradient_accumulation_steps: 4

# Sequences: pack several samples into each sequence_len-token window
sample_packing: true
sequence_len: 2048

# Training length and evaluation interval (in optimizer steps)
max_steps: 100
eval_steps: 25

# Optimizer and schedule
learning_rate: 2e-4
warmup_ratio: 0.15

# Precision recipe; train_vision: false trains on text only
recipe: bf16
train_vision: false

# LoRA adapters: which layers get one, and their size
lora: true
lora_rank: 16
lora_alpha: 32
lora_dropout: 0
lora_target_modules:
  - q_proj
  - k_proj
  - v_proj
  - o_proj
  - gate_proj
  - up_proj
  - down_proj

# Data: where it comes from and in which format
dataloader_num_workers: 4
datasets:
  - path: "OpenLLM-Ro/ro_gsm8k"
    type: auto
```

Each group maps to a section of the config reference:

- `model`, `output_dir` and checkpointing: [General Settings](/engine/reference/config/#general-settings) and [Model Settings](/engine/reference/config/#model-settings)
- batch size, steps and evaluation: [Training Loop Settings](/engine/reference/config/#training-loop-settings)
- `learning_rate` and the schedule: [Optimizer Settings](/engine/reference/config/#optimizer-settings), explained in [Optimizers](/engine/guides/optimizers/)
- `recipe`: [Precision & Recipes](/engine/guides/precision-and-recipes/)
- `lora` and its options: [LoRA Settings](/engine/reference/config/#lora-settings)
- `datasets` and packing: [Dataset Settings](/engine/reference/config/#dataset-settings), explained in [Datasets](/engine/guides/datasets/)

Other features add their own keys on top: `gpus` and `zero_level` for [multi-GPU training](/engine/guides/multi-gpu/), a `distributed:` block for [multi-node training](/engine/guides/multi-node/), `qlora_*` keys for [QLoRA](/engine/guides/qlora/).

## What to edit first

For most runs you'll edit:
- `model`
- `output_dir`
- `datasets`
- `per_device_train_batch_size`, `gradient_accumulation_steps`, `sequence_len`
- `learning_rate`
- (optional) `lora`, `lora_rank` / QLoRA options

If the run doesn't fit in GPU memory, [Memory](/engine/guides/memory/) lists what to change, in order.

## See also

- [Config reference](/engine/reference/config/): every option, its type and default
- [Datasets](/engine/guides/datasets/): the dataset formats and how to configure each
- [Knowledge Distillation](/engine/guides/distillation/): train a student from a larger teacher
- [Back to docs index](/engine/)
