页面简介
The Fireworks Training API lets you write custom Python training loops with full control over objectives while Fireworks manages distributed GPU infrastructure.
正文摘录
Serverless and Dedicated Training are both self-serve. Start with Serverless Training, and move to Dedicated Training for larger workloads, more model selection, or full-parameter training. The Dedicated Training trainer uses your account’s training GPU quota. Using a coding agent? Install the Fireworks training skill to help configure, run, and troubleshoot training jobs using current Fireworks best practices. What is the Training API? Fireworks Training API lets you write training logic in plain Python on your local machine while model computation runs on remote GPUs managed by Fireworks. Most users should start from Cookbook recipes, the recommended entry point for standard SFT, DPO, GRPO-style training, and experimental async RL loops for agentic RL. Recipes use the Python SDK and can be run directly or through your agent. Use the Python SDK directly when you need full control over Training API behavior. Already have a Tinker loop? See Migrate from Tinker for SDK setup, type conversion, sampling, checkpoints, and compatibility differences. Starting pointBest forHow you use itCookbook recipeAdapting a working SFT, DPO, GRPO-style, or experimental async RL loopRun it with the Python SDK directly or through your agentPython SDKFull control over training behaviorWrite the training flow in Python while Fireworks runs GPUs Choose infrastructure After choosing the Training API, decide how compute is provided: Serverless Training: shared pooled trainer for LoRA SFT, DPO, ORPO, RL, distillation, and custom loops on supported models, with no provisioning and per-token billing. Dedicated Training: provisioned trainer and deployment resources, broader model and parameter-mode support, explicit checkpoint/resume/deployment control. Serverless TrainingAttach to a shared pooled trainer. There is no trainer or rollout deployment to provision.Dedicated TrainingProvision trainer and deployment resources for your run, with broader model and parameter-mode support. Quick decision The model is supported, LoRA covers the task, and you want pooled compute with per-token billing.You need full-parameter training, a model outside the serverless pool, explicit resume or deployment control, or sustained provisioned compute. Comparison DimensionServerlessDedicatedProvisioningShared pooled trainer; no trainer or sampler deployment creationSDK provisions trainer and deployment resourcesBillingPer token; no idle GPU chargeTime-based trainer and deployment billingParameter modeLoRA onlyLoRA and full-parameterMethodsSFT, DPO, ORPO, RL, distillation, and custom loopsSFT, DPO, ORPO, RL, distillation, and custom loopsModelsCurrent serverless model listModels with an enabled dedicated training shapeCapacityShared pool and per-account limitsResources allocated to the run, subject to account quota and platform availabilityCheckpoint resumeIn-run snapshots; cross-run resume is limitedExplicit checkpoint, reconnect, promotion, and deployment lifecycleSamplingSampler on the shared pool, no deployment to create; no training client neededSDK-managed rollout or evaluation deploymentTeardownSession lifecycle is managed by the serviceYou must close trainers and delete or scale down deploymentsBest fitLoRA workloads on supported models without provisioningFull-parameter work, models outside the serverless pool, sustained workloads, and explicit lifecycle control Always verify current models, limits, prices, and feature status in the Serverless Training and Dedicated Training pages before launch. Who does what Fireworks handlesCookbook recipes handlePython SDK users implementGPU provisioning and cluster managementTraining loop structure for supported recipesTraining loop logic (forward_backward_custom + optim_step)Service-mode trainer lifecycle (create, health-check, reconnect, delete)Resource setup, health checks, reconnect, and cleanupManaged service setup with FiretitanServiceClient.from_firetitan_config(...)Distributed forward pass, backward pass, optimizer executionCommon losses and reward/evaluation plumbingLoss function and batch constructionCheckpoint storage and exportCheckpoint save, resume, promotion, and sampler refreshCheckpoint calls (save_weights_for_sampler, DCP snapshots)Inference deployments and weight syncDeployment sampling and serving-integrated evaluation for RL recipesCustom rollout, sampling, and evaluation logic through the managed servicePreemption recovery and job resumeResume logic for supported recipe checkpointsResume policy and state restoration callsDistributed training (multi-node, sharding, FSDP)Config surfaces for learning rate, grad accumulation, context length, W&BHyperparameter schedules, data pipeline, and experiment tracking System architecture 1 · Your laptopLoads data, builds batches, computes rewards, and controls the experiment.2 · Fireworks APIAuthenticates requests, routes operations, and manages the selected infrastructure.3 · Remote computeRuns forward passes, backward passes, and optimizer steps.4 · Separate computeServes saved weights for rollouts and evaluation outside the trainer.5 · Persistent outputStores sampler snapshots and resumable training state for later use. Your Python process stays on your laptop throughout the run. It sends model operations to Fireworks and receives metrics or completions back. Sampling uses separate inference infrastructure rather than the trainer itself. How service-mode training works Most common gotchas Remote operations such as forward, forward_backward, optim_step, sampling, and checkpoint saves return future-like results. Call .result() on operations that return one. token_weights=0 means prompt/no-loss tokens, token_weights=1 means response/learned tokens. forward_backward_custom computes gradients only; you still need optim_step to apply updates. Minimal training step lifecycle The shape of the loop is the same on both infrastructures. Toggle between them to see what changes at each stage: Datums A Datum is the unit of training data sent to the remote GPU. It wraps tokenized input and per-token weights that your loss function needs. For SFT, token weight 0.0 marks prompt tokens and 1.0 marks response tokens. Cookbook renderers construct these weights from chat messages. Logprobs and forward_backward_custom When you call forward_backward_custom, the GPU runs a forward pass and returns per-token log-probabilities as PyTorch tensors with requires_grad=True. Your loss function computes a scalar loss, the API calls loss.backward(), and gradients are sent back to the GPU for the model backward pass. After accumulating gradients, call optim_step to apply the update. See the Dedicated Training Quickstart for one complete runnable Datum, loss, and optimizer loop. Futures Remote training operations such as forward, forward_backward, optim_step, and checkpoint saves return future-like results. Call .result() on operations that return one so failures surface. Checkpointing and weight sync After training, you export checkpoints for serving: Base snapshot: a complete chain anchor for the trainable state. For LoRA this is the adapter; for full-parameter training it is model weights. Delta snapshot: a change relative to a prior full-parameter base snapshot. The SDK selects base versus delta automatically unless the recipe overrides it. Checkpoint-to-sampler behavior depends on the infrastructure: Serverless: save a snapshot and bind a sampling client to that snapshot, from the training process or any other. There is no deployment weight sync. See Serverless Training. Dedicated: save a snapshot and refresh an SDK-managed deployment sampler, which syncs weights onto the deployment. See Dedicated Training and Sampling. For dedicated RL rollouts that continue across weight sync, see KV cache behavior for RL rollouts. Dedicated RL rollout transition mode When a dedicated RL recipe provisions a hot-load rollout deployment, you can set hot_load_transition_type to ASYNC or SYNC in the SDK provisioning config or the cookbook rollout deployment config. Leave it unset to keep the recommended ASYNC default; set SYNC when a rollout must not span a weight transition. For the tradeoffs and KV-cache behavior, see Async transition (recommended, default for RL). Key APIs APIPurposeFiretitanServiceClientRecommended direct SDK entry point. Creates or reattaches trainers/deployments and returns training, reference, and sampling clients.FiretitanTrainingClientTinker-compatible training client: forward_backward_custom, optim_step, save_weights_for_sampler, save_state, and load methods.DeploymentSamplerFireTitan-native sampler for tokenized rollout/evaluation from SDK-managed deployments.FireworksClientStandalone checkpoint operations such as listing checkpoints or promoting a model without a live training instance.TrainerJobManagerLegacy/compatibility lifecycle manager. Documented for existing SDK users and advanced debugging; not the recommended user-facing path.DeploymentManagerLegacy/compatibility deployment manager. Documented for existing SDK users and advanced debugging; normal code uses FiretitanServiceClient. Renderers Chat-template formatting, stop-token handling, and loss-weight masking for SFT/DPO datasets are handled by renderers — pluggable per-model classes that turn raw conversations into the trainer’s Datum shape. Most users never touch a renderer directly; cookbook recipes pick the right one for the base_model you set. If you need to author a new one or debug parity against HuggingFace, use the canonical training skill’s renderer implementation reference and verification reference. Comparing Training API pricing vs DIY bare metal When comparing a managed training platform with a self-managed bare-metal stack, optimize for cost per successful iteration, not just headline $ / GPU-hour. What to compare Time to first deployed model: include environment setup, training orchestration, checkpoint handoff, and serving integration. Iteration cycle time (train -> eval -> deploy -> repeat): includ