Skip to content

Checkpoints and Resume

Sudhanshu Shukla edited this page Nov 23, 2026 · 3 revisions

Checkpoints and Resume

Checkpoint operations are implemented in train_utils.py.

What gets saved

For a single-process run, the project writes last.pt containing:

step           optimizer update number
model          model.state_dict()
optimizer      optimizer.state_dict()
config         model architecture settings

It also writes a training_manifest.json at successful end of a stage. The checkpoint is updated at save intervals, so the saved step must be inspected, not assumed from its folder name.

For the separate FSDP2 path, the implementation uses distributed checkpoint directories with a trainer.json step marker.

Inspect the latest checkpoint

python -c "import torch; p=torch.load('checkpoints/healthcare_medical_sft_2000/last.pt', map_location='cpu', weights_only=True); print('Saved step:',p.get('step')); print('Fields:',list(p))"

Resume an interrupted SFT run

python -m scripts.finetune_medical `
  --strategy single `
  --device cuda `
  --config configs/healthcare_moe_single.json `
  --tokenizer artifacts/healthcare_tokenizer.json `
  --resume checkpoints/healthcare_medical_sft_2000/last.pt `
  --source hf `
  --dataset FreedomIntelligence/medical-o1-reasoning-SFT `
  --dataset-config en `
  --hf-split train `
  --schema question_response `
  --num-workers 0 `
  --seq-len 128 `
  --batch-size 1 `
  --grad-accum 4 `
  --steps 2000 `
  --lr 0.00002 `
  --warmup-steps 100 `
  --eval-every 200 `
  --save-every 500 `
  --out checkpoints/healthcare_medical_sft_2000

The script interprets --steps as the total target step, and resumes its loop at the saved optimizer step. For example, a checkpoint saved at step 1,500 will continue toward 2,000 rather than performing another 2,000 updates.

Resume limitations

  • Model architecture and tokenizer must remain compatible with the saved checkpoint.
  • Streaming dataset cursor position is not checkpointed; resumed training may revisit samples.
  • A first SFT run must use --pretrained (model initialization); a continuation must use --resume (optimizer and step state).
  • A successful load does not prove that model quality is acceptable; inspect validation results and data provenance separately.

Clone this wiki locally