Skip to content
This repository was archived by the owner on Apr 23, 2026. It is now read-only.

[DRAFT] Add vllm backend for ilab serve - #1276

Closed
alimaredia wants to merge 1 commit into
instructlab:mainfrom
alimaredia:vllm-serve
Closed

[DRAFT] Add vllm backend for ilab serve#1276
alimaredia wants to merge 1 commit into
instructlab:mainfrom
alimaredia:vllm-serve

Conversation

@alimaredia

Copy link
Copy Markdown
Contributor

Changes

Which issue is resolved by this Pull Request:
Resolves #1106

Description of your changes:

Initial support serving models with vllm as a backend. Further discussion on design is being tracked at #1106.

Signed-off-by: Ali Maredia <amaredia@redhat.com>
@mergify mergify Bot added testing Relates to testing ci-failure PR has at least one CI failure labels Jun 6, 2024
Comment thread requirements-vllm.txt
Comment on lines +1 to +6
# SPDX-License-Identifier: Apache-2.0

-r requirements.txt

# newer vllm does not serve Merlinite
vllm<0.4.3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of another requirements file, how about you use an optional dependency?

Add this to pyproject.toml

[project.optional-dependencies]
vllm = ["vllm<0.4.3"]

then you can install vllm support with pip install instructlab[vllm]

Comment thread requirements.txt
rouge-score>=0.1.2,<0.2.0
sentencepiece>=0.2.0,<0.3.0
tokenizers>=0.15.2,<0.16.0
tokenizers>=0.19.1,<0.20.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This break Intel Gaudi support. Is the version bump really required? Could you just add the higher version to the optional dependencies instead of main dependencies?

Comment thread requirements.txt
torch>=2.2.1,<3.0.0 ; python_version != '3.10'
tqdm>=4.66.2,<5.0.0
transformers>=4.30.0,<=4.38.2
transformers>=4.41.2,<5.0.0

@tiran tiran Jun 6, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem, this version bump also breaks Intel Gaudi support.

The optimum packages has transformers <4.39.0,>=4.38.0 ; extra == 'habana'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have filed huggingface/optimum#1895 with optimum and asked to lift the upper version bound of transformers. This will also allow us to bump the tokenizers version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got feedback on my feature request. The next versions of optimum and optimum-habana will support transformers >= 4.40.0, < 4.41.0. In the mean time, we have to support >=4.38.2.

Comment thread src/instructlab/lab.py
# pylint: disable=C0415
# Local
from .server import ServerException, server
from pathlib import PurePath

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to top-level import. Also why are you using PurePath instead of Path here? There is rarely a need to use PurePath except for special circumstances. See top level module docs of https://docs.python.org/3/library/pathlib.html

Comment thread src/instructlab/lab.py
host,
port,
if use_vllm or serve_safetensors:
import importlib.util

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to top-level import

Comment thread src/instructlab/lab.py
vllm_cmd = ["python", "-m", "vllm.entrypoints.openai.api_server", "--model", model_path]

if vllm_chat_template is not None:
vllm_cmd = vllm_cmd + vllm_chat_template.split()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vllm_cmd = vllm_cmd + vllm_chat_template.split()
vllm_cmd.extend(vllm_chat_template.split())

Comment thread src/instructlab/lab.py
vllm_cmd = vllm_cmd + vllm_chat_template.split()

if vllm_args is not None:
vllm_cmd = vllm_cmd + vllm_args.split()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vllm_cmd = vllm_cmd + vllm_args.split()
vllm_cmd.extend(vllm_args.split())

Comment thread src/instructlab/lab.py

vllm_cmd_str = " ".join(vllm_cmd)
ctx.obj.logger.info(f"vllm serving command is: {vllm_cmd_str}")
subprocess.run(args=vllm_cmd)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You either need to check the status of the return object or use some function like subprocess.check_call to check whether the call fails.

Comment thread src/instructlab/lab.py
ctx.obj.logger.info(f"vllm serving command is: {vllm_cmd_str}")
subprocess.run(args=vllm_cmd)
else:
# pylint: disable=C0415

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use human-readable short names instead of number constants. They are easier to recognize.

Suggested change
# pylint: disable=C0415
# pylint: disable=import-outside-toplevel

Comment thread src/instructlab/lab.py

ctx.obj.logger.info(f"Serving backend is llama-cpp")
ctx.obj.logger.info(
f"Using model '{model_path}' with {llama_cpp_gpu_layers} gpu-layers and {llama_cpp_max_ctx_size} max context size."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's considered bad practice to use f-strings with logging. You should use logging's string interpolation instead.

@leseb leseb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the initial shot, how about we freeze this for a moment and validate the design first? I'd like to avoid back and forth between the design change and the current code.

@alimaredia

Copy link
Copy Markdown
Contributor Author

closed for #1386

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ci-failure PR has at least one CI failure testing Relates to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ilab should support multiple serving backends

3 participants