* start env servers for env group * bump * working reverse-text * correctly set log levels * use client configs everywhere + make val work * cycle through clients via inference pool * update model name * deprecate env worker * implement evals * deprecate evals+synthesize * deprecate serialization * use all clients for evals * simplify config * fix types and use inference pool for opd * bring back logging intercept * setup env client/server in prime-rl * externalize running env server * style * bring back rate limiter on scheduler * revert vf branch * back to custom branch * do not double asyncio * bring back eval * fix cpu tests * bump vf * add math group config * remove stop server call * add logs * remove last mentions of vf.State * deprecate some configs * more * remove eval + cpu integration tests * remove evals + synthesize configs * bump vf * fix branch with vlm cache * do not reference rollout status * use correct model name * stop teacher infer pool if setup * update changelog * deprecate server discovery (unused) * fix env id stripping * use updated model name for evals * strip env version on env server * remove server discovery tests * bump vf * do not fail if env server not yet up * add elastic sanity check * update docs * use extra env kwargs consistently across orch and env server * update math group config * update cfg * use dynamic model name in final evals * add extra_env_kwargs to changelog * resolve vf merge conflicts * assert lora name not None * fix unit tests * fix types * add hendrycks math sanity check * bump vf * do not double repeat eval inputs * do not duplicate eval inputs * lower avg@ * Initialize logger in env-server before install_env (#1743) install_env() calls get_logger() which requires the logger to be set up first. This was missing in env-server but present in orchestrator. * disable vf logging on orch * Fix elastic autoscaling: use base model for health checks (#1745) The health check was using `model_name` which gets updated to the LoRA adapter name after training starts. New inference servers only have the base model, so they would fail health checks and never get added to the pool. Store the original model name as `base_model_name` and use it for health checks, allowing new servers to be discovered and have the LoRA adapter loaded on them. --------- Co-authored-by: JannikSt <JannikSt@users.noreply.github.com> Co-authored-by: William Brown <williambrown97@gmail.com>
3.5 KiB
Logging
prime-rl uses loguru for logging with a global logger pattern. Logs are written to both console and files under {output_dir}/logs/. For RL training, we recommend streaming file logs into tmux panes (as set up by tmux.sh).
tmux helper (scripts/tmux.sh)
scripts/tmux.sh sets up a tmux session for RL runs with three panes (one per subprocess):
- Trainer: run
uv run rl ...here - Orchestrator: follows
{output_dir}/logs/orchestrator.stdout - Inference: follows
{output_dir}/logs/inference.stdout
Logger Architecture
setup_logger and get_logger
We use a singleton pattern with a module-level global logger instance (_LOGGER).
from prime_rl.utils.logger import setup_logger, get_logger
# At entrypoint - call ONCE
logger = setup_logger("info", log_file=Path("output/logs/my.log"))
# Anywhere else in codebase
logger = get_logger()
logger.info("Hello world")
How it works:
-
setup_logger(log_level, log_file)- Initializes the global logger exactly once:- Creates an isolated loguru
Loggerinstance (not the defaultloguru.logger) to prevent third-party code from hijacking our logs - Adds a stdout handler with colorized output
- Optionally adds a file handler (deletes existing file first)
- Raises
RuntimeErrorif called twice
- Creates an isolated loguru
-
get_logger()- Returns the global logger instance:- Raises
RuntimeErrorifsetup_loggerhasn't been called yet - Safe to call from any module after initialization
- Raises
-
reset_logger()- Resets the global logger toNone:- Used in subprocesses that inherit parent state (e.g., env workers)
- Used in tests between test cases
RL Log File Structure
For RL training, logs are organized by component:
| Component | Log Path | Description |
|---|---|---|
| RL (parent) | logs/rl.log |
Main process that spawns subprocesses |
| Inference | logs/inference.stdout |
vLLM inference server stdout/stderr |
| Orchestrator | logs/orchestrator.log |
Rollout generation, buffer, scheduling |
| Trainer | logs/trainer/rank_{N}.log |
Training process (one file per GPU rank) |
| Env Workers | logs/env_workers/{env_name}/worker_{N}.log |
Per-environment worker logs (optional) |
Per-Environment Logging
Environment are run via vf.EnvServer in separate processes. By default, each environment logs to a file in its run directory under {output_dir}/run_default/train/{env_name}.log and {output_dir}/run_default/eval/{env_name}.log. The log verbosity can be controlled with orchestrator.log.vf_level.
[orchestrator.log]
level = "debug" # Log level for prime-rl logger
vf_level = "info" # Log level for verifiers library
output_dir/
└── run_default/
└── train/
├── {env_name_1}.log
├── {env_name_2}.log
└── ...
└── eval/
├── {env_name_1}.log
├── {env_name_2}.log
└── ...
Torchrun
For multi-node training with torchrun, all ranks log simultaneously. To filter to master rank only:
uv run torchrun \
--local-ranks-filter 0 \
--nproc-per-node 8 \
...
You can also use torchrun's native log redirection:
uv run torchrun \
--local-ranks-filter 0 \
--nproc-per-node 8 \
--log-dir outputs/torchrun \
--redirects 3 \
--tee 3 \
...
This writes to outputs/torchrun/{rdzv_id}/attempt_0/{rank}/{stdout,stderr}.log.