From 1e558296c02a08b2064ef43b232f0dd0dc940ed0 Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Fri, 5 Sep 2025 15:00:44 +0000 Subject: [PATCH 01/14] Enable integration tests --- .github/workflows/integration-test.yml | 60 +++++++++++++------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index db293ae2e3..91f45ca4cf 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -1,35 +1,35 @@ -# name: Integration Test +name: Integration Test -# on: -# pull_request: -# branches: [ main ] +on: + pull_request: + branches: [ main ] -# workflow_dispatch: + workflow_dispatch: -# jobs: -# build: +jobs: + build: -# runs-on: ubuntu-22.04 -# strategy: -# fail-fast: false -# matrix: -# python-version: [ 3.9 ] + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + python-version: [ 3.9 ] -# steps: -# - uses: actions/checkout@v2 -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Install dependencies -# run: | -# sudo apt install -y -qq libavfilter-dev libavdevice-dev -# - name: Install packages -# run: | -# python -m pip install --quiet --upgrade pip -# python -m pip install --quiet --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html -# python -m pip install --quiet pytest requests cmake ninja deep-phonemizer sentencepiece flashlight-text git+https://github.com/kpu/kenlm -# python -m pip install . -v --no-build-isolation -# - name: Run integration test -# run: | -# cd test && pytest integration_tests -v --use-tmp-hub-dir + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + sudo apt install -y -qq libavfilter-dev libavdevice-dev cmake ffmpeg + - name: Install packages + run: | + python -m pip install --quiet --upgrade pip + python -m pip install --quiet --pre torch torchcodec -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html + python -m pip install --quiet pytest requests + python -m pip install . -v --no-build-isolation + - name: Run integration test + run: | + cd test && pytest integration_tests -v --use-tmp-hub-dir From e22c3ec27383dae4858f752dd761c3ba4935520c Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Fri, 5 Sep 2025 15:10:04 +0000 Subject: [PATCH 02/14] Add numpy --- .github/workflows/integration-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 91f45ca4cf..2b843b1e1c 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -27,6 +27,7 @@ jobs: - name: Install packages run: | python -m pip install --quiet --upgrade pip + python -m pip install --quiet numpy python -m pip install --quiet --pre torch torchcodec -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html python -m pip install --quiet pytest requests python -m pip install . -v --no-build-isolation From 5a4b4f4cf039fd88ef41872405ab858036293a2f Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Fri, 5 Sep 2025 15:17:54 +0000 Subject: [PATCH 03/14] Install wheel --- .github/workflows/integration-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 2b843b1e1c..9d4e5de6d6 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -26,7 +26,7 @@ jobs: sudo apt install -y -qq libavfilter-dev libavdevice-dev cmake ffmpeg - name: Install packages run: | - python -m pip install --quiet --upgrade pip + python -m pip install --quiet --upgrade pip setuptools wheel python -m pip install --quiet numpy python -m pip install --quiet --pre torch torchcodec -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html python -m pip install --quiet pytest requests From 026b7a7eec6204f3292dc0cc78b7fd00bb7d8793 Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Fri, 5 Sep 2025 15:35:49 +0000 Subject: [PATCH 04/14] Disable cuda build for integration test --- .github/workflows/integration-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 9d4e5de6d6..6824db2dca 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -28,9 +28,11 @@ jobs: run: | python -m pip install --quiet --upgrade pip setuptools wheel python -m pip install --quiet numpy + export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUDA=true + unset CUDA_VERSION python -m pip install --quiet --pre torch torchcodec -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html python -m pip install --quiet pytest requests - python -m pip install . -v --no-build-isolation + USE_CUDA=0 python -m pip install . -v --no-build-isolation - name: Run integration test run: | cd test && pytest integration_tests -v --use-tmp-hub-dir From fa4e54bfaf7c211e13dcf3612d228e1d55a441ca Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Fri, 5 Sep 2025 16:20:25 +0000 Subject: [PATCH 05/14] Use BUILD_DOCS configuration --- .github/workflows/integration-test.yml | 38 ++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 6824db2dca..9fcd97c653 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -26,13 +26,39 @@ jobs: sudo apt install -y -qq libavfilter-dev libavdevice-dev cmake ffmpeg - name: Install packages run: | - python -m pip install --quiet --upgrade pip setuptools wheel - python -m pip install --quiet numpy - export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUDA=true - unset CUDA_VERSION + set -ex + + # Set up Environment Variables + export PYTHON_VERSION="3.10" + + # Install miniforge + wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" + bash Miniforge3.sh -b -p "${HOME}/conda" + source "${HOME}/conda/etc/profile.d/conda.sh" + + echo "::group::Create conda env" + # Mark Build Directory Safe + git config --global --add safe.directory /__w/audio/audio + conda create --quiet -y --prefix ci_env python="${PYTHON_VERSION}" + conda activate ./ci_env + conda install -q -y pip numpy + + echo "::endgroup::" + echo "::group::Install PyTorch" + python -m pip install --quiet --pre torch torchcodec -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html - python -m pip install --quiet pytest requests - USE_CUDA=0 python -m pip install . -v --no-build-isolation + + echo "::endgroup::" + echo "::group::Install TorchAudio" + conda install --quiet --yes cmake>=3.18.0 ninja + pip install --progress-bar off -v . --no-build-isolation + + echo "::endgroup::" + echo "::group::Build FFmpeg" + conda install -q -y "ffmpeg<=7" + + echo "::endgroup::" - name: Run integration test run: | + source "${HOME}/conda/etc/profile.d/conda.sh" cd test && pytest integration_tests -v --use-tmp-hub-dir From 420987fbb59a697b26de5ca5b0f238aa5ee89ea2 Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Fri, 5 Sep 2025 16:52:25 +0000 Subject: [PATCH 06/14] Use pytorch infra runner --- .github/workflows/integration-test.yml | 36 ++++++++++++-------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 9fcd97c653..764a70f8a0 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -9,27 +9,24 @@ on: jobs: build: - runs-on: ubuntu-22.04 - strategy: - fail-fast: false - matrix: - python-version: [ 3.9 ] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - sudo apt install -y -qq libavfilter-dev libavdevice-dev cmake ffmpeg - - name: Install packages - run: | + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + permissions: + id-token: write + contents: read + with: + job-name: Build doc + runner: linux.g5.4xlarge.nvidia.gpu + repository: pytorch/audio + gpu-arch-type: cuda + gpu-arch-version: "12.6" # See GPU_ARCH_ID below + timeout: 120 + script: | set -ex # Set up Environment Variables export PYTHON_VERSION="3.10" + export CU_VERSION="11.8" + export CUDATOOLKIT="pytorch-cuda=${CU_VERSION}" # Install miniforge wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" @@ -58,7 +55,6 @@ jobs: conda install -q -y "ffmpeg<=7" echo "::endgroup::" - - name: Run integration test - run: | - source "${HOME}/conda/etc/profile.d/conda.sh" + + echo "::group::Run Integration Tests" cd test && pytest integration_tests -v --use-tmp-hub-dir From 9624c42910ef6cbaee5c4e674805ea0d93cb2685 Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Fri, 5 Sep 2025 18:39:37 +0000 Subject: [PATCH 07/14] Use nightly torch --- .github/workflows/integration-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 764a70f8a0..302072208a 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -42,8 +42,8 @@ jobs: echo "::endgroup::" echo "::group::Install PyTorch" - - python -m pip install --quiet --pre torch torchcodec -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html + PYTORCH_WHEEL_INDEX="https://download.pytorch.org/whl/nightly/cpu" + pip install --progress-bar=off --pre torch torchcodec --index-url="${PYTORCH_WHEEL_INDEX}" echo "::endgroup::" echo "::group::Install TorchAudio" From 0015feb4e01ebd6eb1c34ec4e27ea716964b19b4 Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Fri, 5 Sep 2025 18:52:54 +0000 Subject: [PATCH 08/14] Install test deps --- .github/workflows/integration-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 302072208a..9364b0b79f 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -57,4 +57,5 @@ jobs: echo "::endgroup::" echo "::group::Run Integration Tests" + pip install pytest expecttest parameterized cd test && pytest integration_tests -v --use-tmp-hub-dir From 25a54db0b8a23ddf6f6da2a27fbfe6964cf24286 Mon Sep 17 00:00:00 2001 From: Sam Anklesaria Date: Fri, 5 Sep 2025 19:05:20 +0000 Subject: [PATCH 09/14] Fix job name --- .github/workflows/integration-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 9364b0b79f..94c50caa5b 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -14,7 +14,7 @@ jobs: id-token: write contents: read with: - job-name: Build doc + job-name: Integration Tests runner: linux.g5.4xlarge.nvidia.gpu repository: pytorch/audio gpu-arch-type: cuda From 81853f846d989b631e4e43b204392974d789acec Mon Sep 17 00:00:00 2001 From: Pearu Peterson Date: Fri, 12 Sep 2025 16:11:24 +0300 Subject: [PATCH 10/14] Use linux_job_v2 conda, copy workflow from linux cpu unittest workflow --- .github/workflows/integration-test.yml | 72 +++++++++++++++----------- 1 file changed, 43 insertions(+), 29 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 94c50caa5b..6e26e8489f 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -7,55 +7,69 @@ on: workflow_dispatch: jobs: - build: +jobs: + build: + strategy: + matrix: + python-version: ["3.11"] + ffmpeg-version: ["7"] + fail-fast: false uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main permissions: id-token: write contents: read with: - job-name: Integration Tests - runner: linux.g5.4xlarge.nvidia.gpu + runner: linux.12xlarge repository: pytorch/audio - gpu-arch-type: cuda - gpu-arch-version: "12.6" # See GPU_ARCH_ID below + gpu-arch-type: cpu + gpu-arch-version: timeout: 120 + job-name: linux-cpu-integration-tests + script: | set -ex - # Set up Environment Variables - export PYTHON_VERSION="3.10" - export CU_VERSION="11.8" - export CUDATOOLKIT="pytorch-cuda=${CU_VERSION}" - - # Install miniforge - wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" - bash Miniforge3.sh -b -p "${HOME}/conda" - source "${HOME}/conda/etc/profile.d/conda.sh" + export PYTHON_VERSION="${{ matrix.python-version }}" + export FFMPEG_VERSION="${{ matrix.ffmpeg-version }}" + export PIP_PROGRESS_BAR=off + export CONDA_QUIET=1 + + # Set UPLOAD_CHANNEL + if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then + export UPLOAD_CHANNEL=test + else + export UPLOAD_CHANNEL=nightly + fi echo "::group::Create conda env" # Mark Build Directory Safe git config --global --add safe.directory /__w/audio/audio - conda create --quiet -y --prefix ci_env python="${PYTHON_VERSION}" - conda activate ./ci_env - conda install -q -y pip numpy + conda create -c conda-forge --strict-channel-priority -y -n ci_env python="${PYTHON_VERSION}" ffmpeg="${FFMPEG_VERSION}" cmake ninja + conda activate ci_env + conda info + ffmpeg -version + python -m pip install --upgrade pip + # We add conda library path as otherwise torchcodec is not + # able to load ffmpeg shared libraries: + export LD_LIBRARY_PATH=${CONDA_PREFIX}/lib:${LD_LIBRARY_PATH} + echo "::endgroup::" + echo "::group::Install TorchAudio integration test and PyTorch dependencies" + python -m pip install parameterized pytest numpy expecttest deep-phonemizer sentencepiece flashlight-text git+https://github.com/kpu/kenlm echo "::endgroup::" - echo "::group::Install PyTorch" - PYTORCH_WHEEL_INDEX="https://download.pytorch.org/whl/nightly/cpu" - pip install --progress-bar=off --pre torch torchcodec --index-url="${PYTORCH_WHEEL_INDEX}" + echo "::group::Install PyTorch and TorchCodec" + PYTORCH_WHEEL_INDEX="https://download.pytorch.org/whl/${UPLOAD_CHANNEL}/cpu" + python -m pip install --pre torch torchcodec --index-url="${PYTORCH_WHEEL_INDEX}" + python -c 'import torch; print(f"{torch.__version__}"); print(f"{torch.__file__}")' + python -c 'import torchcodec; print(f"{torchcodec.__version__}"); print(f"{torchcodec.__file__}")' echo "::endgroup::" - echo "::group::Install TorchAudio" - conda install --quiet --yes cmake>=3.18.0 ninja - pip install --progress-bar off -v . --no-build-isolation + echo "::group::Build and install TorchAudio" + python -m pip install . -v --no-build-isolation echo "::endgroup::" - echo "::group::Build FFmpeg" - conda install -q -y "ffmpeg<=7" + echo "::group::Run TorchAudio integration tests" + pytest test/integration_tests/ -x --use-tmp-hub-dir echo "::endgroup::" - - echo "::group::Run Integration Tests" - pip install pytest expecttest parameterized - cd test && pytest integration_tests -v --use-tmp-hub-dir From f6ec524addd1fdbf5921ef0c2cb11c3932a52312 Mon Sep 17 00:00:00 2001 From: Pearu Peterson Date: Fri, 12 Sep 2025 16:22:16 +0300 Subject: [PATCH 11/14] Fix typo --- .github/workflows/integration-test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 6e26e8489f..e86e1ee12a 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -6,8 +6,6 @@ on: workflow_dispatch: -jobs: - jobs: build: strategy: From 90e0a48d78bf3b0a17b8c693a1b6a9c74764c27e Mon Sep 17 00:00:00 2001 From: Pearu Peterson Date: Fri, 12 Sep 2025 16:35:41 +0300 Subject: [PATCH 12/14] Fix the order of installing test deps --- .github/workflows/integration-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index e86e1ee12a..c8849f02cc 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -54,7 +54,7 @@ jobs: echo "::endgroup::" echo "::group::Install TorchAudio integration test and PyTorch dependencies" - python -m pip install parameterized pytest numpy expecttest deep-phonemizer sentencepiece flashlight-text git+https://github.com/kpu/kenlm + python -m pip install parameterized pytest numpy expecttest echo "::endgroup::" echo "::group::Install PyTorch and TorchCodec" @@ -69,5 +69,6 @@ jobs: echo "::endgroup::" echo "::group::Run TorchAudio integration tests" + python -m pip install deep-phonemizer sentencepiece flashlight-text git+https://github.com/kpu/kenlm pytest test/integration_tests/ -x --use-tmp-hub-dir echo "::endgroup::" From 574054251971c9e027ce8c3232fb1337689ae298 Mon Sep 17 00:00:00 2001 From: Pearu Peterson Date: Fri, 12 Sep 2025 17:11:19 +0300 Subject: [PATCH 13/14] Remove test/torchcodec --- test/torchcodec/decoders.py | 17 ----------------- test/torchcodec/encoders.py | 15 --------------- 2 files changed, 32 deletions(-) delete mode 100644 test/torchcodec/decoders.py delete mode 100644 test/torchcodec/encoders.py diff --git a/test/torchcodec/decoders.py b/test/torchcodec/decoders.py deleted file mode 100644 index a1f0433805..0000000000 --- a/test/torchcodec/decoders.py +++ /dev/null @@ -1,17 +0,0 @@ -from types import SimpleNamespace - -import torchaudio_unittest.common_utils.wav_utils as wav_utils - -# See corresponding [TorchCodec test dependency mocking hack] note in -# conftest.py - - -class AudioDecoder: - def __init__(self, uri): - self.uri = uri - data, sample_rate = wav_utils.load_wav(self.uri) - self.metadata = SimpleNamespace(sample_rate=sample_rate) - self.data = data - - def get_all_samples(self): - return SimpleNamespace(data=self.data) diff --git a/test/torchcodec/encoders.py b/test/torchcodec/encoders.py deleted file mode 100644 index d81cc5aa84..0000000000 --- a/test/torchcodec/encoders.py +++ /dev/null @@ -1,15 +0,0 @@ -from types import SimpleNamespace - -import torchaudio_unittest.common_utils.wav_utils as wav_utils - -# See corresponding [TorchCodec test dependency mocking hack] note in -# conftest.py - - -class AudioEncoder: - def __init__(self, data, sample_rate): - self.data = data - self.metadata = SimpleNamespace(sample_rate=sample_rate) - - def to_file(self, uri, bit_rate=None): - return wav_utils.save_wav(uri, self.data, self.metadata.sample_rate) From 8b90fdf8bb2dd131c2a70d268dab6f848a469b52 Mon Sep 17 00:00:00 2001 From: Pearu Peterson Date: Fri, 12 Sep 2025 17:30:27 +0300 Subject: [PATCH 14/14] Clean up --- .github/workflows/integration-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index c8849f02cc..3f682d4eb6 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -1,4 +1,4 @@ -name: Integration Test +name: Integration tests on: pull_request: @@ -23,7 +23,7 @@ jobs: gpu-arch-type: cpu gpu-arch-version: timeout: 120 - job-name: linux-cpu-integration-tests + job-name: linux-cpu script: | set -ex