Skip to main content

A lightweight reinforcement learning framework that integrates seamlessly into your codebase, empowering developers to focus on algorithms with minimal intrusion.

Project description

RLite

🚀 Quick start🌰 Examples🍲 Recipes📚 Docs

A lightweight RL framework with PyTorch-like interfaces.

Features

  • FSDP2 and FSDP support for training.
  • vLLM support for inference.
  • ray support for resource management.
  • Easy to learn and use. Most interfaces are kept the same as Torch, with parallel engine working seamlessly behind the scenes.
  • Recipes that reproduce SOTA results with a single self-contained python script.

Installation

pip install pyrlite
Advanced installation options

We recommend using conda to manage our computation environment.

  1. Create a conda environment:
conda create -n rlite python==3.12
conda activate rlite
  1. Install common dependencies
# install vllm
pip install vllm accelerate

# flash attention 2 (make sure you have 64 CPU cores)
MAX_JOBS=64 pip install flash-attn --no-build-isolation

# Install fashinfer for faster inference
pip install flashinfer-python==0.2.2.post1 -i https://flashinfer.ai/whl/cu124/torch2.6
  1. Install rlite
git clone https://github.com/rlite-project/RLite.git
cd RLite; pip install -e .

Recipes

We use recipes as examples for reproducing SOTA RL methods. Featured recipes

Programming Model

Programming Model

In RLite, users mainly work with Engines, which is a handler that takes the input from the main process, organizes the tasks and sends to the workers. The engine may have multiple Executors, each holding a full set of model weights. Both Engines and Executors reside in the main process. The Workers are the units that actually perform computational tasks, with each Worker corresponding to a GPU. Conversely, a single GPU can be associated with multiple Workers, which can use the GPU in a time-multiplexed manner.

Key Interfaces

RLite provide minimal interfaces that are

  • easy to learn: most interfaces resembles the behavior of PyTorch.
  • super flexible: interfaces are independent and can be used seperately. This allows inference without training, e.g. evaluation tasks, or training without inference, e.g. SFT and DPO.
  • super powerful: the interfaces combined together allows reproduction of SOTA RL results.
  • highly extensible: the interfaces allows extensions for fancy features such as other train/inference backends, streaming generations for multi-turn use cases, asynchronized workers for overlapping time-consuming operations.

Inference

Inference Example

Train

Train Example

Offload/Reload/Discard Weights

Device Example

Synchronize Weights

Weight Sync

Contributing

Developer's guide.

Write code that you would like to read again.

We use pre-commit and git cz to sanitize the commits. You can run pre-commit before git cz to avoid repeatedly input the commit messages.

pip install pre-commit
# Install pre-commit hooks
pre-commit install
pre-commit install --hook-type commit-msg
# Install this emoji-style tool
sudo npm install -g git-cz --no-audit --verbose --registry=https://registry.npmmirror.com

# Install rlite
pip install -e ".[dev]"
Code Style
  • Single line code length is 99 characters, comments and documents are 79 characters.
  • Write unit tests for atomic capabilities to ensure that pytest does not throw an error.

Run pre-commit to automatically lint the code:

pre-commit run --all-files
Run Unit Tests:
# Only run tests
pytest

# Run tests and output test code coverage report
pytest --cov=rlite

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

pyrlite-0.1.2.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrlite-0.1.2-py3-none-any.whl (57.4 kB view details)

Uploaded Python 3

File details

Details for the file pyrlite-0.1.2.tar.gz.

File metadata

  • Download URL: pyrlite-0.1.2.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for pyrlite-0.1.2.tar.gz
Algorithm Hash digest
SHA256 eb115c1761f55678f53352ef2a71f918dd54726f6bd331449a5c1bc1ffd52bc5
MD5 928d8d473f168dcdfe51b6ce03c376d9
BLAKE2b-256 be0b25d13125ba4dc5296c0d5b07a90d1b77ab93b37fef84d55fafda3c8e12be

See more details on using hashes here.

File details

Details for the file pyrlite-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyrlite-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 57.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for pyrlite-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ce4b763d7d4fb94d38f0daffdfaaf16d915745af84a9ce57bcb86352ed11f23c
MD5 98f2adebd9ba605ad0a2250062176168
BLAKE2b-256 f8698ec86e11e0cfe9a97cd15dd89a42af4c01534e77616457747f8abe04b13f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page