diff --git a/docker/Dockerfile b/docker/Dockerfile index 1679ae433f..39ecdcd68e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 diff --git a/docs/assets/contributing/dockerfile-stages-dependency.png b/docs/assets/contributing/dockerfile-stages-dependency.png index 46da6142a7..510bf7e2b1 100644 Binary files a/docs/assets/contributing/dockerfile-stages-dependency.png and b/docs/assets/contributing/dockerfile-stages-dependency.png differ diff --git a/docs/contributing/dockerfile/dockerfile.md b/docs/contributing/dockerfile/dockerfile.md index 14184b9693..38e5c9a17b 100644 --- a/docs/contributing/dockerfile/dockerfile.md +++ b/docs/contributing/dockerfile/dockerfile.md @@ -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. + >
> ![](../../assets/contributing/dockerfile-stages-dependency.png){ align="center" alt="query" width="100%" } >
@@ -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 > ``` > diff --git a/tools/pre_commit/update-dockerfile-graph.sh b/tools/pre_commit/update-dockerfile-graph.sh index dc2b263014..3ed546db51 100755 --- a/tools/pre_commit/update-dockerfile-graph.sh +++ b/tools/pre_commit/update-dockerfile-graph.sh @@ -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..."