Serverless training is currently in private preview and access is gated per account. Request access and select “Serverless Training API.”
What you need
- Install the SDK (same one as the dedicated path, no separate console flow):
pip install "fireworks-ai[training]" - For the runnable example, clone the cookbook:
git clone https://github.com/fw-ai/cookbook && pip install -e ./cookbook/training - Point at the serverless endpoint:
base_url="https://api.fireworks.ai/training/v1/serverless" - Pick a base model enabled for serverless training on your account. See Models below. Availability changes during private preview; verify it before launch.
- Set your API key and run the Quickstart below.
What is serverless training?
You write the training loop, for supervised fine-tuning or reinforcement learning, and Fireworks runs the forward pass, backward pass, and optimizer on remote GPUs, then serves your latest weights for sampling in the same session. The quickstart shows the exact client setup and operation order. The complete implementation lives in the cookbook’sserverless_rl example.
Serverless lifecycle
1 · Local
Builds batches, rewards, and optimizer requests.
2 · Shared
Runs remote LoRA forward, backward, and optimizer work.
3 · In session
Captures the current adapter weights for sampling.
4 · Shared
Returns rollouts for local scoring and the next step.
What you can run
Supervised Fine-Tuning (SFT)
Run the loop with a cross-entropy loss over your labeled data.
Reinforcement Learning (RL)
Sample completions from the current adapter, score them with your own reward function, and train with an importance-sampling loss (GRPO-style). This is the primary serverless use case.
When to use dedicated
Use Dedicated Training when you need full-parameter training, broader model or method support, explicit resource lifecycle control, or sustained utilization. See the canonical serverless versus dedicated comparison.Core concepts
Session.create_lora_training_client(base_model, rank) attaches you to a pooled trainer for that base model. That attachment is your training session (service.training_session_id) — your LoRA state lives there.
Run. The training client is your run (training_client.run_id). One run is one training trajectory: the forward_backward and optim_step calls plus the checkpoints you save.
LoRA adapter. Serverless is LoRA only. Pass a positive rank (e.g. rank=8); base weights stay frozen and shared across the pool, and you train an adapter on top.
Checkpoint / snapshot. save_weights_for_sampler(name) writes your current adapter weights and returns a snapshot path. That path is a public sampler identity, not a raw storage URI — hand it to the sampler to serve exactly those weights. See Saving and loading checkpoints for the full save / resume / promote surface.
Sampling. create_sampling_client(model_path=snapshot, tokenizer=...) returns a sampler bound to that snapshot through the completions API (/inference/v1/completions). For multi-turn rollouts, session-affinity headers pin an episode to one replica so the KV cache is reused across turns (see RL rollout integration). The sampler runs in the same session, so there’s no deployment to create or hot-load.
Quickstart
Step 1: Create a key, install, and authenticate
Create an API key in the Fireworks dashboard (click Create API key and store it somewhere safe), or runfirectl api-key create. Then install the SDK and export the key:
Step 2: Run the complete serverless RL example
The cookbook includes its dataset, reward, loop, metrics, and cleanup behavior:examples/serverless_rl/countdown_rl.py and reduce steps, group_size,
prompt_groups_per_step, and max_sample_tokens before execution.
The remaining snippets explain the core calls used by that runnable example.
Step 3: Connect to the serverless session
ts-, serverless routing is working. If the base URL does not end in /training/v1/serverless, sampling errors out.
Step 4: Train, checkpoint, and sample
The complete example definesdatums, tinker, tokenizer, prompt, and
params, and rejects prompt plus completion lengths above max_seq_len. The
excerpt below shows the operation order:
Reinforcement learning example
The end-to-end serverless RL pattern is the standard GRPO / importance-sampling loop: each step saves the current adapter, rolls out a batch of prompts through a sampler bound to that snapshot, scores completions with your reward function, turns group-relative advantages into training datums, and takes one optimizer step. Track reward over time; improvement depends on the task, data, reward function, and configuration. Use the complete cookbookserverless_rl example rather than rebuilding the loop from this page. For a supervised loop, use cross-entropy loss. For the broader RL loss menu and dedicated provisioning, 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 included during private preview.
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
To fork a new run from a previous run’s training checkpoint, usecreate_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 Each row carries
FireworksClient (against the regular API gateway, not the serverless base URL). The session resource name is available as service.training_session_name: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.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 fine-tuned 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 fine-tuned 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:Pricing
Serverless training is billed per token, across three meters: prefill, sample, and train. Current rates per model are in Models below. Available models, meter definitions, and rates can change during private preview, so verify current availability and pricing before launch.Supported models and limits
Models
Serverless models are not selected by shape. You attach to a shared, always-on trainer pool with a base model and your ownmax_seq_len, and pay only for the tokens you prefill, sample, and train. Serverless is LoRA only, for SFT and RL.
- Checkpoint storage for serverless models is included during private preview.
- The serverless model catalog evolves, and other frontier models are coming soon. For full-parameter training or a model not on that list, use Dedicated Training.
- For per-model availability across all training surfaces, see the Models catalog.
What the meters mean
Serverless training bills three separate token meters, so a run’s cost depends on the mix of rollout and training tokens your loop generates:Capacity and rate limits (private preview)
- Concurrent runs: The default quota is 8, although account overrides may differ. Slots are released when runs become terminal after session expiration.
- 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.
Behavior to know
- Set
max_seq_lenexplicitly. Serverless has no dedicated instance to infer sequence length from. - Cross-run checkpoint resume. A training checkpoint can be resumed inside the same run (
load_state_with_optimizer), or forked into a new run withcreate_training_client_from_state/create_training_client_from_state_with_optimizerusing a fully qualified<account>/<run-id>/<checkpoint-name>reference. See Saving and loading checkpoints. - Serving your trained adapter. Sample in-session during the run. To serve afterward, promote a sampler checkpoint to a model and deploy it on an on-demand dedicated deployment; serverless per-token serving of your own fine-tuned LoRA is not available.
Video walkthrough: Train a prompt router
This walkthrough fine-tunes Qwen 3.5 9B with LoRA SFT to classify prompts and route them to a small or large model. It covers the local Python loop, pooled serverless trainer, in-session evaluation, and the before-and-after comparison.Open the serverless prompt-router notebook
Follow the complete Cookbook example for dataset preparation, LoRA SFT, sampling, and evaluation.
Next steps
- Serverless RL cookbook example: runnable serverless loop
- Choose infrastructure: compare serverless and dedicated
- Dedicated Training: the provisioned path from setup through teardown
- Training and Sampling: dedicated lifecycle internals
- Loss Functions: built-in and custom losses
- The Cookbook: ready-to-run recipes, including
serverless_rl