diff --git a/.github/workflows/ci-tests-fabric.yml b/.github/workflows/ci-tests-fabric.yml index abfe0e4e8881a..615633c5311bf 100644 --- a/.github/workflows/ci-tests-fabric.yml +++ b/.github/workflows/ci-tests-fabric.yml @@ -62,7 +62,6 @@ jobs: env: PACKAGE_NAME: ${{ matrix.config.pkg-name }} FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }} - PYPI_CACHE_DIR: "_pip-wheels" TORCH_URL_STABLE: "https://download.pytorch.org/whl/cpu/" TORCH_URL_TEST: "https://download.pytorch.org/whl/test/cpu/" # TODO: Remove this - Enable running MPS tests on this platform @@ -70,41 +69,50 @@ jobs: steps: - uses: actions/checkout@v5 - - name: Set up Python ${{ matrix.config.python-version }} - uses: actions/setup-python@v5 + - name: Install uv and set Python version + uses: astral-sh/setup-uv@v6 with: python-version: ${{ matrix.config.python-version || '3.9' }} + # TODO: Avoid activating environment like this + # see: https://github.com/astral-sh/setup-uv/tree/v6/?tab=readme-ov-file#activate-environment + activate-environment: true + enable-cache: true - - name: basic setup - run: pip install -q -r .actions/requirements.txt + - name: Basic setup + run: uv pip install -q -r .actions/requirements.txt + + - name: Append Env. vars for Linux + if: ${{ runner.os == 'Linux' }} + run: echo "GLOO_SOCKET_IFNAME=eth0" >> $GITHUB_ENV + + - name: Append Env. vars for MacOS + if: ${{ runner.os == 'macOS' }} + run: echo "GLOO_SOCKET_IFNAME=lo0" >> $GITHUB_ENV + + - name: Append Env. vars for Windows + if: ${{ runner.os == 'windows' }} + run: | + # Avoid issue on Windows with PyTorch 2.4: "RuntimeError: use_libuv was requested but PyTorch was build without libuv support" + echo "USE_LIBUV=0" >> $GITHUB_ENV - name: Set min. dependencies if: ${{ matrix.config.requires == 'oldest' }} run: | cd requirements/fabric - pip install -U "lightning-utilities[cli]" + uv pip install -U "lightning-utilities[cli]" python -m lightning_utilities.cli requirements set-oldest --req_files "['base.txt', 'strategies.txt', 'test.txt']" - pip install "cython<3.0" wheel - pip install "pyyaml==5.4" --no-build-isolation + uv pip install "cython<3.0" wheel + uv pip install "pyyaml==5.4" --no-build-isolation - name: Adjust PyTorch versions in requirements files if: ${{ matrix.config.requires != 'oldest' }} run: | - pip install -q -r requirements/ci.txt + uv pip install -q -r requirements/ci.txt python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py for fpath in `ls requirements/**/*.txt`; do \ python ./adjust-torch-versions.py $fpath ${{ matrix.config.pytorch-version }}; \ done - - name: pip wheels cache - uses: actions/cache/restore@v4 - with: - path: ${{ env.PYPI_CACHE_DIR }} - key: pypi_wheels - - run: | - mkdir -p $PYPI_CACHE_DIR - ls -lh $PYPI_CACHE_DIR - - name: Expand Env. variables run: | # Switch PyTorch URL between stable and test/future @@ -113,25 +121,15 @@ jobs: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.config.pkg-name}}' == 'lightning' else 'lightning_fabric'))" >> $GITHUB_ENV # if you install mono-package set dependency only for this subpackage python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.config.pkg-name}}' != 'lightning' else 'fabric-'))" >> $GITHUB_ENV - - name: Append Env. vars for MacOS - if: ${{ runner.os == 'macOS' }} - run: | - # trying to avoid "gloo" issue with SIGABRT - echo "GLOO_SOCKET_IFNAME=lo0" >> $GITHUB_ENV - - name: Append Env. vars for Windows - if: ${{ runner.os == 'windows' }} - run: | - # Avoid issue on Windows with PyTorch 2.4: "RuntimeError: use_libuv was requested but PyTorch was build without libuv support" - echo "USE_LIBUV=0" >> $GITHUB_ENV - name: Install package & dependencies timeout-minutes: 20 run: | - pip install -e ".[${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" \ - -U --upgrade-strategy=eager --prefer-binary \ - --extra-index-url="${TORCH_URL}" \ - --find-links="${PYPI_CACHE_DIR}" - pip list + uv pip install ".[${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" \ + --upgrade \ + --find-links="${TORCH_URL}" + uv pip list + - name: Dump handy wheels if: github.event_name == 'push' && github.ref == 'refs/heads/master' continue-on-error: true @@ -179,6 +177,9 @@ jobs: name: CPU-coverage fail_ci_if_error: false + - name: Minimize uv cache + run: uv cache prune --ci + fabric-cpu-guardian: runs-on: ubuntu-latest needs: fabric-cpu diff --git a/.github/workflows/ci-tests-pytorch.yml b/.github/workflows/ci-tests-pytorch.yml index 86f0a58089481..e6ec0b3072d91 100644 --- a/.github/workflows/ci-tests-pytorch.yml +++ b/.github/workflows/ci-tests-pytorch.yml @@ -89,6 +89,7 @@ jobs: - name: Append Env. vars for Linux if: ${{ runner.os == 'Linux' }} run: echo "GLOO_SOCKET_IFNAME=eth0" >> $GITHUB_ENV + - name: Append Env. vars for MacOS if: ${{ runner.os == 'macOS' }} run: echo "GLOO_SOCKET_IFNAME=lo0" >> $GITHUB_ENV