Requirements
- Python 3.10 or later
- PyTorch (installed automatically as a transitive dependency via Transformers)
Install from PyPI
Install TRL usingpip or uv:
- pip
- uv
transformers, accelerate, and datasets.
Install from source
To use the latest unreleased features, install directly from the GitHub repository:Optional dependencies
TRL provides optional dependency groups for specific use cases. Install them using theextras syntax:
For example, to install TRL with PEFT and quantization support:
Developer install
If you want to contribute to TRL or run the test suite, install the development dependencies:dev extra includes testing tools (pytest, pytest-cov, pytest-xdist), code quality tools (pre-commit, hf-doc-builder), and most optional dependency groups.
vLLM is not included in the
dev extra by default due to CUDA compatibility constraints. Install it separately with pip install "trl[vllm]" if needed.