Skip to content

Commit 7c174e0

Browse files
committed
📌 Pin vLLM version (#4122)
1 parent 05fd402 commit 7c174e0

File tree

11 files changed

+26
-18
lines changed

11 files changed

+26
-18
lines changed

docs/source/speeding_up_training.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ To speed up generation, you can use [vLLM](https://github.com/vllm-project/vllm)
1414
To use [vLLM](https://github.com/vllm-project/vllm), first install it using:
1515

1616
```bash
17-
pip install vllm
18-
```
19-
20-
or
21-
22-
```bash
23-
pip install "trl[vllm]"
17+
pip install trl[vllm]
2418
```
2519

2620
<hfoptions id="vllm examples">

docs/source/vllm_integration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
This document will guide you through the process of using vLLM with TRL for faster generation in online methods like GRPO and Online DPO. We first summarize a tl;dr on how to use vLLM with TRL, and then we will go into the details of how it works under the hood. Let's go! 🔥
44

5+
<Tip warning={true}>
6+
7+
TRL currently only supports vLLM versions `0.10.0`, `0.10.1`, and `0.10.2`. Please ensure you have one of these versions installed to avoid compatibility issues.
8+
9+
</Tip>
10+
511
## 🚀 How can I use vLLM with TRL to speed up training?
612

713
💡 **Note**: Resources required for this specific example: a single node with 8 GPUs.

examples/scripts/evals/judge_tldr.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
# /// script
1616
# dependencies = [
17-
# "trl",
18-
# "vllm",
17+
# "trl[vllm]",
1918
# ]
2019
# ///
2120

examples/scripts/rloo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414

1515
# /// script
1616
# dependencies = [
17-
# "trl",
17+
# "trl[vllm]",
1818
# "peft",
1919
# "math-verify",
2020
# "latex2sympy2_extended",
2121
# "trackio",
22-
# "vllm",
2322
# "kernels",
2423
# ]
2524
# ///

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test =
6464
vllm =
6565
# vLLM package does not yet support Python 3.13. These constraints can be lifted once support is added:
6666
# see https://github.com/vllm-project/vllm/pull/13164
67-
vllm>=0.10.0; python_version < "3.13"
67+
vllm>=0.10.0,<=0.10.2; python_version < "3.13"
6868
fastapi; python_version < "3.13"
6969
pydantic; python_version < "3.13"
7070
requests; python_version < "3.13"

trl/extras/vllm_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(
114114
if not is_requests_available():
115115
raise ImportError("requests is not installed. Please install it with `pip install requests`.")
116116
if not is_vllm_available():
117-
raise ImportError("vLLM is not installed. Please install it with `pip install vllm`.")
117+
raise ImportError("vLLM is not installed. Please install it with `pip install trl[vllm]`.")
118118

119119
self.session = requests.Session()
120120

trl/import_utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import importlib
1616
import os
17+
import warnings
1718
from itertools import chain
1819
from types import ModuleType
1920
from typing import Any
@@ -35,7 +36,7 @@
3536
_requests_available = _is_package_available("requests")
3637
_unsloth_available = _is_package_available("unsloth")
3738
_uvicorn_available = _is_package_available("uvicorn")
38-
_vllm_available = _is_package_available("vllm")
39+
_vllm_available, _vllm_version = _is_package_available("vllm", return_version=True)
3940
_vllm_ascend_available = _is_package_available("vllm_ascend")
4041
_weave_available = _is_package_available("weave")
4142

@@ -81,6 +82,15 @@ def is_uvicorn_available() -> bool:
8182

8283

8384
def is_vllm_available() -> bool:
85+
if _vllm_available and (
86+
version.parse(_vllm_version) < version.parse("0.10.0")
87+
or version.parse(_vllm_version) > version.parse("0.10.2")
88+
):
89+
warnings.warn(
90+
"TRL currently only supports vLLM versions `0.10.0`, `0.10.1`, and `0.10.2`. You have version "
91+
f"{_vllm_version} installed. We recommend to install one of these versions to avoid compatibility issues.",
92+
UserWarning,
93+
)
8494
return _vllm_available
8595

8696

trl/trainer/grpo_trainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def __init__(
480480
if not is_vllm_available():
481481
raise ImportError(
482482
"vLLM is not available and `use_vllm` is set to True. Please install vLLM with "
483-
"`pip install vllm` to use it."
483+
"`pip install [vllm]` to use it."
484484
)
485485

486486
if self.vllm_mode == "server":

trl/trainer/online_dpo_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class may differ from those in [`~transformers.TrainingArguments`].
293293
default=False,
294294
metadata={
295295
"help": "Whether to use vLLM for generating completions. Requires vLLM to be installed "
296-
"(`pip install vllm`)."
296+
"(`pip install trl[vllm]`)."
297297
},
298298
)
299299
vllm_model_impl: str = field(

trl/trainer/online_dpo_trainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def __init__(
484484
if not is_vllm_available():
485485
raise ImportError(
486486
"vLLM is not available and `use_vllm` is set to True. Please install vLLM with "
487-
"`pip install vllm` to use it."
487+
"`pip install trl[vllm]` to use it."
488488
)
489489

490490
if self.vllm_mode == "server":

0 commit comments

Comments
 (0)