Skip to content

Tests (MPI)

Tests (MPI) #503

Workflow file for this run

name: Tests (MPI)
on:
workflow_dispatch:
push:
branches:
- master
pull_request: {}
schedule:
- cron: '0 23 * * SUN-THU'
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_number || github.ref }}
cancel-in-progress: true
jobs:
define-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Define workflow matrix
id: set-matrix
run: |
if [ "${{ github.event_name }}" = "schedule" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ] ; then
echo "Schedule tests (run all the versions)"
echo "matrix={\"python-version\":[\"3.8\", \"3.9\", \"3.10\", \"3.11\"]}" >> $GITHUB_OUTPUT
else
echo "PR push tests (run only the oldest and the latest versions)"
echo "matrix={\"python-version\":[\"3.8\", \"3.11\"]}" >> $GITHUB_OUTPUT
fi
tests-mpi:
if: (github.event_name == 'schedule' && github.repository == 'optuna/optuna') || (github.event_name != 'schedule')
needs: define-matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.define-matrix.outputs.matrix)}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup cache
uses: actions/cache@v3
env:
cache-name: test-mpi
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ env.cache-name }}-${{ hashFiles('**/pyproject.toml') }}-v1
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-${{ env.cache-name }}-${{ hashFiles('**/pyproject.toml') }}
- name: Setup environment
run: |
sudo apt-get update
sudo apt-get -y install openmpi-bin libopenmpi-dev
- name: Install
run: |
python -m pip install --upgrade pip
# Install minimal dependencies and confirm that `import optuna` is successful.
pip install --progress-bar off .
python -c 'import optuna'
optuna --version
pip install --progress-bar off .[test]
pip install --progress-bar off .[optional] --extra-index-url https://download.pytorch.org/whl/cpu
# TODO(not522): Remove this line when torchmetrics can be installed with extra-index-url
pip install --progress-bar off torchmetrics
pip install --progress-bar off .[integration] --extra-index-url https://download.pytorch.org/whl/cpu
- name: Output installed packages
run: |
pip freeze --all
- name: Output dependency tree
run: |
pip install pipdeptree
pipdeptree
- name: Tests
run: |
export OMPI_MCA_rmaps_base_oversubscribe=yes
mpirun -n 2 -- pytest tests/integration_tests/test_pytorch_distributed.py
env:
OMP_NUM_THREADS: 1