Utilities for Ray RLlib and related workflows. Includes experiment setup, callbacks, and JAX model utilities.
Project description
Ray Utilities
Quickstart
Train a PPO agent on CartPole-v1 with default settings and log to WandB after the experiment has finished:
python experiments/default_training.py --env CartPole-v1 --wandb offline+upload
Features
Many features are stand-alone and can be used independently. The main features include:
- JAX PPO for RLlib: A JAX-based implementation of the Proximal Policy Optimization (PPO) algorithm compatible with RLlib Algorithm.
- Ray + Optuna Grid Search + Optuna Pruners: Extends ray's
OptunaSearchto be compatible with RLlib and supports advanced pruners. - Experiment Framework: A base class for setting up experiments with dynamic parameters and parameter spaces, easily run via CLI and
ray.tune.Tuner. - Reproducible Environments: Reproducible environments for experiments using
ray.tuneby using a more sophisticated seeding mechanism. - Dynamic Parameter Tuning (WIP): Support for dynamic tuning of parameters during experiments.
ray.tune.grid_searchand Optuna pruners can work as aStopper. - Trial forking and Experiment Key Management: Enhanced support for trial forking and experiment key management, including parsing and restoring from forked checkpoints. This is especially designed for Population Based Training (PBT) and similar use cases and combined with WandB's support for fork logging.
What's New in v0.5.0
Highlights
-
Config File Integration: Config files can now be used seamlessly with the argument parser. Specify config files via
-cfgor--config_filesand all arguments in the file will be parsed as if passed on the command line. -
Flexible Tagging via CLI: Add tags directly from the command line using
--tag:tag_name(for a tag without value) or--tag:tag_name=value(for a tag with a value). Tags are automatically logged to experiment tracking tools (WandB, Comet, etc) and help organize and filter your results. -
Population Based Training (PBT) and Forking: The new
TopPBTTrialSchedulerenables advanced population-based training with quantile-based exploitation and flexible mutation strategies. Forked trials are automatically tracked and restored, and experiment lineage is visible in WandB/Comet dashboards. -
Advanced Comet and WandB Callbacks: Improved handling for online/offline experiment tracking, including robust upload and sync logic for offline runs.
-
Improved Log Formatting: All experiment outputs are now more human-readable and less nested. Training and evaluation results are flattened and easier to interpret.
-
Helper Utilities: New and improved helpers for experiment key generation, argument patching, and test utilities.
Other Features
- Exact Environment Step Sampling: Ensures accurate step counts in RLlib.
- Improved Logger Callbacks: Cleaner logs and better video handling for CSV, Tensorboard, WandB, and Comet.
- PPO Torch Learner with Gradient Accumulation: Efficient training with large batches.
Installation
Install from PyPI
pip install ray_utilities
Install latest version
Clone the repository and install the package using pip:
git clone https://github.com/Daraan/ray_utilities.git
cd ray_utilities
pip install .
Documentation (Work in Progress)
Visit https://ray-utilities.readthedocs.io/
Experiments
Pick What You Need - Customize Your Experiments
ExperimentSetupBase classes provide a modular way to parse your configuration,
setup trainables, their parameters and a Tuner, executed by run_tune.
Simple entry point:
# File: run_experiment.py
from ray_utilities import run_tune
from ray_utilities.setup import PPOSetup
if __name__ == "__main__":
# Take a default setup or adjust to your needs
with PPOSetup() as setup:
# The setup takes care of many settings passed in via the CLI
# but the config (an rllib.AlgorithmConfig) can be adjusted
# inside the code as well.
# Changes made in this with block are tracked for checkpoint reloads
setup.config.training(num_epochs=10)
results = run_tune(setup)
Using Config Files and Tags
You can specify experiment parameters in a config file and combine them with CLI arguments. This makes it easy to share and reproduce experiments.
python run_experiment.py -cfg experiments/models/mlp/default.cfg --tag:baseline --tag:lr=0.001
Tags are automatically logged to experiment tracking tools (WandB, Comet, etc) and help organize and filter your results.
Population Based Training (PBT) and Forking
The new TopPBTTrialScheduler enables advanced population-based training with quantile-based exploitation and flexible mutation strategies. Forked trials are automatically tracked and restored, and experiment lineage is visible in WandB/Comet dashboards.
See the documentation for a full example and advanced usage: Read the Docs
[!NOTE] It is recommended to subclass
AlgorithmSetuporExperimentSetupBaseto define your own setup. ExtendDefaultArgumentParserto add custom CLI arguments. Above'sPPOSetupis a very minimalistic example.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ray_utilities-0.6.0.tar.gz.
File metadata
- Download URL: ray_utilities-0.6.0.tar.gz
- Upload date:
- Size: 313.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f94691f6b66e6bbfb814bcc9962a74408b1598eef74acaf9d631e62295f17822
|
|
| MD5 |
d534b3be566884896e36ff7dad7f5f33
|
|
| BLAKE2b-256 |
50a65d7c383927a73fcf2ac1f3603dc8e79d501c51ef2f91c6c930b7bb92dbd2
|
Provenance
The following attestation bundles were made for ray_utilities-0.6.0.tar.gz:
Publisher:
publish.yml on Daraan/ray_utilities
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ray_utilities-0.6.0.tar.gz -
Subject digest:
f94691f6b66e6bbfb814bcc9962a74408b1598eef74acaf9d631e62295f17822 - Sigstore transparency entry: 612422277
- Sigstore integration time:
-
Permalink:
Daraan/ray_utilities@5019ce69e5be9338dcff493031ac64be645ac064 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/Daraan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5019ce69e5be9338dcff493031ac64be645ac064 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ray_utilities-0.6.0-py3-none-any.whl.
File metadata
- Download URL: ray_utilities-0.6.0-py3-none-any.whl
- Upload date:
- Size: 382.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33b2695f48f0d8438ec13ea18a946a5ca8c3e94d01cf8a4c4b80d15136cfe39a
|
|
| MD5 |
61a9d8d87bc765f7bc4577fb8c214a21
|
|
| BLAKE2b-256 |
4e5c0b076c99cb16b77e2c616d533b08315aec8b76602a5e3a5d214514d22bf5
|
Provenance
The following attestation bundles were made for ray_utilities-0.6.0-py3-none-any.whl:
Publisher:
publish.yml on Daraan/ray_utilities
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ray_utilities-0.6.0-py3-none-any.whl -
Subject digest:
33b2695f48f0d8438ec13ea18a946a5ca8c3e94d01cf8a4c4b80d15136cfe39a - Sigstore transparency entry: 612422325
- Sigstore integration time:
-
Permalink:
Daraan/ray_utilities@5019ce69e5be9338dcff493031ac64be645ac064 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/Daraan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5019ce69e5be9338dcff493031ac64be645ac064 -
Trigger Event:
release
-
Statement type: