From 0b5e64fafe1caa77cb90dc2444161094b4370ecc Mon Sep 17 00:00:00 2001 From: Andreas Karatzas Date: Wed, 24 Dec 2025 21:44:48 +0000 Subject: [PATCH 1/2] [ROCm] Add TorchCodec source build for transcription tests Signed-off-by: Andreas Karatzas --- .buildkite/test-amd.yaml | 2 +- docker/Dockerfile.rocm | 8 +++ tools/install_torchcodec_rocm.sh | 91 ++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100755 tools/install_torchcodec_rocm.sh diff --git a/.buildkite/test-amd.yaml b/.buildkite/test-amd.yaml index f28785e1ad205..1f61dc5b176ea 100644 --- a/.buildkite/test-amd.yaml +++ b/.buildkite/test-amd.yaml @@ -775,7 +775,7 @@ steps: - vllm/entrypoints/openai/ - vllm/model_executor/models/whisper.py commands: # LMEval+Transcription WER check - # Transcription WER check is skipped because encoder-decoder models are not supported on ROCm, see https://github.com/vllm-project/vllm/issues/27442 + - bash tools/install_torchcodec_rocm.sh || exit 1 - pytest -s entrypoints/openai/correctness/ diff --git a/docker/Dockerfile.rocm b/docker/Dockerfile.rocm index 4c09808a14333..3629b1e1a59b6 100644 --- a/docker/Dockerfile.rocm +++ b/docker/Dockerfile.rocm @@ -97,6 +97,14 @@ RUN --mount=type=cache,target=/root/.cache/uv \ uv pip install --system hf_transfer ENV HF_HUB_ENABLE_HF_TRANSFER=1 +# install audio decode package `torchcodec` from source (required due to +# ROCm and torch version mismatch) for tests with datasets package +COPY tools/install_torchcodec_rocm.sh /tmp/install_torchcodec.sh +RUN bash /tmp/install_torchcodec.sh \ + && rm /tmp/install_torchcodec.sh \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + # Copy in the v1 package (for python-only install test group) COPY --from=export_vllm /vllm_v1 /usr/local/lib/python${PYTHON_VERSION}/dist-packages/vllm/v1 diff --git a/tools/install_torchcodec_rocm.sh b/tools/install_torchcodec_rocm.sh new file mode 100755 index 0000000000000..895325d51662f --- /dev/null +++ b/tools/install_torchcodec_rocm.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Copyright contributors to the vLLM project + +# Script to install TorchCodec from source (required for ROCm compatibility) + +set -e + +TORCHCODEC_REPO="${TORCHCODEC_REPO:-https://github.com/pytorch/torchcodec.git}" +TORCHCODEC_BRANCH="${TORCHCODEC_BRANCH:-main}" + +echo "=== TorchCodec Installation Script ===" + +# Check if torchcodec is already installed and working +if python3 -c "from torchcodec.decoders import VideoDecoder" 2>/dev/null; then + echo "TorchCodec is already installed and working. Skipping." + exit 0 +fi + +echo "TorchCodec not found. Installing from source..." + +# Install system dependencies (FFmpeg + pkg-config) +install_system_deps() { + if command -v apt-get &> /dev/null; then + echo "Installing system dependencies..." + apt-get update && apt-get install -y \ + pkg-config \ + ffmpeg libavcodec-dev libavformat-dev libavutil-dev \ + libswscale-dev libavdevice-dev libavfilter-dev libswresample-dev + else + echo "Warning: apt-get did not work. Please install dependencies manually." + return 1 + fi +} + +# Check for pkg-config +if ! command -v pkg-config &> /dev/null; then + echo "pkg-config not found. Installing system dependencies..." + install_system_deps +fi + +# Check for required FFmpeg libraries +echo "Checking for FFmpeg libraries..." +if ! pkg-config --exists libavcodec libavformat libavutil libswscale libavdevice libavfilter libswresample 2>/dev/null; then + echo "FFmpeg development libraries not found. Installing..." + install_system_deps +fi + +# Install Python build dependencies +echo "Installing Python build dependencies..." +pip install pybind11 setuptools wheel + +# Set pybind11 cmake path so CMake can find it +export pybind11_DIR=$(python3 -c "import pybind11; print(pybind11.get_cmake_dir())") +export CMAKE_PREFIX_PATH="${pybind11_DIR}:${CMAKE_PREFIX_PATH}" +echo "pybind11_DIR set to: $pybind11_DIR" + +# Create temp directory for build +BUILD_DIR=$(mktemp -d -t torchcodec-XXXXXX) +echo "Building in temporary directory: $BUILD_DIR" + +cleanup() { + echo "Cleaning up $BUILD_DIR" + rm -rf "$BUILD_DIR" +} +trap cleanup EXIT + +# Clone and build +cd "$BUILD_DIR" +echo "Cloning TorchCodec from $TORCHCODEC_REPO (branch: $TORCHCODEC_BRANCH)..." +git clone --depth 1 --branch "$TORCHCODEC_BRANCH" "$TORCHCODEC_REPO" torchcodec || \ + git clone --depth 1 "$TORCHCODEC_REPO" torchcodec + +cd torchcodec + +# Set build environment for ROCm compatibility +export TORCHCODEC_CMAKE_BUILD_DIR="${PWD}/build" +export TORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR=1 +export I_CONFIRM_THIS_IS_NOT_A_LICENSE_VIOLATION=1 + +echo "Building TorchCodec..." +pip install . --no-build-isolation + +# Verify installation +echo "Verifying installation..." +if python3 -c "from torchcodec.decoders import VideoDecoder; print('TorchCodec installed successfully!')"; then + echo "=== TorchCodec installation complete ===" +else + echo "Error: TorchCodec installation failed verification" + exit 1 +fi \ No newline at end of file From 6557c53ccca44e10144925f66eb07fe7d9367b4f Mon Sep 17 00:00:00 2001 From: Andreas Karatzas Date: Wed, 24 Dec 2025 22:42:11 +0000 Subject: [PATCH 2/2] remove the fallback to let script fail if branch not fetched and prevent installation of packages that are not strictly necessary Signed-off-by: Andreas Karatzas --- tools/install_torchcodec_rocm.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/install_torchcodec_rocm.sh b/tools/install_torchcodec_rocm.sh index 895325d51662f..f4a2554733c52 100755 --- a/tools/install_torchcodec_rocm.sh +++ b/tools/install_torchcodec_rocm.sh @@ -23,7 +23,7 @@ echo "TorchCodec not found. Installing from source..." install_system_deps() { if command -v apt-get &> /dev/null; then echo "Installing system dependencies..." - apt-get update && apt-get install -y \ + apt-get update && apt-get install -y --no-install-recommends \ pkg-config \ ffmpeg libavcodec-dev libavformat-dev libavutil-dev \ libswscale-dev libavdevice-dev libavfilter-dev libswresample-dev @@ -68,8 +68,7 @@ trap cleanup EXIT # Clone and build cd "$BUILD_DIR" echo "Cloning TorchCodec from $TORCHCODEC_REPO (branch: $TORCHCODEC_BRANCH)..." -git clone --depth 1 --branch "$TORCHCODEC_BRANCH" "$TORCHCODEC_REPO" torchcodec || \ - git clone --depth 1 "$TORCHCODEC_REPO" torchcodec +git clone --depth 1 --branch "$TORCHCODEC_BRANCH" "$TORCHCODEC_REPO" torchcodec cd torchcodec