OpenRL is configured with environment variables. The examples below use plain
shell commands so they work even if make is not installed. The root
Makefile wraps the same commands for convenience.
Install uv if needed:
curl -LsSf https://astral.sh/uv/install.sh | shStart the API server and trainer in one process, sampling with torch:
BASE_MODEL=google/gemma-4-e2b \
uv run --extra cpu python -m uvicorn server.api_server:app --host 127.0.0.1 --port 23500Because REDIS_URL is unset, the API server runs the trainer loop in its own
process and samples with torch. This works on a laptop without a GPU.
To train and sample on GPUs with vLLM, set REDIS_URL. The API server then
launches a trainer and a vLLM sampler as separate worker processes when a client
creates a model, and they share queues through Redis:
REDIS_URL=redis://127.0.0.1:6379/0 \
BASE_MODEL=google/gemma-4-e2b \
VLLM_ARCHITECTURE_OVERRIDE=Gemma4ForCausalLM \
TRAINER_CUDA_VISIBLE_DEVICES=0 \
SAMPLER_CUDA_VISIBLE_DEVICES=1 \
uv run --extra gpu python -m uvicorn server.api_server:app --host 127.0.0.1 --port 23500The equivalent Makefile shortcuts are:
make server
REDIS_URL=redis://127.0.0.1:6379/0 VLLM_ARCHITECTURE_OVERRIDE=Gemma4ForCausalLM \
TRAINER_CUDA_VISIBLE_DEVICES=0 SAMPLER_CUDA_VISIBLE_DEVICES=1 make server| Env var | Default | What it does |
|---|---|---|
BASE_MODEL |
unset | Hugging Face model id loaded by the trainer and, when using vLLM, by the sampler. |
SAMPLING_BACKEND |
torch in one process, vllm when REDIS_URL is set |
Sampling backend selector. torch samples in the training process. vllm samples through the sampling pools described below and needs REDIS_URL. |
REDIS_URL |
unset | Enables distributed mode by switching the request store to Redis. Leave unset for a single-machine run. |
OPEN_RL_FUTURE_TTL_S |
300 |
How long resolved request results stay readable by retrieve_future after a worker resolves them. |
| Env var | Default | What it does |
|---|---|---|
OPEN_RL_TMP_DIR |
/tmp/open-rl |
Root directory for adapter snapshots under peft/ and saved states under checkpoints/. Required with OPEN_RL_WORKER_MANAGER=scheduler, set to the shared volume every worker pod mounts. |
OPEN_RL_TRAIN_TOKEN_BUDGET |
auto |
Maximum batch_size * max_sequence_length for padded trainer chunks inside one forward_backward request. auto uses the smaller of 16384 and the tokens whose activations fit in half of the free device memory, read at each request. A number is used as given; 0 runs one datum per pass. |
TRAINER_CUDA_VISIBLE_DEVICES, SAMPLER_CUDA_VISIBLE_DEVICES |
unset | GPUs given to the trainer and sampler worker processes the local worker manager launches. |
| Env var | Default | What it does |
|---|---|---|
OPEN_RL_WORKER_MANAGER |
local |
How the API server starts trainer and sampler workers: local runs them as subprocesses, scheduler creates Workloads for the OpenRL scheduler on Kubernetes, and none leaves workers to something else. |
OPEN_RL_ACCEL_TIMESLICER_SOCKET |
/tmp/open-rl/accel-timeslicer.sock |
Unix socket path for a local accelerator time-slicer. Used when OPEN_RL_ACCEL_TIMESLICER_HOST is unset. |
OPEN_RL_ACCEL_TIMESLICER_HOST |
unset | Node-local accelerator time-slicer host for Kubernetes workers. When set, the worker uses TCP instead of the Unix socket; Kubernetes sets this from status.hostIP. |
OPEN_RL_ACCEL_TIMESLICER_PORT |
9753 |
Node-local accelerator time-slicer TCP port for Kubernetes workers. |
OPEN_RL_LORA_JOBS_PER_RUNTIME |
unset | The most LoRA jobs one shared trainer and sampler serve. The next job on the same base model starts another runtime, so step time stops growing with the job count. The scheduler places that runtime like any LoRA runtime: it waits for GPUs up to OPEN_RL_PLACEMENT_TIMEOUT and is failed past it, and it may share a GPU with the first runtime unless the scheduler limits the seats per claim. 1 gives every job a runtime of its own. Unset or 0 puts every LoRA job on a base model on one runtime; the server refuses to start on any other value. |
OPEN_RL_AUTOMODEL_IMAGE |
ghcr.io/openrl-dev/openrl/automodel:latest |
Worker image used when a client requests openrl.trainer_backend=automodel. |
For per-job multi-GPU settings (openrl.trainer_backend,
openrl.trainer_device_count, openrl.trainer_cp, openrl.sampler_replicas,
and openrl.exclusive) and their restrictions, see
Multi-GPU Training and Sampling.
For local FFT subprocess mode, start python -m accel_timeslicer.serve before the
workers run. The local launcher tags each worker with a time-slice job id and
starts it in its own process group so the CUDA checkpoint backend can discover
the active GPU PIDs. Kubernetes deploys the equivalent process with the
open-rl-accel-timeslicer DaemonSet, which layers on top of the llm-d snapshot
backend by default for physical checkpoint/restore.
| Env var | Default | What it does |
|---|---|---|
VLLM_ARCHITECTURE_OVERRIDE |
unset | Optional architecture override passed to the in-repo vLLM worker. Gemma 4 examples use Gemma4ForCausalLM. |
VLLM_ENABLE_MULTIMODAL |
0 |
By default the samplers pass limit_mm_per_prompt={"image": 0, "video": 0}. Text checkpoints published as *ForConditionalGeneration otherwise make vLLM reserve a multi-GiB encoder cache during startup that no OpenRL code path can use, which can OOM engine init. Gemma 4 samplers also load the text-only Gemma4ForCausalLM. Set to 1 to restore stock vLLM behaviour and keep the full model. |
| Env var | Default | What it does |
|---|---|---|
TINKER_BASE_URL |
http://127.0.0.1:23500 |
Base URL used by example clients and scripts. |
TINKER_API_KEY |
tml-dummy-key |
Passed through to the Tinker SDK. Local OpenRL does not enforce auth. |
HF_TOKEN |
unset | Required for gated Hugging Face models. uv run hf auth login is the easiest setup path. |
ENABLE_GCP_TRACE |
0 |
1 exports OpenTelemetry traces to Google Cloud Trace. |
ENABLE_CONSOLE_TRACE |
0 |
1 prints trace spans to stdout for debugging. |
On Kubernetes the release bundles set these variables. The API server runs with
REDIS_URL and OPEN_RL_WORKER_MANAGER=scheduler; it creates a Workload for
each trainer and sampler, and the OpenRL scheduler starts their pods. The API
server writes each worker's environment into the Workload's pod template, so
there are no worker deployments to configure by hand.
Sampling goes through sampling pools. A pool serves one FFT job, one exclusive
LoRA job, or every shared LoRA job on one base model. Pending requests stay in a
Redis stream until a result is saved, so the Redis in k8s/deploy/base keeps an
append-only file on a persistent volume and never evicts keys.
A pool that one job owns runs vLLM in the sampler's own process when it has one
replica. A pool with two or more replicas (openrl.sampler_replicas), and every
pool that shared LoRA jobs use, runs vllm serve Workloads behind one CPU
Deployment, named after the pool, that runs the dispatcher, Envoy and the llm-d
endpoint picker (configured by the open-rl-sampler-router ConfigMap in
k8s/deploy/base). A shared pool grows to the most replicas any of its jobs asks
for. On one machine every pool has one replica, in process. See
the sampling pools design.
| Env var | Default | What it does |
|---|---|---|
OPEN_RL_DISPATCH_CONCURRENCY |
256 |
Requests one pool keeps in flight. |
OPEN_RL_SAMPLE_DEADLINE_SECONDS |
3600 |
How long a sampling request waits for a result before it fails. Set it on the API server. Worker pods and pool dispatchers get the same value. |
OPEN_RL_DISPATCHER_IMAGE |
the worker image | Image for each pool's dispatcher container. The release sets it to the API-server image, which carries the dispatcher without the GPU stack and pulls in seconds. |
OpenRL uses ports in the unallocated 23500–23509 range for its traffic between nodes. Other ports keep their usual values.
| Port | Component |
|---|---|
23500 |
API server (open-rl-api-server-service Service, container, and local default) |
23501 |
Sampling pool vllm serve HTTP endpoint on sampler pods, reached from the pool's dispatcher pod |
Sampling pools keep the sampler port they were created with. Before upgrading
a cluster from a release that served samplers on port 8000, finish active
runs and delete their Workloads and sampling pools, so that every pool is
created again on the new port.
The API server serves a read-only inventory of runs at
/api/v1/inspect/inventory, a run's logs at
/api/v1/inspect/logs?run_id=<id>, and the cluster dashboard at
/dashboard. /api/v1/inspect/activity shows which
Workloads held which GPUs in a time window, and /api/v1/inspect/query reads
those GPUs' DCGM metrics. See /docs for their fields.
placements lists the Workloads that hold GPUs now, from their status in
Kubernetes. Each entry has the node, pod, GPU UUIDs, placed_at in Unix
seconds, and the run_ids the Workload serves. When the server releases a
run's workers, it also saves each Workload's last placement to the Redis list
open_rl:placements:<runtime>. The list keeps the newest 200 records for seven
days.
Workers record each run's trainer ops, step count, request counts, samples and
failed samples in the API server's Redis for 7 days. Each worker also records
its own phase, GPU turns and settings.
/api/v1/inspect/runs/<id>/steps?last=&fields= returns the run's trainer ops
grouped by step, with their counts, failures, time and metrics.
/api/v1/inspect/runs returns each live run in one line, and ?ended=true
adds ended runs. /api/v1/inspect/runs/<id>/summary and
/api/v1/inspect/sessions/<id>/summary return the facts recorded about one run
or one client session, such as its pace, goodput, unanswered requests, failures
and SDK errors. See /docs for their fields.
| Env var | Default | What it does |
|---|---|---|
OPEN_RL_LOG_STORE |
unset | Where it reads logs. Unset turns log reads off. cloud-logging reads Cloud Logging in the project of the server's Google credentials. cloud-logging:<resource> reads that Cloud Logging resource instead, such as projects/<project>/locations/global/buckets/<bucket>/views/<view>. |
OPEN_RL_PROMETHEUS_URL |
unset | A Prometheus-compatible query endpoint with the DCGM exporter's metrics, such as an in-cluster Managed Service for Prometheus frontend at http://gmp-frontend:9090. Unset turns metric reads off. |
To read a run's client logs with pod=client, set the session tag
openrl.client_log_id=<id>. Ship the client's logs to the same store with the
label openrl_client=<id>. For a client pod, that is a pod label.
A bucket view only shows client logs when that bucket's sink routes them in, so
plain cloud-logging is the simplest choice when clients run outside the cluster.
The lora, fft and distributed-fft-timeslice bundles ship an NVIDIA DCGM
exporter (k8s/deploy/dcgm). GKE's managed DCGM exporter skips DRA node pools,
so without it those nodes report no GPU metrics.
The inspection API reads GPU metrics from the Prometheus-compatible endpoint in
OPEN_RL_PROMETHEUS_URL, such as the in-cluster Managed Service for Prometheus
frontend. It reads Cloud Logging as the API server's Kubernetes ServiceAccount,
open-rl-sa, through Workload Identity. Enable Workload Identity when you
create the cluster (--workload-pool=<project>.svc.id.goog). Enabling it on an
existing cluster replaces its nodes.
PRINCIPAL=principal://iam.googleapis.com/projects/<number>/locations/global/workloadIdentityPools/<project>.svc.id.goog/subject/ns/openrl-system/sa/open-rl-sa
gcloud projects add-iam-policy-binding <project> --role=roles/logging.viewer --member="$PRINCIPAL"Grant roles/monitoring.viewer the same way only if OPEN_RL_PROMETHEUS_URL
is Cloud Monitoring's own Prometheus API.
<number> is the project number. If you read logs through a log bucket view,
also grant roles/logging.viewAccessor on that view.