OmniRL
English | 简体中文
OmniRL is a distributed reinforcement learning framework built on Python, Ray, and PyTorch. It provides a common runtime for asynchronous sampling, replay and rollout storage, distributed learning, versioned weight synchronization, evaluation, logging, and checkpoint recovery. The framework includes 13 value-based and actor-critic algorithms for discrete and continuous control.
Architecture
Environment Collection ──► Samplers ──► Memory ──► Learners ──► WeightStore
▲ │
└───────── Algorithm Policy ◄─────────┘
Environment Evaluation ◄── Evaluators ◄── Algorithm Policy ◄── WeightStore
omnirl.runtimeorchestrates Ray actors for sampling, learning, evaluation, and versioned weight synchronization.omnirl.buffersprovides rollout, replay, and prioritized replay storage.omnirl.algorithmscontains algorithm-specific learners and inference policies.omnirl.networkscontains reusable network architectures for value-based and actor-critic algorithms.omnirl.envsowns environment construction, specifications, collection and evaluation loops, and metric aggregation.
Every algorithm package exposes the same Learner, Policy, and Memory interface. The runtime connects these components to the selected environment backend, keeping algorithm and environment implementations independent.
Implemented Algorithms
| Algorithm | Family | Action space |
|---|---|---|
| ✅ Deep Q-Network (DQN) | Value-based, off-policy | Discrete |
| ✅ Double Deep Q-Network (DDQN) | Value-based, off-policy | Discrete |
| ✅ Dueling Double Deep Q-Network (Dueling DQN) | Value-based, off-policy | Discrete |
| ✅ Prioritized Experience Replay Deep Q-Network (PER-DQN) | Value-based, off-policy | Discrete |
| ✅ Categorical 51-Atom Deep Q-Network (C51) | Distributional value-based, off-policy | Discrete |
| ✅ Quantile Regression Deep Q-Network (QR-DQN) | Distributional value-based, off-policy | Discrete |
| ✅ Advantage Actor-Critic (A2C) | Actor-critic, on-policy | Discrete / Continuous |
| ✅ Proximal Policy Optimization (PPO) | Actor-critic, on-policy | Discrete / Continuous |
| ✅ Importance Weighted Actor-Learner Architectures (IMPALA) | Actor-critic, off-policy | Discrete / Continuous |
| ✅ Deep Deterministic Policy Gradient (DDPG) | Actor-critic, off-policy | Continuous |
| ✅ Twin Delayed Deep Deterministic Policy Gradient (TD3) | Actor-critic, off-policy | Continuous |
| ✅ Soft Actor-Critic (SAC) | Actor-critic, off-policy | Discrete / Continuous |
| ✅ Truncated Quantile Critics (TQC) | Distributional actor-critic, off-policy | Continuous |
Installation
OmniRL supports Python 3.10–3.12. Create a virtual environment:
python -m venv .venv
Activate it on Windows:
.\.venv\Scripts\Activate.ps1
On Linux and macOS:
source .venv/bin/activate
Install OmniRL and its shared dependencies:
python -m pip install --upgrade pip
pip install omnirl-framework
The PyPI distribution is named omnirl-framework; the Python import package remains omnirl. Install the Gymnasium dependency:
pip install "gymnasium>=1.0,<2"
The BipedalWalker and CarRacing examples require the Box2D extra:
pip install "gymnasium[box2d]>=1.0,<2"
On Windows, torch>=2.11.0 is recommended to avoid Gloo initialization errors when training with multiple learners.
For GPU training, install the PyTorch build that matches the operating system and CUDA runtime, then verify CUDA availability:
python -c "import torch; print(torch.cuda.is_available())"
Getting Started
An OmniRL run uses two YAML files:
- The runner configuration defines the environment, Ray worker counts, device, seed, checkpoints, and logging.
- The agent configuration defines the algorithm module and its learner, memory, policy, and network parameters.
Parameter templates for all 13 algorithms are in examples/algorithms.
All three environment examples use PPO. Each directory contains ppo.yaml, train.yaml, and test.yaml:
| Example directory | Input | Action space | Network |
|---|---|---|---|
examples/cartpole/ |
State vector | Discrete | MLP |
examples/bipedal_walker/ |
State vector | Continuous | MLP |
examples/car_racing/ |
RGB image | Continuous | CNN |
These files and run.py are not included in the PyPI package, so first get the repository:
git clone https://github.com/MBer123/omnirl.git
cd omnirl
Start a single-machine PPO run on CartPole-v1:
python run.py --mode train --runner-config examples/cartpole/train.yaml --agent-config examples/cartpole/ppo.yaml
The example uses one CPU learner, one sampler, and one evaluator, with a target of 100 learner updates.
run.py connects to an existing Ray cluster when available; otherwise, it starts a local Ray runtime. For multi-node execution, start the head node:
ray start --head --port=6379
Join each worker, then launch run.py from the head node:
ray start --address=<head-ip>:6379
When runner.load_checkpoint is true, restarting the same training command resumes from checkpoint.ckpt in runner.ckpt_dir.
Outputs
Each run writes the following artifacts to runner.ckpt_dir:
checkpoint.ckpt: complete learner and optimizer state for resuming training.agent_<version>.pth: exported policy weights.log.csv: runtime, evaluation, and learner metrics.run_config.yaml: merged runner and agent configuration used by the run.
Evaluation
Set runner.ckpt_dir and runner.eval_model in the matching test.yaml, then run:
python run.py --mode test --runner-config examples/cartpole/test.yaml --agent-config examples/cartpole/ppo.yaml
The example loads agent_100.pth. If you change the training update target, update runner.eval_model accordingly.
The selected environment backend defines the evaluation metrics. The total number of evaluated episodes is evaluator.num_evaluators * evaluator.num_episodes_per_evaluator.
When a backend supports interactive rendering, set env.render_mode to human and evaluator.num_evaluators to 1 in the test configuration.
Adding an Algorithm
Create a package under omnirl/algorithms/on_policy/<name>/ or omnirl/algorithms/off_policy/<name>/ that exports the shared runtime interface:
from .learner import Learner
from .policy import Policy
from omnirl.buffers import ReplayBuffer as Memory
__all__ = ["Learner", "Memory", "Policy"]
The implementation should provide:
Learner: a class inheritingBaseLearnerfromomnirl.algorithms.base, wrapped as a Ray actor, that implements learning, checkpointing, and versioned weight access. Existing learners can be used as interface examples.Policy: a local inference class inheritingBasePolicyfromomnirl.algorithms.base, with deterministicchoose_action(observation)for a single observation and exploratorysample_action(observations)for a batch. Sampling inputs and outputs must retain the leading batch dimension, including when the batch size is 1.Memory: one of the buffers inomnirl.buffers, or a compatible new Ray actor.- Network definitions under
omnirl.networkswhen the algorithm needs a new architecture. - An agent YAML whose
agent.modulepoints toomnirl.algorithms.on_policy.<name>oromnirl.algorithms.off_policy.<name>and whosemodulessection supplies the constructor parameters.
The environment backend and distributed runtime do not need to be changed. Add module-interface and learner-update tests before adding the algorithm to the table above.
Adding an Environment Backend
Create a package under omnirl/envs/<name>/ that exports the shared runtime interface:
from .backend import EnvAdapter, EnvProvider
from .collection import CollectionLoop
from .evaluation import EvaluationLoop
__all__ = ["EnvAdapter", "EnvProvider", "CollectionLoop", "EvaluationLoop"]
The environment backend should provide:
EnvAdapter: inheritsBaseEnvfromomnirl.envs.baseto wrap an environment.reset()resets the environment,step()executes an action,render()renders the environment, andclose()releases resources.EnvProvider: inheritsBaseEnvProvider.build(env_config, role=None)creates an environment from configuration;get_spec(env_config)provides observation dimensions, action bounds, and related details.CollectionLoop: inheritsBaseCollectionLoop.run(policy, num_steps)collects the requested steps per environment and returns training data.EvaluationLoop: inheritsBaseEvaluationLoop.run(policy, num_episodes_per_evaluator)evaluates the requested episodes;aggregate(eval_infos)combines evaluator results. Thedefault_metricsclass attribute stores initial metric values.
Set the backend module in a runner configuration:
env:
module: omnirl.envs.gymnasium
id: CartPole-v1
render_mode: null
module selects the backend; the remaining env mapping is passed through unchanged.
Algorithms and runtime actors communicate only through this interface, so neither needs backend-specific imports or configuration fields.
Notes
learner.learner_devicesupportscpuandgpu. Multiple CPU learners use Gloo DDP; each GPU learner requires one GPU.- Under
sampler, setnum_sampler_gpusandnum_samplers_per_gputo configure the GPU count and processes per GPU. - Under
evaluator, setnum_evaluator_gpusandnum_evaluators_per_gputo configure the GPU count and processes per GPU. - Sampler/evaluator GPU counts default to zero. Processes beyond the configured capacity use CPU; with zero GPUs, all processes use CPU.
- Size
sampler.num_samplers,evaluator.num_evaluators, andlearner.num_learnersfor the available hardware. - Run the test suite with
python -m unittest discover -s tests -v. - OmniRL is a research framework. Multi-seed algorithm validation and scaling results reflect the current experimental conditions and do not constitute production guarantees.
License
Copyright 2026 Huang Chenbiao (MBer123).
OmniRL is licensed under the Apache License 2.0.
Metadata
Release files for omnirl-framework 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| omnirl_framework-0.7.0.tar.gz | 69.6 kB | Without provenance | Details for omnirl_framework-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| omnirl_framework-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for omnirl_framework-0.7.0-py3-none-any.whl |
Total release size: 175.0 kB
Release files / omnirl_framework-0.7.0.tar.gz
| Download URL | omnirl_framework-0.7.0.tar.gz |
|---|---|
| Size | 69.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0492ad1ac8047a44970d7a517396a922b4c5788fed85c37a065261be68b84da
|
|
BLAKE2b-256 checksum How to use checksums |
eccc23d2b902ffee8b07d106ae56c5b0e95689ede6079ddd45375bf1fd4df6a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.19
|
Release files / omnirl_framework-0.7.0-py3-none-any.whl
| Download URL | omnirl_framework-0.7.0-py3-none-any.whl |
|---|---|
| Size | 105.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4ab731cce3e71211cb3d50b17193ec683fbfc30d30225d9dfe20b7c90a832de3
|
|
BLAKE2b-256 checksum How to use checksums |
5feb66d7680e772027fd8643e4020f0cb8dce945349ce4ac6b7341606005ca90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.19
|
Security for omnirl-framework 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.