async_rl_loop. You provide dataset rows and a rollout function; the recipe runs rollout production independently from serialized training. When a rollout finishes, the producer immediately tries to refill available capacity—even while forward/backward or optimizer work is running.
For the shared serverless pool, use the experimental
async_rl_loop_serverless sibling.
It keeps the rollout and scheduling contract described here but publishes
session-scoped snapshots instead of hotloading an inference deployment. See
Serverless Training for lifecycle and
limits.
Responsibilities
Minimal setup
prompt_token_ids. Fork the single-turn example or multi-turn example for your environment.
For multi-turn agents, tools, sandboxes, token ancestry, and session design, read
Cookbook: Agentic Reinforcement Learning.
Agentic RL is a rollout integration concern; it does not change the async
loop’s scheduling contract. The
Terminal-Bench 2.0 example
shows a complete serverless integration with Harbor-managed local containers,
OpenCode tool use, verifier rewards, and multi-segment logical rollouts.
Rollout contract
The factory receivesRolloutSetup once and returns an async function:
rollout_fn completions_per_prompt times for each dataset row. One call represents one trajectory and returns:
RolloutRun(segments=[...])on success. A run contains one or moreRolloutSamplesegments from the same trajectory.Noneto drop that trajectory draw.
tokens, logprobs, and loss_mask lists plus a scalar reward. Set the mask to 1 only for tokens that should contribute to training. All segments in one run must have the same reward.
Scheduling controls
These five fields define the rollout/training pipeline:
Admission is row-atomic: the scheduler submits a row only when both the staleness budget and concurrency budget can fit all of its completions.
max_head_offpolicy_versions=0 is fully on-policy: every optimizer batch trains groups from its current published policy version. Chunk training can still overlap remaining rollouts from the same optimizer batch.
Runtime behavior
- The recipe syncs initial policy weights to the sampler.
- The producer submits complete rows while both admission budgets allow it.
- Every completed rollout retries refill. As soon as the first training chunk is ready, serialized trainer work can begin while rollout production continues.
- Later chunks queue and run in order. One optimizer step follows the final chunk.
- The recipe hotloads the updated weights and publishes the next policy version. Publication reopens staleness capacity.
async_rl_loop does not expose a weight-sync interval. Known transient rollout failures are dropped behind a bounded circuit breaker. Invalid rollout data, unexpected cancellation, and unknown errors remain fatal.
Loss behavior
The stock recipe has one direct client-side GRPO path and nopolicy_loss or loss_path selector. anchor_logp="old_policy" (the default) snapshots trainer logprobs and applies TIS against rollout behavior logprobs; anchor_logp="rollout" reuses aligned rollout logprobs and makes the TIS ratio identity. Set kl_beta=0 to disable reference-policy KL and reference provisioning.
Detailed reference
Keep implementation and tuning detail out of the recipe page:- Async RL skill reference — admission math, metrics, tuning, failure policy, and resume semantics
- Agentic RL skill reference — multi-turn token ancestry, session/cache architectures, mismatch policies, and trace failures
- Custom RL loss reference — fork the recipe deliberately when you need a trainer built-in or another research objective
- Checkpointing — resumable checkpoints and final model promotion
- Weight sync — how updated policy weights reach the sampler
rl_loop— simpler synchronous GRPO when rollout/training overlap is unnecessary
IGPO (Information Gain Policy Optimization)
Theigpo_loop recipe extends the async RL pipeline with turn-level information-gain rewards for multi-turn agent trajectories. Start from Cookbook RL for the core rollout and weight-sync lifecycle, then switch to igpo_loop when your reward depends on per-turn information gain rather than a single scalar at episode end.