[Docker] Cache test dependencies before vLLM install (#51184)
Signed-off-by: mgoin <mgoin64@gmail.com> Co-authored-by: OpenAI Codex <codex@openai.com> Co-authored-by: OpenAI Codex <noreply@openai.com>
This commit is contained in:
co-authored by
OpenAI Codex
OpenAI Codex
parent
355a338b8f
commit
21c667aa64
+55
-6
@@ -568,6 +568,7 @@ RUN dnf install -y numactl-devel \
|
||||
ARG PYTORCH_NIGHTLY
|
||||
|
||||
# Install development dependencies
|
||||
COPY requirements/common.txt requirements/common.txt
|
||||
COPY requirements/lint.txt requirements/lint.txt
|
||||
COPY requirements/test/cuda.in requirements/test/cuda.in
|
||||
COPY requirements/test/cuda.txt requirements/test/cuda.txt
|
||||
@@ -593,7 +594,7 @@ RUN --mount=type=cache,target=/opt/uv/cache \
|
||||
#################### DEV IMAGE ####################
|
||||
#################### vLLM installation IMAGE ####################
|
||||
# image with vLLM installed
|
||||
FROM ${FINAL_BASE_IMAGE} AS vllm-base
|
||||
FROM ${FINAL_BASE_IMAGE} AS vllm-runtime-base
|
||||
|
||||
ARG CUDA_VERSION
|
||||
ARG PYTHON_VERSION
|
||||
@@ -790,6 +791,8 @@ RUN --mount=type=cache,target=/opt/uv/cache \
|
||||
# VLLM INSTALLATION (depends on build stage)
|
||||
# ============================================================
|
||||
|
||||
FROM vllm-runtime-base AS vllm-base
|
||||
|
||||
ARG PIP_INDEX_URL UV_INDEX_URL
|
||||
ARG PIP_EXTRA_INDEX_URL UV_EXTRA_INDEX_URL
|
||||
ARG PYTORCH_CUDA_INDEX_BASE_URL
|
||||
@@ -849,11 +852,8 @@ COPY benchmarks benchmarks
|
||||
COPY ./vllm/collect_env.py .
|
||||
#################### vLLM installation IMAGE ####################
|
||||
#################### TEST IMAGE ####################
|
||||
# image to run unit testing suite
|
||||
# note that this uses vllm installed by `pip`
|
||||
FROM vllm-base AS test
|
||||
|
||||
ADD . /vllm-workspace/
|
||||
# Stable dependencies for the unit testing image
|
||||
FROM vllm-runtime-base AS test-deps
|
||||
|
||||
ARG PYTHON_VERSION
|
||||
ARG TARGETPLATFORM
|
||||
@@ -861,6 +861,7 @@ ARG TARGETPLATFORM
|
||||
ARG PIP_INDEX_URL UV_INDEX_URL
|
||||
ARG PIP_EXTRA_INDEX_URL UV_EXTRA_INDEX_URL
|
||||
ARG PYTORCH_CUDA_INDEX_BASE_URL
|
||||
ARG PIP_KEYRING_PROVIDER UV_KEYRING_PROVIDER
|
||||
|
||||
# This timeout (in seconds) is necessary when installing some dependencies via uv since it's likely to time out
|
||||
# Reference: https://github.com/astral-sh/uv/pull/1694
|
||||
@@ -876,6 +877,7 @@ RUN apt-get update -y \
|
||||
ARG PYTORCH_NIGHTLY
|
||||
|
||||
# Install development dependencies (for testing)
|
||||
COPY requirements/common.txt requirements/common.txt
|
||||
COPY requirements/lint.txt requirements/lint.txt
|
||||
COPY requirements/test/cuda.in requirements/test/cuda.in
|
||||
COPY requirements/test/cuda.txt requirements/test/cuda.txt
|
||||
@@ -906,6 +908,53 @@ RUN --mount=type=cache,target=/opt/uv/cache \
|
||||
fi \
|
||||
fi
|
||||
|
||||
# image to run unit testing suite
|
||||
# note that this uses vllm installed by `pip`
|
||||
FROM test-deps AS test
|
||||
|
||||
ARG PYTHON_VERSION
|
||||
|
||||
ARG PIP_INDEX_URL UV_INDEX_URL
|
||||
ARG PIP_EXTRA_INDEX_URL UV_EXTRA_INDEX_URL
|
||||
ARG PYTORCH_CUDA_INDEX_BASE_URL
|
||||
ARG PIP_KEYRING_PROVIDER UV_KEYRING_PROVIDER
|
||||
|
||||
# We can specify the standard or nightly build of PyTorch
|
||||
ARG PYTORCH_NIGHTLY
|
||||
|
||||
# Install vLLM and EP kernel wheels after the stable test dependencies so
|
||||
# source-only changes do not invalidate the dependency layers above.
|
||||
COPY --from=base /workspace/torch_lib_versions.txt torch_lib_versions.txt
|
||||
COPY --from=build /workspace/dist/wheel.sha256 /tmp/vllm-wheel.sha256
|
||||
RUN --mount=type=bind,from=build,src=/workspace/dist,target=/vllm-workspace/dist \
|
||||
--mount=type=cache,target=/opt/uv/cache \
|
||||
if [ "${PYTORCH_NIGHTLY}" = "1" ]; then \
|
||||
echo "Installing torch nightly..." \
|
||||
&& uv pip install --system $(cat torch_lib_versions.txt | xargs) --pre \
|
||||
--index-url ${PYTORCH_CUDA_INDEX_BASE_URL}/nightly/cu$(echo $CUDA_VERSION | cut -d. -f1,2 | tr -d '.') \
|
||||
&& echo "Installing vLLM..." \
|
||||
&& uv pip install --system dist/*.whl --verbose \
|
||||
--extra-index-url ${PYTORCH_CUDA_INDEX_BASE_URL}/nightly/cu$(echo $CUDA_VERSION | cut -d. -f1,2 | tr -d '.'); \
|
||||
else \
|
||||
echo "Installing vLLM..." \
|
||||
&& uv pip install --system dist/*.whl --verbose \
|
||||
--extra-index-url ${PYTORCH_CUDA_INDEX_BASE_URL}/cu$(echo $CUDA_VERSION | cut -d. -f1,2 | tr -d '.'); \
|
||||
fi
|
||||
|
||||
# Pytorch now installs NVSHMEM, setting LD_LIBRARY_PATH
|
||||
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
|
||||
|
||||
COPY --from=build /tmp/ep_kernels_workspace/dist/wheels.sha256 /tmp/ep-kernels-wheels.sha256
|
||||
RUN --mount=type=bind,from=build,src=/tmp/ep_kernels_workspace/dist,target=/vllm-workspace/ep_kernels/dist \
|
||||
--mount=type=cache,target=/opt/uv/cache \
|
||||
uv pip install --system ep_kernels/dist/*.whl --verbose \
|
||||
--extra-index-url ${PYTORCH_CUDA_INDEX_BASE_URL}/cu$(echo $CUDA_VERSION | cut -d. -f1,2 | tr -d '.')
|
||||
|
||||
# See the matching comment in the vllm-base stage.
|
||||
ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib64:${LD_LIBRARY_PATH}
|
||||
|
||||
ADD . /vllm-workspace/
|
||||
|
||||
# install development dependencies (for testing)
|
||||
RUN --mount=type=cache,target=/opt/uv/cache \
|
||||
uv pip install --system -e tests/vllm_test_utils
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 398 KiB After Width: | Height: | Size: 344 KiB |
@@ -17,6 +17,9 @@ The edges of the build graph represent:
|
||||
|
||||
- `RUN --mount=(.\*)from=...` dependencies (with a dotted line and an empty diamond arrow head)
|
||||
|
||||
The `test-deps` stage branches from `vllm-runtime-base` so Git and the test
|
||||
requirements remain cached independently of per-commit vLLM wheels and source.
|
||||
|
||||
> <figure markdown="span">
|
||||
> { align="center" alt="query" width="100%" }
|
||||
> </figure>
|
||||
@@ -28,6 +31,7 @@ The edges of the build graph represent:
|
||||
> ```bash
|
||||
> dockerfilegraph \
|
||||
> -o png \
|
||||
> --concentrate \
|
||||
> --legend \
|
||||
> --dpi 200 \
|
||||
> --max-label-length 50 \
|
||||
@@ -47,6 +51,7 @@ The edges of the build graph represent:
|
||||
> --dpi 200 \
|
||||
> --max-label-length 50 \
|
||||
> --filename docker/Dockerfile \
|
||||
> --concentrate \
|
||||
> --legend
|
||||
> ```
|
||||
>
|
||||
|
||||
@@ -47,6 +47,7 @@ if printf '%s\n' "${FILES[@]}" | grep -q "^docker/Dockerfile$"; then
|
||||
--dpi 200 \
|
||||
--max-label-length 50 \
|
||||
--filename docker/Dockerfile \
|
||||
--concentrate \
|
||||
--legend
|
||||
|
||||
echo "Finding generated PNG file..."
|
||||
|
||||
Reference in New Issue
Block a user