Training parameters reference
Every training setting, its default, and how the "auto" defaults are chosen. You rarely need to set any of them.
Every recipe works with only model= and a dataset. Anything you leave out takes the default below, and grad train --dry-run (or client.runs.plan(...)) prints the value each setting resolved to before you spend anything. To pin every resolved value, export a run's config with grad runs inspect <run_id> --yaml and check it into Git.
Names are the same in every SDK, with each language's own casing: max_cost_usd is maxCostUsd in TypeScript, MaxCostUSD in Go and --max-cost-usd in the CLI.
Common run parameters#
These apply to every recipe and to client.runs.create(...).
| Parameter | Default | What it does |
|---|---|---|
model | "qwen/qwen3-8b"; "qwen/qwen3-0.6b" for RouterRecipe; "qwen/qwen3-4b" for DistillRecipe; chosen by the recipe for DecisionModelRecipe and EmbeddingRecipe | Base model ID, or an Artifact from SFTRecipe or DPORecipe to keep training its LoRA adapter (rank and alpha are inherited; merged exports can't be continued). Router, decision, cartridge, embedding, distillation and reward-model runs start from a base model. The dry run names the model it resolved. See Supported models. |
dataset | required | A Dataset from client.datasets.push(name, records_or_path), client.datasets.from_hf(...) or an import with client.datasets.import_file(...). |
name | required | Output name. Artifacts are versioned under it (name@<date>-<n>). |
max_cost_usd | none | Spend cap. When it's reached, the run stops gracefully, saves a checkpoint and ends with status stopped_budget. Raise it and continue with client.runs.resume(run_id, max_cost_usd=...). |
split | splits.BySession(eval_fraction=0.10); 0.15 for routers and decision models; splits.ByGroup for DPO and reward models | Holds out sessions for evaluation. Records with the same session_id (or preference pairs with the same group_id) stay on the same side. splits.Random(...) holds out single records. Every split takes seed= (default 42). |
idempotency_key | a fresh UUID per call | Pass your own to make a rerun of your script return the run the first call created instead of starting another (TypeScript { idempotencyKey }, Go RunParams.IdempotencyKey, Rust runs().create(&req, Some(key)), CLI --idempotency-key). |
Two more settings every recipe takes:
evals: up to four extra evals scored on every checkpoint during training: datasets (a benchmark fromclient.datasets.from_benchmark(...)brings its answer check) orEvalSpec(dataset, rubric=..., limit=..., name=...)with judges, regexes and validators. The plan pins each dataset version and rubric and estimates the cost per checkpoint; each eval is billed like any eval and isn't capped bymax_cost_usd. Results are inrun.checkpoint_evalsand the finaleval_report. A checkpoint the inference endpoint can't serve gets a failed entry; the run continues. Gradiated Cloud doesn't serve checkpoints, so there a recipe withevalsanswers422 checkpoint_evals_unsupported_on_cloud: evaluaterun.artifactafter training.loggers: up to four experiment trackers that receive the run's metrics:loggers.WandB(project, secret="wandb-key", entity=..., host=..., run_name=...)orloggers.MLflow(tracking_uri, experiment=..., secret=..., run_name=...). Keys live in workspace secrets (grad secrets set wandb-key); MLflow'ssecretis an optional bearer token. For an MLflow or W&B server of your own, store the key with its host (--allowed-host). A tracker that fails is dropped and reported in the worker log; it never fails or slows the run. The dry run warns about a secret it can't find.
In the CLI, both go in a run file for grad train -f, as lists under evals: (dataset, rubric, limit, name) and loggers: (kind: wandb or kind: mlflow plus the fields above).
Live metrics from run.metrics(follow=True) include step, loss, grad_norm, lr, tokens_per_sec, running tokens and cost_usd, and on eval steps eval_loss and eval_metrics (held-out metrics by name; None between evals).
Optimization#
| Parameter | Default | What it does |
|---|---|---|
lr | "auto" | Looked up per base model and recipe, then scaled for your batch size. See How "auto" values resolve. Pass a float to override. |
lr_scale | 1.0 | Multiplies the resolved lr. Sweep 0.5, 1.0 and 2.0 to tune without picking raw numbers. |
adapter | adapters.LoRA(rank=32) | alpha stays at 32 by default, so changing rank doesn't change the right learning rate. Ranks 8–16 are enough for datasets under about 5,000 records; use 64–128 for SFT on more than about 50,000. |
optimizer | optim.AdamW(lr="auto", betas=(0.9, 0.95), weight_decay=0.0, grad_clip=1.0) | Standard settings for LoRA. AdamW is the only optimizer; grad_clip=0 disables clipping. |
schedule, warmup | "linear", 0.03 | Linear decay to zero after a 3% warmup. schedule also takes "cosine" or "constant"; warmup is a fraction of steps up to 0.5. |
batch_size | 128 examples (SFT records, DPO pairs, router and decision records, embedding triplets); a quarter of the training examples (at least 8) when that's smaller, except for embedding | Examples per optimizer step. |
epochs | 1 | Passes over the data (1–20). The dry run warns when a run has fewer than 100 optimizer steps and suggests a smaller batch. |
loss | set per recipe (see each recipe below) |
Data and chat templates#
| Parameter | Default | What it does |
|---|---|---|
train_on | "last" for chat records | Trains only the final assistant turn. "all_assistant" trains every assistant turn, for multi-turn agent traces. Tool outputs and user turns are never trained. |
"train" on a message | unset | "train": true or false on a single message overrides train_on for that message. |
thinking | "auto" | "auto" keeps the base model's thinking mode, and records with no <think> block train with thinking off. Also takes "on" or "off" (True and False map to them). A target that contradicts the setting fails the dry run with its record ID. There are no effort levels: Qwen3 chat templates only switch thinking on or off. |
preserve_thinking | False | Whether earlier assistant turns keep their reasoning in the prompt. Set True for agents that rely on reasoning from previous turns. |
reduction (SFT) | "per_example" | Averages the loss within each example and then across the batch, so long examples don't drown out short ones. "per_token" weights every trained token equally. |
session_id (record field) | one per record | Groups records from the same conversation for the train/eval split. |
Preview the exact tokens and which ones are trained with grad render <dataset> --model <model> or client.datasets.render(dataset, model=..., limit=3). The dry run prints the pinned template revision (such as qwen3@3) and the share of tokens trained. See Chat templates and loss masks.
Checkpoints and evaluation#
| Parameter | Default | What it does |
|---|---|---|
| Checkpoint frequency | every 10% of steps (at least every 20 steps) or every 5 minutes, whichever comes first | Managed runs checkpoint automatically, including optimizer state, so a lost GPU costs a few minutes at most. Training pauses only for an in-memory copy; the upload runs in the background, one checkpoint at a time. Resume with client.runs.resume(run_id). |
eval_every | "auto" (every 25% of the run) | How often the held-out split is evaluated during training: every 25% of the run, at most every 20 steps, and at the end. An eval step is always also a checkpoint, so the best one can be promoted. Pass a number to evaluate every N optimizer steps. |
select | "best" | run.artifact is the best checkpoint by the recipe's held-out metric (listed under each recipe below). "last" keeps the final one. |
checkpoint_ttl_days | 30 | How long intermediate checkpoints are kept. A run keeps its last 3 checkpoints plus its best one while it trains (older ones are deleted), the best and final checkpoints never expire, and ckpt.promote(name=...) turns any unexpired checkpoint into an artifact. |
The run's resolved_config records the base model, adapter, chat template revision, thinking, train_on, the resolved lr (with lr_source and rule_version), the checkpoint and eval intervals, and the split. run.checkpoints() lists checkpoints with step, eval_score, best, final and expires_at.
Where code runs#
Built-in checks (Judge, validators.* and Rubrics made of them) run on the server and need no packaging. Your own Python Scorer functions run in your process: ev.wait() scores eval outputs locally. Training recipes don't take Python functions; a managed sandbox for them is coming soon. See Where your code runs.
| Parameter | Default | What it does |
|---|---|---|
requirements (on Scorer) | [] | Packages your function imports. evals.create checks them against your local Python environment and runs the scorer once on a sample record before any model is called. |
network (on Scorer) | False | Accepted for forward compatibility; local functions can always reach the network. |
runtime (on Scorer) | "local" | The only runtime for Python functions. A Scorer that wraps a validators.* check runs on the server. |
SFTRecipe#
| Parameter | Default | What it does |
|---|---|---|
model | "qwen/qwen3-8b" | Base model or a previous Artifact. |
adapter, lr | adapters.LoRA(rank=32), "auto" (about 5e-4) | See Optimization. |
train_on, thinking, reduction | "last", "auto", "per_example" | See Data and chat templates. |
merge_on_export | False | Exports a standalone merged checkpoint instead of a LoRA adapter. A merged export can't be continued with model=. |
Best checkpoint by held-out eval loss.
DPORecipe#
| Parameter | Default | What it does |
|---|---|---|
loss, beta | losses.DPO(beta=0.1) | Higher beta (0.2–0.5) stays closer to the starting model; lower (0.05) pushes harder away from rejected answers. beta= is shorthand for loss=losses.DPO(beta=...). |
lr | "auto" (about 2e-5) | Much lower than SFT, so formatting taught by SFT survives. |
adapter | the starting artifact's adapter when model= is an artifact; otherwise adapters.LoRA(rank=32) | When continuing an artifact, leave it out or match its rank and alpha. |
| Reference model | the starting checkpoint | Loaded for you; never passed explicitly. |
To run DPO after SFT, wait for the SFT run and pass its artifact: DPORecipe(model=sft.artifact). Best checkpoint by held-out preference accuracy.
GRPORecipe#
Coming soon; see RL for agents. The server rejects it today (422 recipe_deferred). Pass either rubric= (single-turn) or env= (single- or multi-turn).
| Parameter | Default | What it does |
|---|---|---|
model | "qwen/qwen3-8b" | Base model, or an Artifact (for example from SFT) to start RL from. |
rubric | none | How to score single-turn answers: a Rubric, Judge, Scorer, score name or function. |
env | none | An Environment: environments.Tools(...) or your own subclass. |
batch_size | 32 | Prompts per training step. |
group_size | 8 | Attempts per prompt, scored against each other. Raise to 16 when most groups score all 0 or all 1. |
max_new_tokens | "auto" | Generation limit per turn. See How "auto" values resolve. Cut-off answers score 0. |
temperature | 1.0 | Sampling temperature for training attempts. |
lr | "auto" (about 5e-5) | |
adapter | adapters.LoRA(rank=32) | Ranks as low as 8 work well for RL. |
loss | "auto" | See How "auto" values resolve. |
advantage | advantages.GroupStd() | How each attempt's score becomes an advantage relative to its group. |
max_staleness | 0 | The one async setting: how many weight versions a rollout may lag behind the trainer. 1–2 overlaps slow container rollouts with training. Stale rollouts are kept, not discarded. |
kl_coef | 0.0 | Penalty for drifting from the starting model. Set 0.01–0.05 only if outputs drift from its style. |
max_turns | the environment's own | Turn limit for multi-turn environments. |
thinking | "auto" | Use "off" when the task doesn't need long reasoning and answers are getting cut off. |
RL metrics: mean_reward; truncation_rate, the share of attempts cut off at max_new_tokens (above 5% needs attention); and for async runs, staleness_mean and staleness_max.
DistillRecipe#
See Distillation.
| Parameter | Default | What it does |
|---|---|---|
model | "qwen/qwen3-4b" | The student: a LoRA (adapters.LoRA(rank=32)) on this base model. adapters.LoRA(merge_on_export=True) exports merged weights instead. |
teacher | required | On-policy: a catalog model that shares the student's tokenizer, loaded by the trainer on the same GPU as the student, so the pair must fit in its memory (a 14B teacher for a 4B student, not a 32B one). Off-policy: any catalog model, or one of your Artifacts served by the inference endpoint. |
rollout | OnPolicy(max_new_tokens="auto") | The student writes each answer (temperature 1) and the teacher scores those tokens. OffPolicy(max_new_tokens=1024) has the teacher answer each prompt once in a labeling eval before training (greedy, billed as an eval, estimated in runs.plan().labeling) and trains on those answers. |
loss | losses.TopKKLDistill(top_k=32) | On-policy: matches the teacher's top-k next-token probabilities; top_k of 16–32 captures almost all the signal. Off-policy: losses.CrossEntropy() on the teacher's answers. |
context | none | A Context to bake into a LoRA fine-tune: the teacher reads it before every prompt and the student doesn't (on-policy only). |
lr | "auto" (about 2e-4) |
On-policy runs meter each prompt's tokens twice at the student's price (it writes an answer, then trains on it), plus the teacher's prompt and answer tokens at the teacher's catalog price; the teacher also answers the held-out prompts once. runs.plan().teacher shows the teacher's share, which estimated_cost_usd includes. Metrics report answer_tokens and truncation_rate.
Best checkpoint by KL to the teacher on held-out prompts (eval_kl, on the teacher's own answers; base_kl is the untrained student's), or by held-out loss off-policy.
RouterRecipe#
| Parameter | Default | What it does |
|---|---|---|
model | "qwen/qwen3-0.6b" | Router backbone: qwen/qwen3-0.6b or qwen/qwen3-1.7b. |
models | the models found in metadata.model (or model-keyed scores) in your logs | Candidate models, at least two. Required with a Judge or Rubric. Candidates must be catalog models or workspace artifacts served by the inference endpoint. |
rubric | the score on your logs | A score name on your records (pass it when records carry several scores), or a Judge or Rubric of judges and validators. With a Judge or Rubric, the server replays each prompt against models and scores the answers in a labeling eval before training; it's billed as an eval, isn't capped by max_cost_usd, and its estimate is in runs.plan().labeling. Python functions (Scorer(fn=...)) are coming soon. |
max_quality_drop | 0.02 | Training target: how much quality, compared with the fallback model, the router may trade for cost savings (0–0.5). |
pricing | none | USD per request per candidate via pricing=, else metrics.cost_usd on your logs (with a Judge rubric the labeling eval records each call's cost at catalog prices). Without either, cost_savings_pct is null. |
fallback | the best-scoring candidate | The candidate that gets every request the router doesn't offload. Must be one of models. |
DecisionModelRecipe#
| Parameter | Default | What it does |
|---|---|---|
model | gradiated/linden-1, chosen by the recipe | Pass "qwen/qwen3-0.6b" to train from a general open model instead. |
loss | by question type: losses.CrossEntropy() (choice), losses.BCEWithLogits() (noul), losses.OrdinalBCE() (score) | Not overridable; passing loss= is an error. |
adapter | adapters.LoRA(rank=32) | adapters.FrozenHead() trains only the heads on a frozen backbone (linden-1 only). |
lr | "auto" (about 3e-4 on linden-1) | Printed by the dry run. |
Best checkpoint by held-out loss.
RewardModelRecipe#
See Reward models.
| Parameter | Default | What it does |
|---|---|---|
model | "qwen/qwen3-8b" | 4B–8B models score in milliseconds. |
adapter | adapters.LoRA(rank=32) | Rank 8–16 is enough for a few thousand pairs. |
rubric | none | A score name in [0, 1] on records ending in an assistant turn, trained pointwise (BCEWithLogits) next to the Bradley-Terry loss on pairs. |
lr | "auto" (about 1e-4) |
Pairs stay on the same side of the split. Best checkpoint by held-out pair accuracy (preference_accuracy), or by held-out loss when there are only scored answers.
EmbeddingRecipe#
| Parameter | Default | What it does |
|---|---|---|
model | baai/bge-small-en-v1.5, chosen by the recipe | Compact encoder with sub-10 ms inference. |
| Weights trained | All encoder weights (managed by the recipe) | Small encoders (33M params) train fast end-to-end and usually beat LoRA. |
pool | pooling.Mean() | Averages token vectors into one vector. pooling.CLS() uses the first token's vector instead. The pooling is saved with the artifact. |
loss, temp | losses.InfoNCE(temp=0.05) | Lower temp (0.03) sharpens rankings when negatives are near-duplicates. Without negatives, other documents in the batch serve as negatives. temp= is shorthand for loss=losses.InfoNCE(temp=...). |
lr | "auto" (about 2e-5) |
Best checkpoint by held-out top-10 hit rate.
CartridgeRecipe#
| Parameter | Default | What it does |
|---|---|---|
context | required | Context.from_text(...) or Context.from_file(...). The context plus each prompt must fit the model's 32,768-token window. |
num_tokens | 256 | Size of the compressed prefix (16–4096). Try 512–1024 for very large contexts. |
teacher | the same model reading the full context | Pass a larger catalog model of the same family to distill from it as well. |
loss | losses.TopKKLDistill(top_k=20) | Pass losses.TopKKLDistill(top_k=...) to change top_k (the SDK's bare TopKKLDistill() means 32). |
slot_token | the first reserved token that tokenizes atomically | The token that marks where the cartridge goes in a prompt. |
max_new_tokens | 256 | Length of the teacher's answer to each prompt during distillation (1–8192). |
lr | "auto" (about 1e-2) | Prefix KV tokens need a far higher learning rate than LoRA weights. Keep overrides within 1e-2–2e-2. |
Best checkpoint by closeness to the model reading the full context.
Environments#
Environments are coming soon with GRPORecipe; see Environments. The SDK types environments.Tools today.
| Parameter | Default | What it does |
|---|---|---|
environments.Tools(tools, ...) | — | Turns typed Python functions into tools; each signature and docstring becomes the tool's JSON schema. An empty list gives a single-turn environment. |
Tools(tasks=, rubric=) | none | The task dataset, and how each finished attempt is scored. |
Tools(max_turns=) | 10; 1 with no tools | Maximum model turns per attempt. |
Tools(system_prompt=) | none | System instructions added to every task. |
Tools(requirements=) | [] | Packages your tool functions import. |
Judge and Scorer#
| Parameter | Default | What it does |
|---|---|---|
Judge(model=) | required | There's no default model that could change under you. The eval records every judge model it used (judge_models). |
Judge(prompt=), Judge(name=) | none, "judge" | Scoring instructions (up to 8,000 characters) and the score's name. |
Judge(weight=), Scorer(weight=) | 1.0 | Weight of this check in the Rubric's overall score. |
requirements, network, runtime | see Where code runs |
Evaluations#
For client.evals.create(...) and client.evals.plan(...).
| Parameter | Default | What it does |
|---|---|---|
dataset | required | The dataset whose prompts every model answers: your own, or a benchmark from client.datasets.from_benchmark(...). |
rubric | the dataset's own (a benchmark's answer check), else validators.NonEmpty() | Judges, validators.* and local Scorers, alone or in a Rubric. |
samples | 1 | Attempts per task (1–32). pass@1 and pass@samples are reported. Use 3–4 for decisions you'll act on. |
baseline | none | A model or artifact for a paired comparison, with a confidence interval on the difference. |
pass_threshold | 1.0 when every check is binary (regex or validator), 0.5 otherwise | The score at or above which an attempt counts as passing, for pass@k. |
temperature, max_tokens | 0.7, 1024 | Sampling settings for the evaluated models. |
limit | the whole dataset | Evaluates only the first limit records. |
client.evals.plan(...) returns estimated_cost_usd at $0. Eval usage is billed: the finished eval reports total_cost_usd, and each model's summary its cost_per_1k_tasks_usd.
Deploy#
How "auto" values resolve#
| Value | How it's chosen |
|---|---|
lr="auto" | A per-model, per-recipe table, calibrated by a learning-rate sweep on each base model. Each entry is measured at batch_size=128, LoRA(rank=32, alpha=32), linear decay with 3% warmup and AdamW(betas=(0.9, 0.95)), then scaled by the square root of your batch size over 128 and by lr_scale. A model trains only the recipes it has an entry for (client.models.list() and GET /v1/base-models list them as recipes and calibrated_lrs); self-hosted servers register extra models, with their learning rates, through GRAD_EXTRA_MODELS_JSON. |
loss="auto" (GRPO, coming soon) | losses.GRPO(clip_low=0.2, clip_high=0.28) for on-policy runs. With max_staleness > 0 it adds mask_ratio=(0.5, 2.0), which drops tokens whose probability under the current weights has moved more than 2× from the sampler's. auto never picks losses.CISPO, and the dry run warns if you combine CISPO with max_staleness > 0. |
max_new_tokens="auto" (distillation) | The 95th-percentile length of the assistant turns already in your records, rounded up to a multiple of 32 and kept between 32 and 1024, or 256 when the records have none. Metrics report truncation_rate. |
thinking="auto" | The base model's own default. For Qwen3, thinking is on, and records with no <think> block train with thinking off. |
Resolved learning rates on each recipe's default model at batch_size=128:
| Recipe | Default model | lr |
|---|---|---|
| SFT (LoRA) | qwen/qwen3-8b | 5e-4 |
| DPO | qwen/qwen3-8b | 2e-5 |
| Router | qwen/qwen3-0.6b | 5e-4 |
| Decision model | gradiated/linden-1 | 3e-4 |
| Context Cartridge | qwen/qwen3-8b | 1e-2 |
| Embeddings (encoder) | baai/bge-small-en-v1.5 | 2e-5 |
| Distillation | qwen/qwen3-4b | 2e-4 |
| Reward model | qwen/qwen3-8b | 1e-4 |
Rule versions. The auto rules are versioned. Each run's resolved_config records the version it used (rule_version: auto@2) and where its lr came from (lr_source, for example auto@2: calibrated for qwen/qwen3-8b at batch 128, sqrt batch scaling). If we change what a rule resolves to, it gets a new version, and existing run configs keep the old one.