Skip to main content
Describe a run in a TOML config, then pass it to flash train. Every run requires project and model. SFT and GRPO also require environment.id; custom training requires [custom] instead. algorithm defaults to sft. flash train config.toml --dry-run runs submit-time checks without starting paid training or allocating a training GPU. See Cost and billing for estimate behavior.

Top level

[environment]

Environment code reads the secret normally:
Never put secret values in [environment.params]; those values are recorded on the run. Every name you list under [environment].secrets must resolve to a value in your shell, .env, or .env.local when you submit. Names such as FREESOLO_API_KEY, RUN_ID, and GITHUB_TOKEN are reserved by Flash.

Scorer dependencies

Declare third-party scorer dependencies under [environment] pip:
Use a list of requirement strings, such as ["pymongo==4.10.1"]. Pip options, credential-bearing URLs, and URLs with query strings are rejected. Private packages requiring authentication are unsupported; include their source in your published environment or use a publicly installable package. Declare every extra dependency even if it is already installed locally. flash env test succeeding locally does not prove all dependencies are declared. A missing package or incompatible version can fail a submitted run.

[train]

[train] is a flat table. The fields below describe SFT and GRPO; custom training accepts only its listed subset. Shared recipe keys are below; the rest are scoped by algorithm and a knob the run’s algorithm cannot consume is rejected at submit rather than silently ignored. See Knobs are scoped by algorithm. --dry-run, --cost, and submission resolve warm-start rank, alpha, and the source base-model identity through the authenticated control plane.

Warm-start from SFT or GRPO

init_from_adapter supports SFT and GRPO continuation in either direction, including same-algorithm continuation. Custom training can also warm-start from an adapter with fresh optimizer state. Use custom.resume_from to restore a saved custom optimizer and algorithm state.
Across the lineage keep the same base model. The source adapter’s rank and alpha are authoritative, so setting lora_rank or lora_alpha alongside init_from_adapter is rejected at submit, and a source rank above the model’s serving cap is rejected too.

Knobs are scoped by algorithm

There are no [sft] or [grpo] tables: every knob lives under [train], and the error names the key you set. --dry-run surfaces these without allocating a GPU. Custom training accepts a smaller set of [train] fields; see [custom].

GRPO needs a stated horizon

For GRPO, set a positive [train] max_steps or the dataset size in [train] max_examples. A config without either cannot be quoted. [environment.params] max_examples does not satisfy this requirement. SFT can be quoted without either limit.

Batch settings by algorithm

Use batch_size for SFT and prompts_per_step for GRPO. Each is rejected under the other algorithm. The default is 64 prompts per step for GRPO.

SFT-specific

Use batch_size to set examples per training step. Generation settings such as group_size and max_completion_tokens are rejected. If a run warns that sequence packing is off, its effective batch is one example per step, even with a larger configured batch_size. Review the quote and consider a lower learning_rate. This limitation applies to image-bearing SFT.

GRPO-specific

Length-limited completions

mask_truncated_completions is a GRPO-only boolean. The default masks length-limited completions from the loss, including when stop_sequences is configured. Responses that actually finish on a stop string remain trainable. Set it to false only for single-turn rewards designed to score partial output, such as draft-token prefix agreement. This keeps generated tokens in the loss without inventing an end-of-sequence token. Empty batches and generation errors still fail. The option is unsupported for multi-turn environments, whose actions must be complete and usable.

The GRPO rollout shape is a fixed set

GRPO group_size accepts exactly 2, 4, or 8, and defaults to 8. Any other value - including 1, 3, 6, or anything above 8 - is rejected at submit, before a GPU is looked up or allocated. Flash never rewrites the value you authored, so an unsupported group_size fails fast instead of quietly training a different shape than you asked for. A step also has a completion ceiling:
The default 64 x 8 is exactly 512. Admission checks the authored values, or their defaults when omitted, so an oversized shape is refused up front - a smaller retained dataset cannot rescue it later. To raise one factor, lower the other. At execution the effective prompt count may clamp down to the number of valid prompts left after max_examples and prompt-budget filtering; group_size is never changed. Rollout generation, reward work, and cost all scale with the effective prompts_per_step x group_size product.

Structured outputs

structured_outputs constrains GRPO rollouts; SFT rejects it. Set exactly one JSON schema, regex, choice, or json_object constraint. Optional whitespace controls are documented in the guide. Combining constraints or using unsupported forms is rejected. With thinking = true, the constraint applies to the final answer. See Structured outputs.

[custom]

Use this table only with algorithm = "custom". See the custom-algorithm guide for the local script contract. Custom [train] accepts only these fields: Custom training supports every catalog model, with text-only inputs on one Modal GPU by default. Omit [gpu] for automatic cheapest-fit single-card selection, or use type to constrain the GPU classes and count = 2 to allow two cards. Custom training supports only counts 1 and 2; the count is a ceiling, so a cheaper fitting single card can still win. Two-card workers shard model layers and optimizer state; full-logit memory must fit per device. Omit [environment], [wandb], and thinking. Batch construction, learning rate, data limits, and logging belong in your script. Use custom.resume_from for durable continuation, or train.init_from_adapter for a fresh optimizer initialized from an adapter. They are mutually exclusive; omit rank and alpha when warm-starting.

[gpu]

Flash uses Modal by default. Set spot = true to opt into Spot for SFT/GRPO when enabled on your control plane; Spot never falls back to Modal. See Spot training for capacity and checkpoint behavior. A scalar type pins one supported GPU class, while a list allows any of those classes. Run flash gpus for the current validated names.
This permits either 80 GB class on Modal, subject to the model’s memory needs. Omitting count with an authored type keeps this a single-card constraint.

Multi-GPU runs

The automatic shapes below apply to SFT and GRPO. Custom training defaults to one card and supports an explicit ceiling of two; see custom multi-GPU training. Omit both type and count for automatic GPU selection. A Modal run can use one, two, four, or eight cards, depending on the model and GPU class. Spot offers one- or eight-card shapes; a ceiling below eight permits only one. Review the quote before submitting. Setting count turns it into a hard ceiling that never escalates:
A ceiling of 3 therefore never buys 4 cards - it permits 1 or 2. An explicit count = 1 on a run that does not fit one card is an error rather than a silent escalation, and it names the smallest count that would work:
If nothing fits even at eight cards, the error names the knobs that actually shrink that algorithm - they differ per algorithm. See Pre-flight says the run is too large.
Authoring type without a count, whether as a scalar pin or an acceptable list, stays a single-card constraint. Auto-sizing across multiple cards applies only when you omit both keys.
flash train --gpus N sets the same ceiling from the command line without editing the config. Cost is quoted for the shape the run actually occupies, so a multi-card run is priced on every card it held. A run’s VRAM requirement is a whole-run figure, and a multi-card shape pools its cards to meet it. The quote spells out both numbers so a shape that fits does not read as a rejection:
The per-card size stays visible because that is what you check against a provider listing. If an authored single-card pin cannot hold the run, the error now names the card count that would - for example it fits on 2 cards -- raise the card ceiling with --gpus 2 - so a run needing more than the largest single card is not a dead end.

[wandb]

Optional Weights & Biases logging labels. These values are non-secret; set WANDB_API_KEY in your local environment when submitting a run to enable logging to your own W&B account.

Overrides & composition

Set any value at submit time without editing the file. The override flag is --set (repeatable, dotted keys):
The config file is the base, --config overlays merge onto it, and --set/--gpus win over both, applied left to right. An absent --gpus is indistinguishable from no flag, so a [gpu] count authored in the file is never silently downgraded.