Skip to main content

BravoRL

A modular, SOTA reinforcement learning framework built on PyTorch and Hydra, driven entirely by declarative YAML. Train any combination of algorithm, network architecture, and environment without writing code:

bravorl train --config /path/to/config.yaml runner.agent.learning_rate=0.0001

Installation

pip install -e .
# optional extras
pip install -e ".[wandb]"            # Weights & Biases logging
pip install -e ".[tensorboard]"      # TensorBoard logging
pip install -e ".[mujoco]"           # MuJoCo continuous-control environments
pip install -e ".[classic-control]"  # pygame, needed to *render* CartPole/Acrobot/Pendulum/... (not needed for training)

Quickstart

Two ready-to-run configs live in configs/:

# Discrete control, CPU, ~seconds: PPO on CartPole-v1
bravorl train --config configs/ppo_cartpole.yaml

# Continuous control PPO on HalfCheetah-v4 (needs the [mujoco] extra)
bravorl train --config configs/ppo_halfcheetah.yaml runner.device=cpu

Config files may live anywhere on disk -- they don't need to be inside the package. Any positional argument after --config is a Hydra dotlist override addressed by its path in the config (e.g. runner.total_timesteps=500000, runner.agent.clip_epsilon=0.1).

Training saves a checkpoint of the trained network once it finishes (see runner.checkpoint_path in the config, e.g. cartpole_checkpoint.pt; set it to null to disable). Watch the trained agent act with:

bravorl play --config configs/ppo_cartpole.yaml --checkpoint cartpole_checkpoint.pt

This opens the environment in render_mode="human" and runs 5 episodes by default (--episodes N to change that), acting deterministically (--stochastic to sample instead). It rebuilds the exact env/network/agent described by --config, so pass the same config the checkpoint was trained with -- only the checkpoint path changes.

Architecture

bravorl/
├── cli.py          # argparse <-> Hydra bridge (hydra.initialize_config_dir)
├── runner.py        # Trainer: instantiation + the env interaction loop
├── core/
│   ├── interfaces.py # cross-cutting ABCs (BaseLogger) and shared types
│   └── registry.py   # optional name -> class registries
├── algorithms/
│   ├── base.py       # BaseAlgorithm ABC
│   └── ppo.py         # PPO: GAE, clipped surrogate, clipped value loss
├── networks/
│   ├── base.py        # BaseNetwork ABC + shape-inference helpers
│   ├── mlp.py          # ActorCriticMLP (vector observations)
│   └── cnn.py           # ActorCriticCNN (image observations)
├── buffers/
│   ├── base.py          # BaseBuffer ABC
│   └── replay_buffer.py  # StandardReplayBuffer (on- and off-policy)
├── envs/
│   └── wrappers.py        # NormalizeObservation, ClipAction, RewardScaling, ...
└── utils/
    └── logger.py           # TensorBoardLogger, WandbLogger

Every component is instantiated from config via Hydra's _target_ mechanism -- there is no hardcoded registry lookup and no if env_id == "..." branching anywhere. Network input/output shapes are always inferred at runtime from env.observation_space / env.action_space.

The network-shaping problem, and how BravoRL solves it

A network needs to know the environment's observation/action shapes before it can be built, but a naive recursive Hydra instantiation would try to build agent.network before the environment even exists. Trainer sidesteps this by being instantiated with _recursive_=False (see cli.py) and then doing the instantiation itself, in the right order:

  1. env = instantiate(cfg.env)
  2. network = instantiate(cfg.agent.network, obs_space=env.observation_space, action_space=env.action_space)
  3. agent = instantiate(cfg.agent, network=network) -- the explicit network= kwarg overrides the (still un-instantiated) network: key in the config.

Extending BravoRL

  • New algorithm: subclass bravorl.algorithms.base.BaseAlgorithm, implement select_action, compute_loss and update. Set on_policy = True if your algorithm must consume rollouts in collection order (like PPO); leave it False for off-policy algorithms sampled randomly from a replay buffer.
  • New network: subclass bravorl.networks.base.BaseNetwork, implement forward and get_action_distribution.
  • New buffer: subclass bravorl.buffers.base.BaseBuffer, implement push, sample and __len__.

Point any config's _target_ at your new class's dotted path -- no other code needs to change.

Non-functional notes

  • Fully type-hinted, mypy-compliant.
  • Google-style docstrings throughout.
  • pytest tests/ runs a fast CPU smoke test that trains PPO on CartPole-v1 for a handful of steps end-to-end.

Metadata

Release files for bravorl 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bravorl 0.2.0
File Size Uploaded Provenance Actions
bravorl-0.2.0.tar.gz 26.3 kB With provenance Details for bravorl-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bravorl 0.2.0
File Interpreter ABI Platform Actions
bravorl-0.2.0-py3-none-any.whl Python 3 none any Details for bravorl-0.2.0-py3-none-any.whl

Total release size: 54.5 kB

Release files / bravorl-0.2.0.tar.gz

Download URL bravorl-0.2.0.tar.gz
Size 26.3 kB
Tags Source
SHA-256 checksum
How to use checksums
098bf60dc162b5b026557429c9fab82b0207d4d64f3ec2621d8e22a575b4fc6d
BLAKE2b-256 checksum
How to use checksums
e67f76ac8165c26f416a0e8aa30d5d8c1eb4f69c556f39ad5cef800464cd187c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Release files / bravorl-0.2.0-py3-none-any.whl

Download URL bravorl-0.2.0-py3-none-any.whl
Size 28.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c0d47c02c877d7d1d1dfc30fe36bcbc876131316119c6da256aef2b7169f5b5
BLAKE2b-256 checksum
How to use checksums
898dd14d085e3bbfd787d085484d0a08392bed4f55636780d6ab7deb82a56e56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

Security for bravorl 0.2.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bravorl-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page