How it works
1 · Local
Your Python loop
Builds batches, rewards, and optimizer requests.
2 · Shared
Trainer
Runs remote LoRA forward, backward, and optimizer work.
3 · In session
Checkpoint
Captures the current adapter weights for sampling.
4 · Shared
Sampler
Returns rollouts for local scoring and the next step.
What you can run
Supervised fine-tuning (SFT)
Train on labeled examples with a cross-entropy loss.
Reinforcement learning (RL)
Sample, score with your own reward function, and train on the results.
Direct preference optimization (DPO)
Train from pairs of chosen and rejected responses.
Odds ratio preference optimization (ORPO)
Supervised learning and a preference objective in one step.
Distillation
Train a student model from a teacher model’s scores.
Custom loss
Write your own loss function using the same Training API calls as dedicated training.
Quickstart
Requires Python 3.11 or later.Step 1: Create a key, install, and authenticate
Create an API key in the Fireworks dashboard, or runfirectl api-key create in your terminal. Then install the SDK and export the key:
The example below runs from a source checkout. To import released recipes in your own project, use the PyPI installation.
Step 2: Run the complete serverless RL example
The cookbook’s DeepMath example includes its dataset, reward, training loop, and metrics. It trains on math problems with reinforcement learning (RL), using Group Relative Policy Optimization (GRPO). These flags keep the first run small:Step 3: Clean up
The run keeps one of your training slots until you delete its session. Deleting the session also removes access to its checkpoints, so promote any you want to keep first. Then delete the session, using the training session name the example printed (accounts/<ACCOUNT_ID>/trainingSessions/<SESSION_ID>):
Supported models
Serverless supports these base models. For dedicated and managed options, see the Models catalog.Pricing
Serverless training is billed per token, across three meters:- Prefill: prompt tokens the sampler reads. Repeated prefixes bill at the cached rate, 80% off.
- Sample: tokens the sampler generates.
- Train: tokens you train on (passed through
forward_backward).
Nemotron 3.5 Super VL uses the current Tinker 256K card, which includes a limited-time 50% discount.
Write your own training loop
The DeepMath example wraps a loop you can write yourself with the SDK. To use the SDK without the cookbook, install it on its own:Connect to a serverless session
Run this Python script:ts-, your setup works. The session holds a training slot until you delete it.
Train, checkpoint, and sample
Each training step follows the order below. This excerpt doesn’t run on its own: it continues from the code above and usesdatums, tokenizer, prompt, and params, which a complete loop such as the DeepMath example defines.
async_rl_loop_serverless recipe. For other RL losses, see the cookbook RL recipes.
Saving and loading checkpoints
Serverless training writes two different kinds of checkpoint, and they are not interchangeable:
Checkpoint storage is currently included at no charge.
For the full SDK-level checkpoint reference (base/delta sampler types, weight sync, and cross-job resolution), see Dedicated Training and the Cookbook Reference.
Save and resume training checkpoints
Save training checkpoints periodically so an interrupted run can continue:.result() to block and surface failures. save_state also accepts a timeout to bound the wait. Give each checkpoint a distinct name: overwriting an existing name (overwrite=True) is not supported.
To see what checkpoints a run has saved, use the session-scoped control-plane list in Promote a sampler checkpoint to a model below — the trainer-local training_client.list_checkpoints() is not routed on the serverless surface.
Resume a new run from a training checkpoint
Resume a new run from a training checkpoint
To fork a new run from a previous run’s training checkpoint, use Checkpoint references are fully qualified as
create_training_client_from_state on the service client. The SDK reads the base model and LoRA configuration from the checkpoint itself, creates a fresh run, and loads the saved state:<account>/<run-id>/<checkpoint-name>, where run-id is the previous run’s training_client.run_id (run-<hex>). weights_access_token is not supported — load checkpoints accessible to your API key.Promote a sampler checkpoint to a model
Promotion turns a sampler checkpoint into a deployable Fireworks model (a standard LoRA addon model). Training checkpoints are not promotable — save a sampler checkpoint first.1
Save a sampler checkpoint during training
2
List the session's checkpoints
Listing and promotion are session-scoped control-plane operations on
FireworksClient (against the regular API gateway, not the serverless base URL). The session resource name is available as service.training_session_name:About the checkpoint list fields
About the checkpoint list fields
Each row carries
name (the full 4-segment resource name), checkpointName, checkpointType, promotable, and createTime. Two things to know about the values:checkpointNameis the server-side checkpoint ID, not the bare name you passed: it is prefixed with the source run ID and, for sampler checkpoints, suffixed with an 8-hex-char session ID — a save namedfinalsurfaces asrun-<hex>-final-<8hex>. Select rows onpromotable+createTimeas above, or with a prefix/substring test — never by equality with your logical name. The composed ID caps your own name at 17 characters.checkpointTypeis a server enum string:CHECKPOINT_TYPE_TRAINING_LORAfor training checkpoints,CHECKPOINT_TYPE_INFERENCE_LORAfor sampler checkpoints. Treat it as opaque and filter onpromotable, which is authoritative.
3
Promote the checkpoint
output_model_id must be 1-63 characters of lowercase a-z, 0-9, and hyphens. The promoted model appears in your account’s model list like any other trained model.Session-scoped list and promote require the training session and its bound trainer to still exist. Once the session is deleted or its trainer is drained, both calls return
NOT_FOUND and the checkpoints are no longer reachable through this API — promote any checkpoint you want to keep before the session is torn down. Cross-run training-checkpoint resume (above) is resolved per run and is not subject to this limit.Deploy the promoted model to production
A promoted model deploys like any LoRA model trained on Fireworks: with live merge, Fireworks merges the adapter into the base weights at deployment time, so the deployment performs identically to the base model. Deploy the promoted model directly:default, see Deployment shapes.
Then send requests with the model name:
Sampling without a training client
Sample from a checkpoint during or after a run to evaluate it. The sampler is not a chat endpoint for your adapter: to evaluate through the chat completions API, promote the checkpoint and evaluate it on serverless with Specialized Model Inference if its base model is supported, or on a preemptible deployment. Serverless sampling does not work for adapters produced by dedicated training. See Evaluating trained models. Sampling does not needcreate_lora_training_client. A fresh FiretitanServiceClient can sample a base model in the serverless pool, or any sampler checkpoint your account saved with save_weights_for_sampler, including checkpoints from a run that has already ended. These samplers create no training run and do not use a concurrent-run slot, so evaluation workers can open and close them freely. Sampled tokens are billed per token like other serverless training sampling.
Requires SDK version 1.2.29 or later:
pip install --upgrade "fireworks-ai[training]>=1.2.29".Sample a base model
Sample a saved checkpoint
Pass the path thatsave_weights_for_sampler returned, <account>/<run-id>/<checkpoint-name>. The process that saved it can be gone:
- You can only sample checkpoints that belong to your own account. A path for another account fails before any request is sent.
- To keep a checkpoint as a deployable model, promote it.
- On a service that has already created a training client,
create_sampling_client(model_path=...)for that run’s checkpoints, andbase_model=...for the session’s base weights, sample through the training session as before.
Prompt caching for RL rollouts
Prompt caching for RL rollouts
For RL rollouts, pass a stable trajectory ID so repeated prompts reuse the KV cache. This requires SDK 1.2.9 or later: versions 1.2.0 through 1.2.8 replaced per-request session values with one derived from the checkpoint. Upgrade with
pip install --upgrade "fireworks-ai[training]>=1.2.9" and restart the client process. See Inference for RL rollouts and DeploymentSampler RL rollout sampling.Capacity and rate limits
- Concurrent runs: The default is 8 active runs per account, although account overrides may differ. Some pool models also limit active runs per account on that base model, and managed fine-tuning jobs on the same model count toward it. Over either limit, new runs fail with HTTP 429 (
RATE_LIMIT_EXCEEDED) and a message such asmaximum concurrent serverless training runs for base model <MODEL> exceeded: in use 1, limit 1. A run holds its slot until its session is deleted or expires. Sampling without a training client uses no slot. - Free a slot now: Closing the client does not end the session. Promote any checkpoint you need, then delete the session as in Step 3: Clean up.
- Request and token limits: Contact Fireworks for the current limits on your account.
- Shared-pool capacity: if the pool is full,
create_lora_training_clientreturns an out-of-capacity error. Retry, or switch to the dedicated path.
Troubleshooting
Next steps
- DeepMath serverless example: runnable serverless RL loop
- Prompt-router serverless notebook: dataset preparation, LoRA SFT, checkpoint sampling, and evaluation on Qwen 3.8 27B
- Choose infrastructure: compare serverless and dedicated
- Dedicated Training: the provisioned path from setup through teardown
- The Cookbook: ready-to-run recipes
Video walkthrough: Train a prompt router
Video walkthrough: Train a prompt router
This video uses the deprecated Qwen 3.5 9B pool and is kept for conceptual reference. Use Qwen 3.8 27B for current Serverless Training runs, as in the notebook above.The walkthrough trains a model with LoRA SFT to classify prompts and route them to a small or large model. It covers the local Python loop, the pooled serverless trainer, checkpoint evaluation, and the before-and-after comparison.
Glossary
- Session: your attachment to a shared trainer for a base model, created with your training client. Its ID (
service.training_session_id) starts withts-. Your adapter lives in the session, and the session holds a training slot until you delete it. - Run: one training trajectory, with its steps and checkpoints (
training_client.run_id). - LoRA adapter: a small set of weights trained on top of the frozen base model. Serverless trains LoRA only: pass a positive
rank, such asrank=8. - Checkpoint: saved adapter weights.
save_weights_for_sampler(name)returns a path you can sample from or promote. See Saving and loading checkpoints. - Sampling: generating completions from a base model or checkpoint, for rollouts and evaluation. Any process can sample a saved checkpoint. See Sampling without a training client.