Overview
Supervised fine-tuning trains on labeled token sequences. Your code builds each typed JSON batch and submits Whitney primitives in order.Prerequisites
GET /v1/training/capabilities— confirm the model advertisesforward_backward,optim_step,save_state, andexport_lora.- Create a session and LoRA run (see Quickstart).
Training loop
For each step: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:
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_statepersists resume state, including the optimizer when requested.export_loraproduces 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:Resume
Resume is provider-bound and model-bound. Create a new session and run, then either bind the checkpoint at run creation or executeload_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.