Run settings
Set these when you create the training client withcreate_lora_training_client():
LoRA rank: the width of the adapter’s low-rank matrices. Creating a run above the model’s maximum rank fails with an error that names the limit. With automatic mode selection, a rank serverless doesn’t support uses dedicated capacity. With
scope="serverless", the request fails instead. See Availability modes.Longest sequence the run handles, in tokens. Omit it to use the model’s default. Check the model catalog for maximum sequence lengths and your workspace’s enabled limits.
Optimizer settings
PassAdamParams to optim_step() on every step. The trainer uses Adam:
Apply a learning-rate schedule
The trainer applies the values you pass on each call and has no learning-rate schedule of its own. Compute the rate in your script to warm up and then decay it. In SFT with the SDK, replace the training-loop block with the following code. It uses thetraining_client and tokenized data prepared earlier in that example, derives the step count from the dataset, and prints the rate and loss for each batch:
2e-5 and 4e-5. The remaining six decay to zero. Use your evaluation to choose the peak rate and warmup length.
Batch size is also a choice your loop makes. forward_backward() accumulates gradients until the next optim_step(), so the examples you pass across those calls make up one batch.
Log training metrics to MLflow
Read the batch loss fromforward_backward() and the update metrics from optim_step(). Log them under the same step after the optimizer update completes so you can compare loss and gradient norm across steps.
Install the MLflow Python package with python3 -m pip install mlflow. To send metrics to an existing tracking server, set MLFLOW_TRACKING_URI and configure any credentials the server requires.
In SFT with the SDK, replace the training loop with this block. It uses the same training_client and tokenized data.
loops-sft experiment in your tracking server to view the run. For local tracking, run mlflow ui from the directory where you ran the script and open the URL it prints. The run shows one training_loss point per completed update, plus grad_norm when the trainer returns it.
Loss settings
Choose a loss withloss_fn on forward_backward(), and tune it with loss_fn_config. Loss functions defines each loss’s keys and defaults.
Sampling settings
PassSamplingParams to sample(), with num_samples for the number of completions per prompt:
Sample from the
top_k most likely tokens. Zero or a negative value turns off this filter.Constrain generation to a structure, such as a JSON schema or regular expression. Defaults to
None, which leaves generation unconstrained. See SamplingParams for the accepted format.Settings Loops fixes
- LoRA alpha is fixed at
32, so the adapter’s output is scaled by32 / rank. A higher rank lowers that scale, so retune the learning rate when you change the rank. - LoRA target modules are fixed for each model family.
- Parallelism and hardware are chosen for each model and sequence length.
Next steps
- Loss functions: Look up the keys and defaults for each loss.
- Evaluate a model: Compare runs with different settings on a held-out set.
- Check whether an RL run is learning: Read the metrics that show whether a setting change helped.