Skip to content
SurogateSurogateDocs
↑↓ to move↵ to openesc to close

Training Modes

Surogate gives you five ways to adapt a model. This page explains each one so you can pick the right starting point:

  1. Pretraining / Continued Pretraining (PT)
  2. Full Fine-Tuning
  3. LoRA / QLoRA (Adapter Fine-Tuning)
  4. RL Fine-Tuning (GRPO)
  5. 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.


GoalRecommended mode
Train a base model from scratch on large textPretraining
Continue training a base model on more text (domain adaptation)Continued pretraining
Maximize quality for a specific task/domain and you can afford itFull fine-tuning
Fast adaptation, smaller GPU, cheaper runs, easy iterationLoRA
Same as LoRA but you’re VRAM-limitedQLoRA
Improve reasoning, math, coding via reward-based trainingGRPO
Compress a larger model into a smaller one from the same familySFT + Knowledge Distillation
Steer behavior from chosen-vs-rejected preference pairs (offline)DPO

1) Pretraining / Continued Pretraining (PT)

Section titled “1) Pretraining / Continued Pretraining (PT)”

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: text datasets)
  • Typical run shape: Lots of tokens, long runs, throughput-focused

You usually run PT with:

bash
surogate pt path/to/config.yaml
  • 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.
  • Highest compute cost and longest wall-clock time.
  • Needs the most data.

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:

yaml
lora: false

Then run it with surogate sft ....

  • 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.
  • Costs more and needs more memory than LoRA.
  • Harder to maintain several downstream variants, since each run produces a full checkpoint.

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):

yaml
lora: true
lora_rank: 16
lora_alpha: 32
  • 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.

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)

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:

bash
surogate grpo --train train.yaml --infer infer.yaml --orch orch.yaml \
--infer-gpus 0 --trainer-gpus 1

On a single GPU, co-locate them instead (Single-GPU GRPO). They then share one resident copy of the base weights:

bash
surogate grpo-colocate --train train.yaml --infer infer.yaml --orch orch.yaml
  • 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.
  • 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.

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: preference datasets ({prompt, chosen, rejected})
  • Typical run shape: a few hundred gradient steps over preference pairs

DPO runs from a single config (keys under DPO Settings):

bash
surogate dpo path/to/config.yaml
yaml
loss:
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 spans
datasets:
- path: pairs.jsonl
type: preference
  • 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.
  • Needs preference pairs, and the result depends heavily on how you build them.
  • dpo_beta controls 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.

  • 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.

Picked a mode? Each quickstart gets you to a first run in a few minutes: