GRPO: split GPUs, one shared GPU, or separate processes
EngineSurogate EngineThe same train, infer, and orch configs run
Qwen3-0.6B on the local markdown-table-qa reward environment. Run them from the repository
root with the RL dependencies installed. The environment loads from
environments/markdown-table-qa, so you don’t need to install it separately.
# Two GPUs: separate rollout server and trainer.surogate grpo --train examples/grpo/train.yaml --infer examples/grpo/infer.yaml \ --orch examples/grpo/orch.yaml --infer-gpus 0 --trainer-gpus 1On one GPU, use the same files with a fresh outputs/grpo directory:
CUDA_VISIBLE_DEVICES=0 surogate grpo-colocate \ --train examples/grpo/train.yaml --infer examples/grpo/infer.yaml --orch examples/grpo/orch.yamlColocation shares one BF16 base model and alternates between generation and training. It requires unquantized BF16 safetensors, LoRA, one GPU, and a model the shared runner supports (Nemotron is not supported). It does not support checkpoint resume, QLoRA, CPU weight offload, or QeRL noise. See colocation limits.
For rollouts with real function tools, use tools-orch.yaml with the same training and inference files and a fresh output directory.
Split mode reads enable_auto_tool_choice from infer.yaml. A tool
environment does not work without it:
surogate grpo --train examples/grpo/train.yaml --infer examples/grpo/infer.yaml \ --orch examples/grpo/tools-orch.yaml --infer-gpus 0 --trainer-gpus 1Colocate hardcodes the equivalent in its shared server and ignores the flag, but the same orchestrator config applies:
CUDA_VISIBLE_DEVICES=7 surogate grpo-colocate \ --train examples/grpo/train.yaml --infer examples/grpo/infer.yaml \ --orch examples/grpo/tools-orch.yamlThe local tool environment exposes add(a, b), executes the model’s
structured tool call, returns a tool message, and rewards the final answer.
Schemas come from Verifiers’ ToolEnv, and custom environments can expose their own
Python functions the same way. Tool results are context tokens and carry no GRPO loss.
Every model family that native colocate supports can use tools. The shared training
server picks the checkpoint’s tool protocol, or adapts templates that have no tool support.
Base models still need training before they call tools reliably. See the
protocols and limits.
To run independent processes, use three terminals:
CUDA_VISIBLE_DEVICES=0 surogate grpo-infer examples/grpo/infer.yamlsurogate grpo-orch examples/grpo/orch.yamlCUDA_VISIBLE_DEVICES=1 surogate grpo-train examples/grpo/train.yamlThe processes must share the output filesystem and see the same broadcast paths.
You can’t currently tell grpo-train where the orchestrator polls, so this
layout works only with an orchestrator output_dir of run_default, which is
what orch.yaml uses. With tools-orch.yaml (run_tools) the trainer
publishes somewhere the orchestrator does not read and the run fails once
checkpoint_wait_timeout expires. Use split mode for tool environments.
For remote servers, update client.base_url and the bind address in the inference
config. Multi-node SFT uses Ray, while this RL layout uses separate service processes.
The configs show grouped rewards, token-in/token-out rollouts, a temperature
schedule, online difficulty filtering, periodic evaluation, local metrics, and
orchestrator and trainer checkpoints. Evaluation runs before training and every ten
steps. Read metrics from outputs/grpo/metrics.jsonl (trainer) and
/tmp/grpo_metrics.jsonl (orchestrator).
When you customize the configs, keep these values aligned:
- The model name in all three configs, and
max_stepsin the trainer and orchestrator. sequence_lenin the trainer and orchestrator, with a large enoughmax_model_lenon the server.orch.output_dirmust betrain.output_dir/run_<name>.rollouts_per_examplemust dividebatch_size. Inference needs room for the prompt plus the completion, and adapters must fit withinmax_lora_rank.
use_token_client: true keeps the tokens generated so far and appends the
environment’s response through a template bridge. Surogate’s bridge keeps
real function names and handles Qwen’s reasoning rules. Truncated
turns or incompatible custom templates can still fall back to message rendering,
and the client logs when that happens. The multi-turn OPD example uses
message rendering explicitly. Very short completion limits can truncate every answer and leave zero
reward. A small model may also need easier tasks or more steps to learn.
For split-mode resume, set trainer resume_from_checkpoint: true and orchestrator
ckpt.resume_step to the matching saved step (or -1 for the latest), and keep
the same output paths. The optional ckpt.spool_inflight: true also saves in-flight
rollouts. Do not use the resume variant with colocation.
The active GRPO loss accepts adv_tau, teacher_tau, kl_tau, ipo_mask_low,
ipo_mask_high, and ratio_clip. The teacher term is demonstrated in
TurnOPD; RULER adds an external judge.
Native serving cannot apply QeRL base-weight noise, so both native runners reject
noise_scheduler.enabled. The replay/OPD reference-loss knobs do not yet
add up to a complete replay-training CLI workflow, so there are no runnable recipes for them.
Token budgets, filtering and async collection
Section titled “Token budgets, filtering and async collection”To collect each batch by a budget of generated tokens, copy orch.yaml, remove batch_size
and add:
token_batch_size: 8192max_inflight_rollouts: 16Keep rollouts_per_example, because collection still works in complete groups. To get
metrics on degenerate rollouts, add a filter (set enforce: true to mask them):
filters: - type: repetition enforce: false window: 32 prob_threshold: 0.99To train on several reward tasks, append named entries to env and set
buffer.env_ratios to one positive weight per environment. Different environment
arguments can make easier or harder variants of the same task. For split or
separate-process runs, bound policy staleness by tuning max_async_level in both the trainer and
orchestrator, and max_off_policy_steps in the orchestrator. Colocation
sets synchronous collection on its own.
Separate processes can send batches over ZMQ. Set transport_type: zmq
in the trainer and add the following to the orchestrator (adapter broadcasts still
need a shared filesystem):
rollout_transport: type: zmq host: localhost port: 5555 hwm: 10Use filesystem transport with colocation. See the RL guide for custom environments and advantage functions.
Next: RL environments shows how to write your own task and reward, and the GRPO kits are tested single-GPU recipes to start from.