LLM Pretraining Pipeline
Pretraining converts a large curated corpus into token sequences, batches them, predicts next tokens, computes loss and updates weights over huge numbers of tokens.
type PretrainingRun = {
tokenizerVersion: string;
datasetVersion: string;
maxSequenceLength: number;
tokensSeen: bigint;
checkpoint: string;
};
Sequence packing
Packing multiple shorter documents/examples into full sequences reduces wasted padding, but document boundaries and loss masking must be handled deliberately.
Scale concerns
Pretraining adds data parallelism, tensor/model parallelism, optimizer-state sharding, mixed precision, checkpointing, fault recovery and cluster networking.
Practice
- Why is sequence packing useful?
- What must be versioned to reproduce a pretraining run?
- Why are total tokens processed more informative than epochs for web-scale corpora?
- What failure recovery state belongs in a distributed checkpoint?