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:
| Extra | Packages installed | Use case |
|---|---|---|
peft | peft>=0.8.0 | LoRA and QLoRA training via PEFT |
vllm | vllm, fastapi, pydantic, aiohttp, uvicorn, and others | Fast online generation for RL-based trainers |
deepspeed | deepspeed>=0.14.4 | DeepSpeed ZeRO distributed training |
liger | liger-kernel>=0.7.0 | Liger fused kernels for faster and more memory-efficient training |
quantization | bitsandbytes | 4-bit and 8-bit quantization |
judges | openai>=1.23.2, llm-blender>=0.0.2 | LLM-based reward judges |
vlm | Pillow, torchvision, num2words | Vision-language model training |
math_verify | math-verify>=0.5.2 | Mathematical answer verification for reward functions |
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.