Skip to content
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

Update build.py to build vLLM backend #6394

Merged
merged 16 commits into from
Oct 8, 2023
Merged
73 changes: 61 additions & 12 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ def create_dockerfile_buildbase(ddir, dockerfile_name, argmap):
ENTRYPOINT []
"""

# Install miniconda required for the DALI backend.
# Install miniconda required for the DALI and vllm backend.
if target_platform() != "windows":
df += install_miniconda(argmap["CONDA_VERSION"], target_machine())

Expand Down Expand Up @@ -1279,6 +1279,23 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
rm -rf /var/lib/apt/lists/*
"""

# Build conda environment for vllm backend
if "vllm" in backends:
df += install_miniconda(argmap["CONDA_VERSION"], target_machine)
vllm_conda_env_bash = "https://raw.githubusercontent.com/triton-inference-server/vllm_backend/main/tools/environment.yml"

# The last copy is needed so that user could run vllm models with unpacked
# conda env
df += """
# conda environment is required for the vllm backend
RUN conda install -y mamba -c conda-forge && \
wget "{vllm_conda_env_bash}" && \
mamba env create -f environment.yml && \
tanmayv25 marked this conversation as resolved.
Show resolved Hide resolved
cp /opt/conda/envs/vllm_env/lib/python3.10/site-packages/conda_pack/scripts/posix/activate /opt/conda/envs/vllm_env/bin/
""".format(
vllm_conda_env_bash=vllm_conda_env_bash
)

df += """
WORKDIR /opt/tritonserver
RUN rm -fr /opt/tritonserver/*
Expand Down Expand Up @@ -1768,6 +1785,29 @@ def backend_build(
cmake_script.blankln()


def backend_clone(
be,
clone_script,
tag,
install_dir,
github_organization,
):
repo_clone_dir = os.path.join(install_dir, "backends")

clone_script.commentln(8)
clone_script.comment(f"'{be}' backend")
clone_script.comment("Delete this section to remove backend from build")
clone_script.comment()
clone_script.mkdir(repo_clone_dir)
clone_script.cwd(repo_clone_dir)
clone_script.gitclone(backend_repo(be), tag, be, github_organization)
tanmayv25 marked this conversation as resolved.
Show resolved Hide resolved

clone_script.comment()
clone_script.comment(f"end '{be}' backend")
clone_script.commentln(8)
clone_script.blankln()


def repo_agent_build(
ra, cmake_script, build_dir, install_dir, repoagent_repo, repoagents
):
Expand Down Expand Up @@ -2620,17 +2660,26 @@ def enable_all():
else:
github_organization = FLAGS.github_organization

backend_build(
be,
cmake_script,
backends[be],
script_build_dir,
script_install_dir,
github_organization,
images,
components,
library_paths,
)
if be == "vllm":
backend_clone(
be,
cmake_script,
backends[be],
script_install_dir,
github_organization,
)
else:
backend_build(
be,
cmake_script,
backends[be],
script_build_dir,
script_install_dir,
github_organization,
images,
components,
library_paths,
)

# Commands to build each repo agent...
for ra in repoagents:
Expand Down