From e68fb75b250e33f013162582ece39e766a424df8 Mon Sep 17 00:00:00 2001 From: Hongxia Yang <62075498+hongxiayang@users.noreply.github.com> Date: Mon, 17 Aug 2026 17:58:48 -0400 Subject: [PATCH] [ROCm][AMD][Installation] add LMCache kv-connector installation and runtime packages to docker image (#51208) Signed-off-by: Hongxia Yang Signed-off-by: Andreas Karatzas Co-authored-by: Andreas Karatzas --- .buildkite/release-pipeline.yaml | 1 + .buildkite/scripts/ci-bake-rocm.sh | 2 +- docker/Dockerfile.rocm | 87 +++++++++++++++++++++++++++++- 3 files changed, 88 insertions(+), 2 deletions(-) diff --git a/.buildkite/release-pipeline.yaml b/.buildkite/release-pipeline.yaml index 7b9cac7b52..1dd8f0146c 100644 --- a/.buildkite/release-pipeline.yaml +++ b/.buildkite/release-pipeline.yaml @@ -906,6 +906,7 @@ steps: --build-arg SCCACHE_BUCKET_NAME=vllm-build-sccache \ --build-arg SCCACHE_REGION_NAME=us-west-2 \ --build-arg SCCACHE_S3_NO_CREDENTIALS=0 \ + --build-arg INSTALL_LMCACHE=true \ --tag public.ecr.aws/q9t5s3a7/vllm-release-repo:$${BUILDKITE_COMMIT}-rocm \ --target vllm-openai \ --progress plain \ diff --git a/.buildkite/scripts/ci-bake-rocm.sh b/.buildkite/scripts/ci-bake-rocm.sh index 45e45cf33a..1e14311314 100644 --- a/.buildkite/scripts/ci-bake-rocm.sh +++ b/.buildkite/scripts/ci-bake-rocm.sh @@ -17,7 +17,7 @@ DEFAULT_REPO_SLUG="vllm-project/vllm" DEFAULT_CI_HCL_SOURCE="docker/ci-rocm.hcl" DEFAULT_CI_BASE_CONTENT_FILES=".dockerignore requirements/common.txt requirements/rocm.txt requirements/test/rocm.txt tools/install_torchcodec_rocm.sh tools/install_protoc.sh rust-toolchain.toml tests/vllm_test_utils" DEFAULT_CI_BASE_DOCKERFILE="docker/Dockerfile.rocm" -DEFAULT_CI_BASE_DOCKERFILE_STAGES="base rust_toolchain_input_0 rust-toolchain-input rust-toolchain build_nixl build_rocshmem build_deepep mori_base ci_base" +DEFAULT_CI_BASE_DOCKERFILE_STAGES="base rust_toolchain_input_0 rust-toolchain-input rust-toolchain build_nixl lmcache_source build_lmcache build_rocshmem build_deepep mori_base ci_base" DEFAULT_CI_BASE_METADATA_VERSION="3" # ROCm CI forces REMOTE_VLLM=0, so content identity covers only the selected # local-source stages rather than unreachable remote-fetch alternatives. diff --git a/docker/Dockerfile.rocm b/docker/Dockerfile.rocm index d3504d1a3d..0487c0c916 100644 --- a/docker/Dockerfile.rocm +++ b/docker/Dockerfile.rocm @@ -6,6 +6,7 @@ ARG COMMON_WORKDIR=/app ARG BASE_IMAGE=rocm/vllm-dev:base ARG CI_BASE_IMAGE=rocm/vllm-dev:ci_base ARG ROCM_TRITON_KERNELS_COMMIT=0f380657dbf3ee86eb57558ff71df24f03b5d4e7 +ARG INSTALL_LMCACHE=false # NIC backend for MoRI RDMA support. # By default (all), drivers and userspace libraries for all supported NIC types # (ainic and bnxt) are installed; MoRI selects the appropriate one at runtime. @@ -471,6 +472,71 @@ RUN cd /opt/nixl && \ /tmp/nixl_wheels/repaired/*.whl && \ cp /tmp/nixl_wheels/repaired/*.whl /app/install +# Fetch and verify pinned LMCache source. +FROM base AS lmcache_source +ARG LMCACHE_REPO="https://github.com/LMCache/LMCache.git" +ARG LMCACHE_REF="140819c9d57a975dbc5678a6459a218e544cb58b" +ARG LMCACHE_VERSION="0.5.3" + +# Remove NVIDIA-only dependencies and accept the release image's NumPy version. +RUN printf '%s\n' "${LMCACHE_REF}" | grep -Eq '^[0-9a-f]{40}$' \ + && git clone --depth=1 --branch "v${LMCACHE_VERSION}" \ + "${LMCACHE_REPO}" /app/lmcache \ + && test "$(git -C /app/lmcache rev-parse HEAD)" = "${LMCACHE_REF}" \ + && test "$(grep -Ec '^(cufile-python|nvtx)([<=>[:space:]]|$)' \ + /app/lmcache/requirements/common.txt)" -eq 2 \ + && test "$(grep -Fxc 'numpy<=2.2.6' \ + /app/lmcache/requirements/common.txt)" -eq 1 \ + && sed -i -E \ + -e '/^(cufile-python|nvtx)([<=>[:space:]]|$)/d' \ + -e 's/^numpy<=2\.2\.6$/numpy<=2.3.5/' \ + /app/lmcache/requirements/common.txt \ + && rm -rf /app/lmcache/.git + +FROM base AS build_lmcache +COPY --from=lmcache_source \ + /app/lmcache/requirements/build.txt /tmp/lmcache-build-requirements.txt +RUN --mount=type=cache,id=vllm-rocm-uv,target=/root/.cache/uv \ + uv pip install --system -r /tmp/lmcache-build-requirements.txt + +ARG LMCACHE_VERSION="0.5.3" +ARG LMCACHE_ROCM_ARCH="gfx942;gfx950" +ARG USE_SCCACHE + +COPY --from=lmcache_source /app/lmcache /app/lmcache +WORKDIR /app/lmcache + +RUN --mount=type=cache,id=vllm-rocm-ccache,target=/root/.cache/ccache \ + set -eu; \ + printf '%s\n' "${LMCACHE_ROCM_ARCH}" \ + | grep -Eq '^gfx[0-9a-z]+(;gfx[0-9a-z]+)*$'; \ + offload_flags="$(printf '%s' "${LMCACHE_ROCM_ARCH}" \ + | sed 's/;/ --offload-arch=/g; s/^/--offload-arch=/')"; \ + if [ "${USE_SCCACHE:-0}" = "1" ]; then \ + export HIP_CLANG_PATH=/opt/sccache-wrappers; \ + fi; \ + mkdir -p /app/install; \ + SETUPTOOLS_SCM_PRETEND_VERSION="${LMCACHE_VERSION}" \ + PYTORCH_ROCM_ARCH="${LMCACHE_ROCM_ARCH}" \ + HIPCC_COMPILE_FLAGS_APPEND="${offload_flags}" \ + BUILD_WITH_HIP=1 CXX=hipcc \ + python3 setup.py bdist_wheel --dist-dir=/app/install; \ + test "$(find /app/install -maxdepth 1 -name '*.whl' | wc -l)" -eq 1 + +RUN --mount=type=tmpfs,target=/tmp/lmcache-wheel \ + set -eu; \ + python3 -m zipfile -e /app/install/*.whl /tmp/lmcache-wheel; \ + c_ops="$(find /tmp/lmcache-wheel -type f -name 'c_ops*.so')"; \ + test "$(find /tmp/lmcache-wheel -type f -name 'c_ops*.so' | wc -l)" -eq 1; \ + expected="$(printf '%s' "${LMCACHE_ROCM_ARCH}" | tr ';' '\n' | sort -u)"; \ + actual="$(/opt/rocm/llvm/bin/llvm-objdump --offloading "${c_ops}" \ + | grep -oE 'gfx[0-9a-z]+' | sort -u)"; \ + if [ "${actual}" != "${expected}" ]; then \ + printf 'LMCache code objects mismatch\nexpected:\n%s\nactual:\n%s\n' \ + "${expected}" "${actual}" >&2; \ + exit 1; \ + fi + # ROCShmem build stage - split from DeepEP so changing DEEPEP_BRANCH does not # invalidate the slow ROCShmem build. FROM base AS build_rocshmem @@ -797,6 +863,13 @@ RUN --mount=type=cache,target=/root/.cache/uv \ uv pip install --system /tmp/vllm_test_utils \ && rm -rf /tmp/vllm_test_utils +RUN --mount=type=bind,from=build_lmcache,src=/app/install,target=/lmcache_install \ + --mount=type=bind,source=requirements/test/rocm.txt,target=/tmp/lmcache-constraints.txt \ + --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system --constraint /tmp/lmcache-constraints.txt \ + /lmcache_install/*.whl \ + && python3 -c "import lmcache, lmcache.c_ops; print('lmcache', lmcache.__version__)" + # ----------------------- # Test vLLM image (Tier 2) - vLLM-only layer on top of ci_base. FROM ${CI_BASE_IMAGE} AS test @@ -825,7 +898,7 @@ ENV VLLM_GPU_SYNC_CHECK=error # ----------------------- # Final vLLM image -FROM mori_base AS final +FROM mori_base AS final_common RUN python3 -m pip install --upgrade pip && rm -rf /var/lib/apt/lists/* @@ -901,6 +974,18 @@ RUN echo "VLLM_BASE_IMAGE=${BASE_IMAGE}" >> ${COMMON_WORKDIR}/versions.txt \ CMD ["/bin/bash"] +FROM final_common AS final_lmcache_false + +FROM final_common AS final_lmcache_true +RUN --mount=type=bind,from=build_lmcache,src=/app/install,target=/lmcache_install \ + --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system /lmcache_install/*.whl \ + && test "$(python3 -c 'import numpy; print(numpy.__version__)')" = "2.3.5" \ + && uv pip check --system \ + && python3 -c "import lmcache, lmcache.c_ops; print('lmcache', lmcache.__version__)" + +FROM final_lmcache_${INSTALL_LMCACHE} AS final + #Set entrypoint for vllm-openai official images FROM final AS vllm-openai ENTRYPOINT ["vllm", "serve"]