baseten.loops.helpers itself exports nothing; import each helper from its submodule, except loops_log_kl_sample_train, which is exported from the top-level package:
list[Datum]
Return a copy of
data with each Datum carrying a new ref_logprobs field in loss_fn_inputs, scored by reference.data(list[Datum]): the preference batch, with each datum holding the full prompt + response sequence inmodel_input. For DPO batches, these are interleaved chosen/rejected pairs.reference(SamplingClient): a version-pinned snapshot of the reference policy, typically returned byTrainingClient.save_weights_and_get_sampling_clientbefore any optimizer steps.
compute_logprobs call. Scoring is sequential.dict[str, Any]
Compute sampler-vs-trainer logprob divergence diagnostics for an RL step and log them to Weights & Biases. Over the action tokens (
mask > 0), it compares the sampler logprobs saved on each Datum against the trainer logprobs from forward_backward, and logs KL estimators (kl_sample_train_v1_loops, kl_sample_train_v2_loops, kl_sample_train_k3), importance-ratio and effective-sample-size stats, a per-token-diff histogram, and a worst-divergent-tokens table under optim/train-sample-div/.wandb_run: a W&B run (anything with.log(metrics, step=...)), orNoneto skip logging; the metrics dict is returned either way.data(list[Datum]): the batch passed toforward_backward, with sampler logprobs attached.- Pass either
forward_backward_output(aForwardBackwardOutput) ortraining_logprobs; passing neither raisesValueError.
loops_compute_kl_sample_train(data, training_logprobs) from baseten.loops.rl_metrics.