Quickstart: Pretraining (PT)
EngineSurogate EngineThis quickstart runs a pretraining job from a YAML config. Pretraining (PT) teaches a model by next-token prediction on raw text; use it to train a base model from scratch or to continue training one on your own domain. See Training Modes if you are not sure PT is the right mode.
1) Pick an example config
Section titled “1) Pick an example config”You’ll find example configs in examples/pt/.
Start with:
examples/pt/qwen3.yaml
2) Run
Section titled “2) Run”surogate pt examples/pt/qwen3.yamlThe pt command takes the config path as its only required argument. With uv:
uv run surogate pt examples/pt/qwen3.yaml3) Outputs
Section titled “3) Outputs”Checkpoints and logs are written under the config’s output_dir.
4) Recommended Hyperparameters
Section titled “4) Recommended Hyperparameters”Learning Rate
Section titled “Learning Rate”For pretraining from scratch, use a learning rate schedule with warmup and cosine decay:
- Learning rate:
1e-4to5e-4(depending on model size)- Smaller models (< 1B):
3e-4to5e-4 - Medium models (1B-7B):
1e-4to3e-4 - Larger models (> 7B):
1e-4to2e-4
- Smaller models (< 1B):
- Warmup steps: 2000-5000 steps (or 1-5% of total steps)
- Min learning rate:
1e-5(10% of peak LR)
Batch Size
Section titled “Batch Size”Pretraining is more stable with a large global batch:
- Recommended global batch size: 1M-4M tokens
- Small models: 1M-2M tokens
- Medium models: 2M-4M tokens
- Large models: 2M-4M tokens
Work out the per-device batch size from this formula:
global_batch_size = per_device_train_batch_size × gradient_accumulation_steps × num_gpus × sequence_lenSequence Length
Section titled “Sequence Length”- Standard: 2048 or 4096 tokens
- Long context: 8192+ tokens (may require position interpolation)
Weight Decay
Section titled “Weight Decay”- Recommended:
0.1 - Applies to all parameters except biases and layer norms
Gradient Clipping
Section titled “Gradient Clipping”- Recommended:
1.0 - Keeps outlier gradients from destabilizing training
Precision
Section titled “Precision”- BF16 (default): Best accuracy, good speed on Ampere+
- FP8-Hybrid: Faster on Hopper+ (H100, H200), slight accuracy tradeoff
- NVFP4: Maximum speed on Blackwell+ (B200, B300), experimental
ZeRO Configuration
Section titled “ZeRO Configuration”- 1-2 GPUs: ZeRO disabled or ZeRO-1
- 4-8 GPUs: ZeRO-2 (shard optimizer + gradients)
- 8+ GPUs: ZeRO-3 (shard optimizer + gradients + weights)
The Multi-GPU Training guide explains each ZeRO level.
Example Configuration
Section titled “Example Configuration”model: Qwen/Qwen3-0.6Boutput_dir: ./output
# Batch configuration (4M tokens global batch)per_device_train_batch_size: 4gradient_accumulation_steps: 16sequence_len: 2048gpus: 8
# Learning ratelearning_rate: 3e-4lr_scheduler_type: cosinewarmup_steps: 2000min_lr_ratio: 0.1
# Regularizationweight_decay: 0.1max_grad_norm: 1.0
# Precisionrecipe: bf16
# Parallelismzero_level: 2See also
Section titled “See also”- Training modes: Pretraining vs Full Fine-Tuning vs LoRA: how PT compares with the other modes
- Quickstart: SFT: fine-tune the model you pretrained on instructions or conversations
- Configuration: how a config file is put together; every key is in the Configuration Reference
- Back to docs index