> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Loops

> Use LoRA for supervised fine-tuning and reinforcement learning at long sequence lengths, then deploy checkpoints to the Baseten Inference Stack.

Loops is a training SDK for LoRA fine-tuning and post-training large language models at long sequence lengths. You write a Python training loop that calls a dedicated trainer and sampler for a [supported base model](/loops/supported-models). Each forward pass, optimizer step, and sampling call goes through the API.

Loops updates LoRA adapters while keeping the base model parameters frozen, for both supervised fine-tuning and reinforcement learning. Use [Training Jobs](/training/overview) for full-parameter fine-tuning or a custom training framework.

## How Loops works

A Loops session pairs a trainer with a sampler. The trainer runs forward, backward, and optimizer steps. The sampler generates output from published adapter weights. Because they scale independently, reinforcement learning (RL) rollouts don't compete with training for compute.

In synchronous RL, your loop waits for the sampler to load the published adapter weights before collecting the next rollouts. Asynchronous RL overlaps training with sampling. Your algorithm controls the allowed lag between their policy versions. This coordination is separate from the SDK's [`*_async` methods](/reference/sdk/loops/training-client), which let you use the SDK with a Python event loop. Both RL workflows train LoRA adapters.

Use [Get checkpoint source](/reference/loops-api/checkpoints/get-checkpoint-source) to determine whether to download checkpoint files through presigned URLs or pull them from a volume. You can also deploy checkpoints to the Baseten Inference Stack through the dashboard, CLI, or API.

## Where to go next

The [Loops quickstart](/loops/quickstart) runs the full session lifecycle: train a step, sample from the tuned weights, list the checkpoint, and shut the trainer and sampler down.

To train and evaluate models from your application, follow [Programmatic training](/loops/programmatic-training). The example saves results and checkpoints for each round.

The [Loops concepts](/loops/concepts) page explains sessions, trainers, samplers, checkpoints, and weight synchronization.

Use [Training Jobs](/training/overview) when you need to bring your own container and training code. [Training on Baseten](/training) compares Loops and Training Jobs.

To migrate an existing Tinker project, see [Migrate from Tinker](/loops/tinker-compatibility).

## Reference

* [CLI reference](/reference/cli/baseten/loops): Manage Loops runs, checkpoints, and GPU usage.
* [SDK reference](/reference/sdk/loops/overview): Train, sample, and manage sessions from Python.
* [API reference](/reference/loops-api/overview): Manage Loops resources over HTTP.
