-
-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
MPS
Backend [without torch.amp.autocast ] + CI (#3041)
* Add support for `MPS` Backend [without torch.amp.autocast ] (#2993) * Add support for "mps" device in ignite.distributed.base * Made changes in the supervised_trainer API to have mps devices, Added some tests * autopep8 fix * Added lint fixes * Setup ci for mps tests --------- Co-authored-by: guptaaryan16 <[email protected]> Co-authored-by: vfdev <[email protected]> * Fixed mps-tests.yml * More fixes to mps-tests.yml * Set up working directory in mps yml * another try * another try * another try * added version check and skipped mps tests * code formatting * another code formatting fix --------- Co-authored-by: Aryan Gupta <[email protected]> Co-authored-by: guptaaryan16 <[email protected]>
- Loading branch information
1 parent
4dc4e04
commit a5ee7ae
Showing
9 changed files
with
199 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
name: Run unit tests on M1 | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- "*.*.*" | ||
paths: | ||
- "ignite/**" | ||
- "tests/ignite/**" | ||
- "tests/run_code_style.sh" | ||
- "examples/**.py" | ||
- "requirements-dev.txt" | ||
- ".github/workflows/mps-tests.yml" | ||
pull_request: | ||
paths: | ||
- "ignite/**" | ||
- "tests/ignite/**" | ||
- "tests/run_code_style.sh" | ||
- "examples/**.py" | ||
- "requirements-dev.txt" | ||
- ".github/workflows/mps-tests.yml" | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
# <workflow_name>-<branch_name>-<true || commit_sha (if branch is protected)> | ||
group: mps-tests-${{ github.ref_name }}-${{ !(github.ref_protected) || github.sha }} | ||
cancel-in-progress: true | ||
|
||
# Cherry-picked from | ||
# - https://github.com/pytorch/vision/main/.github/workflows/tests.yml | ||
# - https://github.com/pytorch/test-infra/blob/main/.github/workflows/macos_job.yml | ||
|
||
jobs: | ||
mps-tests: | ||
strategy: | ||
matrix: | ||
python-version: [3.8] | ||
pytorch-channel: ["pytorch"] | ||
skip-distrib-tests: [1] | ||
fail-fast: false | ||
runs-on: ["macos-m1-12"] | ||
timeout-minutes: 60 | ||
|
||
steps: | ||
- name: Clean workspace | ||
run: | | ||
echo "::group::Cleanup debug output" | ||
sudo rm -rfv "${GITHUB_WORKSPACE}" | ||
mkdir -p "${GITHUB_WORKSPACE}" | ||
echo "::endgroup::" | ||
- name: Checkout repository (pytorch/test-infra) | ||
uses: actions/checkout@v3 | ||
with: | ||
# Support the use case where we need to checkout someone's fork | ||
repository: pytorch/test-infra | ||
path: test-infra | ||
|
||
- name: Checkout repository (${{ github.repository }}) | ||
uses: actions/checkout@v3 | ||
with: | ||
# Support the use case where we need to checkout someone's fork | ||
repository: ${{ github.repository }} | ||
ref: ${{ github.ref }} | ||
path: ${{ github.repository }} | ||
fetch-depth: 1 | ||
|
||
- name: Setup miniconda | ||
uses: ./test-infra/.github/actions/setup-miniconda | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install PyTorch | ||
if: ${{ matrix.pytorch-channel == 'pytorch' }} | ||
shell: bash -l {0} | ||
run: pip install torch torchvision | ||
|
||
- name: Install PyTorch (nightly) | ||
if: ${{ matrix.pytorch-channel == 'pytorch-nightly' }} | ||
shell: bash -l {0} | ||
run: pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu | ||
|
||
- name: Install dependencies | ||
shell: bash -l {0} | ||
working-directory: ${{ github.repository }} | ||
run: | | ||
# TODO: We add set -xe to explicitly fail the CI if one of the commands is failing. | ||
# Somehow the step is passing even if a subcommand failed | ||
set -xe | ||
pip install -r requirements-dev.txt | ||
echo "1 returned code: $?" | ||
pip install -e . | ||
echo "2 returned code: $?" | ||
pip list | ||
echo "3 returned code: $?" | ||
# Download MNIST: https://github.com/pytorch/ignite/issues/1737 | ||
# to "/tmp" for unit tests | ||
- name: Download MNIST | ||
uses: pytorch-ignite/download-mnist-github-action@master | ||
with: | ||
target_dir: /tmp | ||
|
||
# Copy MNIST to "." for the examples | ||
- name: Copy MNIST | ||
run: | | ||
cp -R /tmp/MNIST . | ||
- name: Run Tests | ||
shell: bash -l {0} | ||
working-directory: ${{ github.repository }} | ||
run: | | ||
SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} bash tests/run_cpu_tests.sh | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
file: ${{ github.repository }}/coverage.xml | ||
flags: mps | ||
fail_ci_if_error: false | ||
|
||
- name: Run MNIST Examples | ||
shell: bash -l {0} | ||
working-directory: ${{ github.repository }} | ||
run: python examples/mnist/mnist.py --epochs=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters