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

Add vLLM backend - #1442

Merged
mergify[bot] merged 8 commits into
instructlab:mainfrom
leseb:add-vllm-backend
Jun 25, 2024
Merged

Add vLLM backend#1442
mergify[bot] merged 8 commits into
instructlab:mainfrom
leseb:add-vllm-backend

Conversation

@leseb

@leseb leseb commented Jun 21, 2024

Copy link
Copy Markdown
Contributor

See individual commits.

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the
    conventional commits.
  • Changelog updated with breaking and/or notable changes for the next minor release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

leseb and others added 2 commits June 21, 2024 15:47
This commit introduces the ability to configure and automatically detect
the backend for serving models in InstructLab. One new field, `backend`
has been added to the configuration and the CLI to allow users to
specify the backend. This field is optional.

Additionally, the commit includes the implementation of backend validation and
auto-detection based on the model file properties, specifically targeting GGUF
file format for now. The `serve` command has been updated to utilize these new
configurations and perform backend validation or auto-detection as required.

Unit tests for backend validation and changes to the configuration tests to
include the new fields are also part of this commit.

Co-authored-by: Ali Maredia <amaredia@redhat.com>
Signed-off-by: Sébastien Han <seb@redhat.com>
This commit refactors the backend selection and server initialization
process for both the generate and chat functionalities within the
application. The changes include:

- Abstracting the backend selection logic by utilizing the `backends`
  module, which dynamically determines the appropriate backend based on
  the configuration file or auto-detection if no configuration is set in
  the serve section of config.yaml (serve.backend)

- Encapsulating the conditional logic for checking if the selected
  backend is LLAMA

- Streamlining the exception handling for backend determination and
  server initialization, ensuring that any failures in these processes
  are clearly communicated to the user and result in a graceful exit.

These modifications enhance the code's structure, making it easier to
understand and extend in the future, especially as new backends or
initialization requirements are introduced.

Signed-off-by: Sébastien Han <seb@redhat.com>
@mergify mergify Bot added the testing Relates to testing label Jun 21, 2024
@leseb

leseb commented Jun 21, 2024

Copy link
Copy Markdown
Contributor Author

This contains everything related to the vLLM integration work.

@mergify mergify Bot added the ci-failure PR has at least one CI failure label Jun 21, 2024
tiran
tiran previously requested changes Jun 21, 2024

@tiran tiran 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.

The vLLM version on PyPI is limited to CUDA. AMD ROCm and Intel Gaudi needs different builds and different forks of vLLM. There is also a version conflict between vLLM and optimum-habana for Intel Gaudi.

I suggest to introduce a cuda optional dependencies and only install vLLM with pip install instructlab[cuda] for now.

@leseb
leseb force-pushed the add-vllm-backend branch from 522469e to e71d3bc Compare June 21, 2024 18:35
@mergify mergify Bot added ci-failure PR has at least one CI failure and removed ci-failure PR has at least one CI failure labels Jun 21, 2024
backends.py now holds the common functions to be used by all the
backends we will implements. These functions will be used to reduce code
duplication.
Now, the only supported backend 'llama-cpp' was reworked to make it of
these common functions.

Signed-off-by: Sébastien Han <seb@redhat.com>
@leseb
leseb force-pushed the add-vllm-backend branch from e71d3bc to c66d76b Compare June 21, 2024 18:53
@mergify mergify Bot removed the ci-failure PR has at least one CI failure label Jun 21, 2024
@leseb leseb mentioned this pull request Jun 21, 2024
5 tasks
@mergify mergify Bot added the ci-failure PR has at least one CI failure label Jun 21, 2024
@tiran

tiran commented Jun 21, 2024

Copy link
Copy Markdown
Contributor

vLLM does not support Python 3.12 and therefore does not have binaries for 3.12 on PyPI. It also has a really strange build system. vLLM build systems requires a PyTorch installation to build vLLM for a platform.

Basically vLLM only works out of the box on Linux x86_64 with CUDA on Python >=3.9 <= 3.11. Everything else is not working at the moment or cannot be expressed as a simple requirement in wheels.

@tiran

tiran commented Jun 21, 2024

Copy link
Copy Markdown
Contributor

And you also need to install a bunch of packages manually for each GPU arch, e.g. https://github.com/vllm-project/vllm/blob/main/requirements-cuda.txt for CUDA and https://github.com/vllm-project/vllm/blob/main/requirements-rocm.txt for ROCm.

Except do NOT install Ray. It's only needed for multi-node inference and is an even greater PITB to install correctly.

@leseb
leseb force-pushed the add-vllm-backend branch from c66d76b to f37e159 Compare June 21, 2024 19:38
@mergify mergify Bot added ci-failure PR has at least one CI failure and removed ci-failure PR has at least one CI failure labels Jun 21, 2024
@n1hility

Copy link
Copy Markdown
Contributor

And you also need to install a bunch of packages manually for each GPU arch, e.g. https://github.com/vllm-project/vllm/blob/main/requirements-cuda.txt for CUDA and https://github.com/vllm-project/vllm/blob/main/requirements-rocm.txt for ROCm.

Except do NOT install Ray. It's only needed for multi-node inference and is an even greater PITB to install correctly.

Previously we talked about making vllm an optional dep which people could pip install instructlab[vllm]. I think that probably makes sense still. wdyt @tiran ?

Comment thread src/instructlab/model/backends/backends.py
@nathan-weinberg
nathan-weinberg self-requested a review June 24, 2024 02:03
@leseb
leseb force-pushed the add-vllm-backend branch from f37e159 to 5fce33b Compare June 24, 2024 15:13
@mergify mergify Bot added ci-failure PR has at least one CI failure and removed ci-failure PR has at least one CI failure labels Jun 24, 2024
@russellb
russellb self-requested a review June 24, 2024 15:48
@leseb
leseb force-pushed the add-vllm-backend branch from 5fce33b to 52f76f8 Compare June 24, 2024 16:00
@mergify mergify Bot removed the ci-failure PR has at least one CI failure label Jun 24, 2024
@leseb
leseb force-pushed the add-vllm-backend branch from ee13202 to 0b98284 Compare June 25, 2024 14:28
@mergify mergify Bot removed the ci-failure PR has at least one CI failure label Jun 25, 2024
@leseb leseb mentioned this pull request Jun 25, 2024
@mergify mergify Bot added the one-approval PR has one approval from a maintainer label Jun 25, 2024
Comment thread CHANGELOG.md Outdated
Comment thread src/instructlab/model/backends/vllm.py Outdated
leseb added 3 commits June 25, 2024 21:43
InstructLab is now capable of running a vLLM server to serve models. The
backend is auto-detected based on that fact that model_path is a
directory.

Signed-off-by: Sébastien Han <seb@redhat.com>
When running `ilab model chat` or `ilab model generate`, the internal
backend that will be used can be vLLM (if no server is running through
    `ilab model serve`).
This code works also with the internal auto-detection backend as well as
setting the backend in the serve section of the config file.

Signed-off-by: Sébastien Han <seb@redhat.com>
The logs from the backend server is being redirected from stdout/stderr
to an instance of a logger. When this happens the logger would print the
current log python file name. We replace this with "serving_backend" to
indicate that the log is coming from inside the uvicorn process that
runs the backend (llama_cpp or vllm).

Signed-off-by: Sébastien Han <seb@redhat.com>
@leseb
leseb force-pushed the add-vllm-backend branch from 0b98284 to cbbcde0 Compare June 25, 2024 19:44
@mergify mergify Bot removed the one-approval PR has one approval from a maintainer label Jun 25, 2024
@mergify mergify Bot added the one-approval PR has one approval from a maintainer label Jun 25, 2024
@mergify mergify Bot removed the one-approval PR has one approval from a maintainer label Jun 25, 2024
@n1hility
n1hility dismissed tiran’s stale review June 25, 2024 19:57

Requested changes made

template = ""
# TODO: find the equivalent in vllm for eos_token and bos_token
eos_token = "<|endoftext|>"
bos_token = ""

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.

@leseb are eos_token and bos_token just here for the TODO? They don't seem to lead anywhere

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, just TODO.

@n1hility
n1hility removed the request for review from tiran June 25, 2024 20:02
@leseb leseb added the hold In-progress PR. Tag should be removed before merge. label Jun 25, 2024
@russellb
russellb removed their request for review June 25, 2024 20:10
@russellb russellb removed the hold In-progress PR. Tag should be removed before merge. label Jun 25, 2024
@mergify
mergify Bot merged commit 60685b6 into instructlab:main Jun 25, 2024
@leseb
leseb deleted the add-vllm-backend branch June 25, 2024 20:15
@cdoern

cdoern commented Jun 25, 2024

Copy link
Copy Markdown
Contributor

this probably should have come after #1370

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

Labels

testing Relates to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants