Skip to main content

Overview

Supervised fine-tuning trains on labeled token sequences. Your code builds each typed JSON batch and submits Whitney primitives in order.

Prerequisites

  1. GET /v1/training/capabilities — confirm the model advertises forward_backward, optim_step, save_state, and export_lora.
  2. Create a session and LoRA run (see Quickstart).

Training loop

For each step:
Build a ForwardPayload with your token batches, dense loss-input tensors, and loss configuration. This is the whole computation — right-shift the sequence by one position, and only weight the completion span:
The real implementation — sft_datum() in whitney_datums.py — is a stdlib port of tinker_cookbook’s create_rightshifted_model_input_and_leftshifted_targets. sl_loop.py is a complete, runnable loop over this: it reads a batch from --forward-backward-json, submits forward_backward/optim_step in order, and finishes. Submit forward_backward and optim_step as ordered run operations. Poll each operation to a terminal state before advancing seq_id.

Checkpoints

After training:
  • save_state persists resume state, including the optimizer when requested.
  • export_lora produces a portable LoRA adapter artifact.

Optional sampling

Omit sampling for artifact-only SFT so Modal does not provision a separate sampler GPU. If you need generations during SFT:
Sampling never synchronizes newer trainer weights implicitly. Always sync the weight version you intend to read.

Resume

Resume is provider-bound and model-bound. Create a new session and run, then either bind the checkpoint at run creation or execute load_state as the first ordered operation — not both for the same run.

Cleanup

On failure: cancel the run, poll until terminal, then close the session.