Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
RelayRL Framework
Core Rust Library & Python Bindings for RelayRL
Platform Support: RelayRL runs on MacOS, Linux, and Windows (x86_64). Some dependencies may require additional setup on Windows.
Warning:
This is a prototype and is unstable during training.
For general usage and project overview, see the root README.
Overview
The relayrl_framework
crate provides the core infrastructure for distributed RL experiments, including:
- High-performance agent and training server implementations (gRPC & ZMQ)
- Core RL data structures (actions, trajectories, configs)
- Python bindings via PyO3 for seamless integration with Python RL algorithms
- Utilities for configuration, logging, and benchmarking
Default Rust Usage Example
use RelayRLAgent;
use TrainingServer;
use PathBuf;
use ;
use tokio;
async
Default Python Usage Example
# Start a training server (REINFORCE, discrete, CartPole)
=
# Create an agent and interact with the environment
=
# Example: Request an action from the agent
= # Should be a numpy array or torch tensor in real use
= # Should be a numpy array or torch tensor
= 0.0
=
=
More Explanatory Tutorial
Framework Requirements:
- Python Algorithms: The framework requires Python RL algorithms to be implemented and provided
- TorchScript Models: Algorithms must export their models as TorchScript for deployment
- Custom Algorithm Support: Custom algorithms can be integrated via configuration parameters
Building & Development
Prerequisites
- Supported Platforms: MacOS, Linux, Windows (x86_64)
- Rust (latest stable recommended)
- Python 3.8+
- PyTorch 2.5.1
- maturin (for building Python bindings)
- Protobuf compiler (
protoc
) for gRPC
Build the Rust Library
Build & Install Python Bindings
From the relayrl_framework
directory:
This will build the Rust library and install the Python bindings into your current environment.
Python Algorithms
Included Algorithms
Currently, the framework includes:
- REINFORCE with baseline value functions
- REINFORCE without baseline value functions
Custom Algorithm Implementation
Custom algorithms can be implemented and integrated into the framework. Your algorithm must:
- Inherit from BaseAlgorithm: Extend the
AlgorithmAbstract
class - Export Required Methods: Use
@torch.jit.export
annotations for critical methods - Implement Core Interface: Provide
step
,get_obs_dim
, andget_act_dim
methods
Required TorchScript Exports
Your algorithm's model must export these methods via @torch.jit.export
:
=
=
# Your network architecture here
"""Execute one step of the policy"""
# Your inference logic here
=
=
=
return ,
"""Return observation dimension"""
return
"""Return action dimension"""
return
Algorithm Class Structure
# Load configuration
=
=
=
# Initialize your model
=
"""Save model as TorchScript"""
=
"""Process received trajectory and return True if training should occur"""
# Your training logic here
return
Using Custom Algorithms
Configuration
Specify custom algorithms in your relayrl_config.json
:
Server Initialization
# Initialize server with custom algorithm
=
Agent Initialization
# Initialize agent with custom algorithm
=
Running Benchmarks
Benchmarks are provided in the benches/
directory:
You can also use the provided shell scripts in scripts/
for profiling and release builds.
Development Notes
- Python Bindings:
ExposeRelayRLAction
,RelayRLTrajectory
,ConfigLoader
, and agent/server classes to Python. - Configuration:
Use JSON files to specify experiment parameters, network settings, and logging options. - Algorithm Integration:
Custom algorithms must be properly structured with TorchScript exports and inherit from the base algorithm class.
Limitations
- Single-Agent Focus:
The framework is designed for single-agent RL. Multi-agent support is not natively implemented, but you may launch multiple agent and training server processes for experimentation. - Prototype Status:
The framework is unstable during training and is under active development. Expect breaking changes and incomplete features. - Python Algorithm Requirement:
The framework requires Python algorithms to be implemented and provided - it does not include built-in algorithms beyond the basic REINFORCE implementations.
Contributing
Contributions are welcome! Please open issues or pull requests for bug reports, feature requests, or improvements.