Training Modes
EngineSurogate EngineSurogate gives you five ways to adapt a model. This page explains each one so you can pick the right starting point:
- Pretraining / Continued Pretraining (PT)
- Full Fine-Tuning
- LoRA / QLoRA (Adapter Fine-Tuning)
- RL Fine-Tuning (GRPO)
- Preference Fine-Tuning (DPO)
They differ in which parameters get updated, how much data you need, and how much compute and VRAM you will spend. If you already know your goal, the table below points you to a mode.
Quick decision guide
Section titled “Quick decision guide”| Goal | Recommended mode |
|---|---|
| Train a base model from scratch on large text | Pretraining |
| Continue training a base model on more text (domain adaptation) | Continued pretraining |
| Maximize quality for a specific task/domain and you can afford it | Full fine-tuning |
| Fast adaptation, smaller GPU, cheaper runs, easy iteration | LoRA |
| Same as LoRA but you’re VRAM-limited | QLoRA |
| Improve reasoning, math, coding via reward-based training | GRPO |
| Compress a larger model into a smaller one from the same family | SFT + Knowledge Distillation |
| Steer behavior from chosen-vs-rejected preference pairs (offline) | DPO |
1) Pretraining / Continued Pretraining (PT)
Section titled “1) Pretraining / Continued Pretraining (PT)”How it works
Section titled “How it works”Pretraining updates all (or nearly all) model weights by predicting the next token on large amounts of raw text.
- What updates? Base model weights (full model training)
- Typical data: Raw text corpora (
type: textdatasets) - Typical run shape: Lots of tokens, long runs, throughput-focused
You usually run PT with:
surogate pt path/to/config.yamlWhen to use it
Section titled “When to use it”- You are training a new base model.
- You want domain adaptation through continued pretraining (for example on legal, medical or finance corpora).
- You care about general capabilities and learning a broad distribution.
Tradeoffs
Section titled “Tradeoffs”- Highest compute cost and longest wall-clock time.
- Needs the most data.
2) Full Fine-Tuning (update all weights)
Section titled “2) Full Fine-Tuning (update all weights)”How it works
Section titled “How it works”Full fine-tuning starts from a pretrained checkpoint and updates every parameter on a task or domain dataset.
- What updates? Base model weights (and optionally embeddings / lm_head depending on your config)
- Typical data: Instruction or conversation datasets
- Typical run shape: Fewer tokens than PT, but still heavy VRAM/compute
You usually run full fine-tuning through the SFT workflow with LoRA turned off:
lora: falseThen run it with surogate sft ....
When to use it
Section titled “When to use it”- You need the best possible performance on a task or domain.
- You can afford the VRAM and compute to update all weights.
- You don’t need to swap adapters across many downstream tasks.
Tradeoffs
Section titled “Tradeoffs”- Costs more and needs more memory than LoRA.
- Harder to maintain several downstream variants, since each run produces a full checkpoint.
3) LoRA / QLoRA (adapter fine-tuning)
Section titled “3) LoRA / QLoRA (adapter fine-tuning)”How LoRA works
Section titled “How LoRA works”LoRA freezes the base model weights and trains small low-rank adapter matrices inserted into selected linear layers.
- What updates? Only LoRA adapter parameters
- Base weights: Frozen (unchanged)
- Typical data: Instruction / conversation / task datasets
Turn on LoRA in your config with (all options under LoRA Settings):
lora: truelora_rank: 16lora_alpha: 32When to use LoRA
Section titled “When to use LoRA”- You want fast, cheap iterations.
- You want several downstream specializations (adapters are small to store, ship and swap).
- You are experimenting and want quick turnarounds.
What is QLoRA?
Section titled “What is QLoRA?”QLoRA is LoRA with the frozen base model weights quantized to save VRAM.
- What updates? LoRA adapters (still)
- Base weights: Frozen and stored in a quantized format (FP8 / FP4 / NF4)
- When to use it: when VRAM is the bottleneck (see the QLoRA guide)
Surogate supports three QLoRA formats:
qlora_fp8(SM89+)qlora_fp4(SM100+ Blackwell)qlora_bnb(NF4 via BitsAndBytes, broad compatibility)
4) RL Fine-Tuning (GRPO)
Section titled “4) RL Fine-Tuning (GRPO)”How it works
Section titled “How it works”GRPO (Group Relative Policy Optimization) is a reinforcement learning method. The model generates rollouts, a reward function scores them, and the policy is updated to favor the higher-reward responses.
- What updates? LoRA adapter parameters (base model is frozen)
- Typical data: Prompts + reward environments (math, code, custom verifiers)
- Typical run shape: Iterative rollout → reward → gradient loop
One command runs all three GRPO components: the inference server, the orchestrator and the trainer. On two or more GPUs, give inference and training their own GPUs:
surogate grpo --train train.yaml --infer infer.yaml --orch orch.yaml \ --infer-gpus 0 --trainer-gpus 1On a single GPU, co-locate them instead (Single-GPU GRPO). They then share one resident copy of the base weights:
surogate grpo-colocate --train train.yaml --infer infer.yaml --orch orch.yamlWhen to use it
Section titled “When to use it”- You want better reasoning, math or coding than SFT gets you.
- You have a reward signal (a verifier, unit tests, reference answers), not only demonstration data.
- You want to optimize for the quality of outcomes instead of imitating a fixed dataset.
Tradeoffs
Section titled “Tradeoffs”- Needs a reward environment (built-in or custom; see RL Environments).
- The pipeline is more complex than SFT (inference server, orchestrator and trainer).
- Training dynamics are less predictable, so you need to watch importance ratios and masking fractions.
5) Preference Fine-Tuning (DPO)
Section titled “5) Preference Fine-Tuning (DPO)”How it works
Section titled “How it works”DPO (Direct Preference Optimization) teaches a model to prefer a chosen response over a rejected one for the same prompt. It works directly on the pairs, with no reward model and no rollouts. It is offline: you supply a static dataset of {prompt, chosen, rejected} triples, and the loss raises the implicit reward of chosen relative to rejected:
margin = β · [ (logπθ − logπref)(chosen) − (logπθ − logπref)(rejected) ]loss = −log σ(margin)- What updates? LoRA adapter parameters (base model is frozen)
- Reference model: the frozen start checkpoint, evaluated inline with LoRA disabled
- Typical data:
type: preferencedatasets ({prompt, chosen, rejected}) - Typical run shape: a few hundred gradient steps over preference pairs
DPO runs from a single config (keys under DPO Settings):
surogate dpo path/to/config.yamlloss: type: dpo dpo_beta: 0.1 length_norm: false # enable when chosen/rejected lengths differ a lot span_mask: false # optionally score only differing token spansdatasets: - path: pairs.jsonl type: preferenceWhen to use it
Section titled “When to use it”- You have paired preferences (chosen vs rejected), not a reward function or plain demonstrations.
- You want to fix a specific behavior with small, targeted contrasts (for example correct vs incorrect word forms) without the cost and instability of RL.
- You want something simpler than GRPO, with no inference server and no orchestrator.
Tradeoffs
Section titled “Tradeoffs”- Needs preference pairs, and the result depends heavily on how you build them.
dpo_betacontrols how hard the policy is pushed away from the reference. Too high overfits; too low barely moves the model.- Offline only: the pairs are fixed, with no on-policy regeneration.
Practical recommendations
Section titled “Practical recommendations”- Start with LoRA (bf16 recipe) unless you have a good reason not to.
- Use QLoRA when you can’t fit the base model + activations comfortably.
- Use Full fine-tuning when you want maximum quality and have budget.
- Use (Continued) pretraining for domain adaptation on large raw text.
- Use GRPO when you have a reward signal and want to go beyond imitation learning.
- Use DPO when you have chosen-vs-rejected preference pairs and want offline preference steering without a reward model.
See also
Section titled “See also”Picked a mode? Each quickstart gets you to a first run in a few minutes:
- Quickstart: Pretraining
- Quickstart: Supervised Fine-Tuning: the usual starting point, with LoRA
- Quickstart: GRPO
- Quickstart: DPO
- Configuration
- Precision & recipes
- QLoRA
- Knowledge Distillation
- Config reference
- Back to docs index