-
Notifications
You must be signed in to change notification settings - Fork 5
Upgrade vLLM to v0.16.0 #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5d5a84e
e128a6e
6fc6cad
c04e5c3
1d0be9e
1ca770d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,7 +152,7 @@ def wrapper(self: VLLM, *args: tuple, **kwargs: dict) -> Callable: | |
|
|
||
| self.llm = LLM(self.model_name, **self.model_kwargs) | ||
| if self.model_limit_tokens == "default": | ||
| self.model_limit_tokens = self.llm.llm_engine.get_model_config().max_model_len | ||
| self.model_limit_tokens = self.llm.llm_engine.model_config.max_model_len | ||
| return method(self, *args, **kwargs) | ||
|
|
||
| return wrapper | ||
|
|
@@ -306,7 +306,7 @@ def _batch_compute_log_probs( | |
| prefix + continuation for prefix, continuation in zip(batch_prefix_ids, batch_continuation_ids) | ||
| ] | ||
|
|
||
| max_length = self.llm.llm_engine.get_model_config().max_seq_len_to_capture | ||
| max_length = self.llm.llm_engine.model_config.max_model_len | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| stride = stride or max_length // 2 | ||
| if not (0 < stride < max_length): | ||
| msg = f"stride must be in (0, {max_length}), but got {stride}" | ||
|
|
@@ -315,7 +315,7 @@ def _batch_compute_log_probs( | |
|
|
||
| from vllm import RequestOutput, SamplingParams | ||
| from vllm.inputs import TokensPrompt | ||
| from vllm.sequence import Logprob | ||
| from vllm.logprobs import Logprob | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| sampling_params = SamplingParams(temperature=0.0, max_tokens=1, prompt_logprobs=1) | ||
|
|
||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,34 +29,14 @@ def chat_lm() -> VLLM: | |
| model_kwargs={ | ||
| "seed": 42, | ||
| "gpu_memory_utilization": 0.1, | ||
| "max_model_len": 2048, | ||
| "enforce_eager": True, | ||
| "disable_custom_all_reduce": True, | ||
| }, | ||
| tokenizer_kwargs={"use_fast": False}, | ||
| ) | ||
| yield llm | ||
| from vllm.distributed.parallel_state import cleanup_dist_env_and_memory | ||
|
|
||
| cleanup_dist_env_and_memory() | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def chat_lm_with_system_message() -> VLLM: | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know why this function was originally placed here, but since it was causing errors, I moved it to |
||
| llm = VLLM( | ||
| model="sbintuitions/tiny-lm-chat", | ||
| model_kwargs={ | ||
| "seed": 42, | ||
| "gpu_memory_utilization": 0.1, | ||
| "enforce_eager": True, | ||
| "disable_custom_all_reduce": True, | ||
| }, | ||
| tokenizer_kwargs={"use_fast": False}, | ||
| system_message="You are a helpful assistant.", | ||
| ) | ||
| yield llm | ||
| from vllm.distributed.parallel_state import cleanup_dist_env_and_memory | ||
|
|
||
| cleanup_dist_env_and_memory() | ||
| llm.cleanup_resources() | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not is_vllm_enabled(), reason="vllm library is not installed") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,22 +14,20 @@ | |
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def chat_lm() -> Generator[VLLM, None, None]: | ||
| def chat_lm() -> VLLM: | ||
| llm = VLLM( | ||
| model="sbintuitions/tiny-lm-chat", | ||
| model_kwargs={ | ||
| "seed": 42, | ||
| "gpu_memory_utilization": 0.1, | ||
| "max_model_len": 2048, | ||
| "enforce_eager": True, | ||
| "dtype": "float32", | ||
| "disable_custom_all_reduce": True, | ||
| }, | ||
| tokenizer_kwargs={"use_fast": False}, | ||
| ) | ||
| yield llm | ||
| from vllm.distributed.parallel_state import cleanup_dist_env_and_memory | ||
|
|
||
| cleanup_dist_env_and_memory() | ||
| llm.cleanup_resources() | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
|
|
@@ -39,14 +37,29 @@ def chat_lm_qwen() -> Generator[VLLM, None, None]: | |
| model_kwargs={ | ||
| "seed": 42, | ||
| "gpu_memory_utilization": 0.1, | ||
| "max_model_len": 2048, | ||
| }, | ||
| ) | ||
| yield llm | ||
| llm.cleanup_resources() | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def chat_lm_with_system_message() -> VLLM: | ||
| llm = VLLM( | ||
| model="sbintuitions/tiny-lm-chat", | ||
| model_kwargs={ | ||
| "seed": 42, | ||
| "gpu_memory_utilization": 0.1, | ||
| "max_model_len": 2048, | ||
| "enforce_eager": True, | ||
| "disable_custom_all_reduce": True, | ||
| }, | ||
| tokenizer_kwargs={"use_fast": False}, | ||
| system_message="You are a helpful assistant.", | ||
| ) | ||
| yield llm | ||
| from vllm.distributed.parallel_state import cleanup_dist_env_and_memory | ||
|
|
||
| cleanup_dist_env_and_memory() | ||
| llm.cleanup_resources() | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
|
|
@@ -57,17 +70,15 @@ def chat_lm_for_tool_calling() -> Generator[VLLM, None, None]: | |
| model_kwargs={ | ||
| "seed": 42, | ||
| "gpu_memory_utilization": 0.1, | ||
| "max_model_len": 2048, | ||
| "enforce_eager": True, | ||
| "dtype": "float32", | ||
| "disable_custom_all_reduce": True, | ||
| }, | ||
| tokenizer_kwargs={"use_fast": False}, | ||
| tool_parser=tool_parser, | ||
| ) | ||
| yield llm | ||
| from vllm.distributed.parallel_state import cleanup_dist_env_and_memory | ||
|
|
||
| cleanup_dist_env_and_memory() | ||
| llm.cleanup_resources() | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
|
|
@@ -77,24 +88,38 @@ def hf_lm(model_name: str = "sbintuitions/tiny-lm-chat") -> HuggingFaceLM: | |
| ) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def hf_lm_qwen(model_name: str = "Qwen/Qwen3-0.6B-Base") -> HuggingFaceLM: | ||
| return HuggingFaceLM( | ||
| model=model_name, model_kwargs={"torch_dtype": "float32"}, default_gen_kwargs={"temperature": 0.0} | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not is_vllm_enabled(), reason="vllm library is not installed") | ||
| @pytest.mark.parametrize("chat_lm_name", ["chat_lm", "chat_lm_qwen"]) | ||
| @pytest.mark.parametrize( | ||
| ("chat_lm_name", "hf_lm_name"), | ||
| [ | ||
| ("chat_lm", "hf_lm"), | ||
| ("chat_lm_qwen", "hf_lm_qwen"), | ||
| ], | ||
| ) | ||
| def test_batch_compute_log_probs_approximates_hf_lm( | ||
| request: pytest.FixtureRequest, | ||
| chat_lm_name: str, | ||
| hf_lm: HuggingFaceLM, | ||
| hf_lm_name: str, | ||
| ) -> None: | ||
| chat_lm = request.getfixturevalue(chat_lm_name) | ||
| hf_lm = request.getfixturevalue(hf_lm_name) | ||
| prefix_list = ["それは正しい日本語ですか?"] | ||
| text_list = ["これは正しい日本語です。"] | ||
|
|
||
| vllm_log_probs = chat_lm.compute_log_probs(text_list) | ||
| hf_log_probs = hf_lm.compute_log_probs(text_list) | ||
| assert vllm_log_probs == pytest.approx(hf_log_probs, abs=1e-2) | ||
| assert vllm_log_probs == pytest.approx(hf_log_probs, abs=0.5) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that differences of this magnitude can occur depending on the seed (or the environment), so I widen the acceptable tolerance range. |
||
|
|
||
| vllm_log_probs = chat_lm.compute_log_probs(text_list, prefix_list=prefix_list) | ||
| hf_log_probs = hf_lm.compute_log_probs(text_list, prefix_list=prefix_list) | ||
| assert vllm_log_probs == pytest.approx(hf_log_probs, abs=1e-2) | ||
| assert vllm_log_probs == pytest.approx(hf_log_probs, abs=0.5) | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not is_vllm_enabled(), reason="vllm library is not installed") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vllm-project/vllm#26427