Recipes

Coral

Test-time training of the served model on a CORAL task: CORAL's coding agents work on one problem in git worktrees, every model call goes through Reef, and the graded attempts train the model. The recipe is beta (issue #422); issue #3 tracks the experiment.

What it trains#

The served model's weights; the example trains a rank-32 LoRA of Qwen3-8B on Slime. The feedback is CORAL's grader score of each attempt: a watcher reports each finalized attempt once, with the inference records of its calls. The scored attempts that start from one parent commit form a group. When group_size of them have a score, the group trains one step with the tttd objective and loss family (grouped leave-one-out advantages), and later attempts run on the new weights. stages.py and recipe.py give the grouping and the training.

When to use it#

  • A CORAL task: several coding agents, graded attempts on one problem, and a model that Reef serves and trains.
  • For one problem without CORAL's runtime, use TTT-Discover.

Known limitations:

  • A parent commit with fewer than group_size scored attempts never trains.
  • The adapter puts its middleware inside CORAL's gateway (gateway_launcher.py). It is written against CORAL commit 0123dfb, which the example pins.

Requirements#

  • One node with 4 GPUs: 2 for the Slime actor and 2 for two SGLang engines.
  • Reef's Slime training environment (Train model weights).
  • CORAL at the pinned commit: pip install -e .[coral] in examples/coral_demo.
  • A CORAL runtime CLI on PATH, opencode by default (npm install -g opencode-ai). Any runtime that CORAL registers works (--runtime claude_code, codex), if it accepts an OpenAI-compatible endpoint for a local model.

Run the example#

Shell
cd recipes/beta/coral/examples/coral_demo
pip install -e .[coral]
npm install -g opencode-ai
./run.sh

run.sh downloads Qwen/Qwen3-8B to work/model on the first run, starts reef serve -c serve.yaml and waits for /healthz. Then run.py starts CORAL's AgentManager on the task in task/: implement a stable merge of two sorted lists, scored by the fraction of checks that pass. Two agents run until 8 attempts are graded (--agents, --max-attempts). The run then writes work/coral-demo/bundle.json: the score over time, the best attempt, the model revisions served and the token counts.

Without GPUs, smoke/run_smoke.sh runs run.py against the Reef service with a canned model and a scripted CORAL runtime. coral validate task/ checks the task package.

Configuration#

  • recipe.samples.group-size: the scored attempts of one parent that make a group; 4 by default, 2 in the example (CoralSettings).
  • recipe.samples.accept-multi-turn-policy-samples: train all calls of an attempt as one sample; on by default in this recipe.
  • recipe.jobs.job-samples: the samples of one job; 4 in the example, equal to global-batch-size.
  • training.options: the Slime options, such as the LoRA rank and lr; n-samples-per-prompt follows group-size.
  • run.py flags: --agents, --max-attempts, --runtime and --model.

See the settings reference for the shared settings.

Results#

No measured results. The tests and the smoke run check the wiring, not learning.

Files#

Text
coral/
  __init__.py            exports the adapter and CoralRecipe
  recipe.py              CoralRecipe: the CORAL stages with the tttd objective
  stages.py              CoralSamples, CoralGrouping and CoralJobData: sibling groups of one parent commit
  middleware.py          ReefGatewayMiddleware: Reef scenario and tag headers on CORAL's gateway calls, and receipts
  gateway_launcher.py    puts the middleware inside CORAL's gateway
  journal.py             CallJournal: the append-only journal of the gateway's calls
  watcher.py             AttemptWatcher: reports each finalized attempt once
  reporter.py            AttemptReport: one attempt as a POST /reef/report
  bundle.py              the run's result bundle from the journal and the reports
  examples/coral_demo/
    serve.yaml           the Slime deployment: Qwen3-8B LoRA on 4 GPUs
    run.sh               downloads the model, starts Reef, runs run.py
    run.py               CORAL's AgentManager with the adapter and the watcher
    task/                the CORAL task: the seed, the grader and the LiteLLM gateway config
    smoke/               the run without GPUs: a canned Reef service and a scripted runtime

The tests are in tests/recipes/coral/.