Skip to main content
Use a verifiable reward when code can check a response, such as a math answer, test result, schema constraint, exact extraction, or tool outcome.
Sampling, forward-backward passes, optimizer steps, and checkpoints all belong to the same interactive Fastino job. Reward execution and application state remain in your code.

Prerequisites

Start with a working interactive training loop from the Decoder Quickstart and confirm that a baseline datum trains successfully. This guide reuses its call and wait helpers, tokenizer, and job_id. Your application samples responses, grades them, and converts rewards into per-token advantages. Fastino applies those advantages with a supported loss: importance_sampling, ppo, cispo, or dro. Custom loss functions do not run inside the training job.

1. Define a narrow grader

Separate parsing from scoring so malformed output is observable:
Run generated code or tools only in an isolated, resource-limited environment. Fastino doesn’t execute your reward function or manage its side effects.
Keep a frozen fixture set that includes correct, incorrect, malformed, and equivalently formatted answers. Log parse failures separately from valid but incorrect responses.

2. Snapshot the job for sampling

Save a sampler checkpoint from the current weights, then sample a group from it:
This doesn’t create another job. The checkpoint and the samples belong to the same interactive job.

3. Convert rewards to advantages

Track groups with no reward variance. They may indicate that the task is too easy, too hard, or parsed incorrectly.

4. Build aligned datums

The prompt is context, so prompt positions receive zero advantage. Completion positions receive the response’s group-relative advantage and the sampler’s log probabilities. Every tensor has one value per input position:
Use the tokenizer of the job’s base_model for both prompts and decoding.

5. Update the interactive job

Wait for forward-backward to succeed before submitting the optimizer step. Wait for and record the optimizer result before advancing the application step. Supported loss_fn_config fields and defaults: The reward-loss safeguards in the last row are enabled by default. Unknown configuration fields are rejected.

6. Save a recovery boundary

Persist the returned path with:
  • Job ID
  • Application step and dataset cursor
  • Dataset and reward implementation revisions
  • Base model and training configuration
  • Evaluation metrics
This metadata lets a controller choose a checkpoint without guessing from its name.

7. Run the reward loop

Define the training examples in your application, then compose the helpers inside the loop. continue now skips only the current group when all rewards are equal:

Verify before scaling

  • The grader distinguishes known correct and incorrect fixtures.
  • Malformed responses don’t crash the application loop.
  • At least one sample group has reward variance.
  • Every datum’s tensors have one value per input position.
  • Forward-backward passes and optimizer steps complete on the same job.
  • A new job can start from a state checkpoint with its client-owned resume metadata.
  • Held-out evaluation remains separate from the training reward batch.
For the surrounding lifecycle, read Build an interactive training loop.