Skip to content

Build and test PyTorch #147

Build and test PyTorch

Build and test PyTorch #147

Workflow file for this run

# *******************************************************************************
# Copyright 2025 Arm Limited and affiliates.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# *******************************************************************************
name: "Build and test PyTorch"
#* To avoid duplicate jobs running when both push and PR is satisfied, we use this:
#* https://github.com/orgs/community/discussions/26940#discussioncomment-5686753
on:
push:
branches: [main]
paths:
- ".github/**"
- "ML-Frameworks/pytorch-aarch64/**"
- "ML-Frameworks/utils/**"
# Exclusions (must come after the includes):
- "!ML-Frameworks/pytorch-aarch64/CHANGELOG.md"
- "!ML-Frameworks/pytorch-aarch64/README.md"
- "!ML-Frameworks/pytorch-aarch64/welcome.txt"
pull_request:
types: [opened, synchronize, reopened]
paths:
- ".github/**"
- "ML-Frameworks/pytorch-aarch64/**"
- "ML-Frameworks/utils/**"
# Exclusions (must come after the includes):
- "!ML-Frameworks/pytorch-aarch64/CHANGELOG.md"
- "!ML-Frameworks/pytorch-aarch64/README.md"
- "!ML-Frameworks/pytorch-aarch64/welcome.txt"
schedule:
#* minute (0-59) hour (0-23) day (1-31) month (1-12) day of the week (0 - 6)
#* cron jobs run on the default (main) branch.
#* set to run at 5am UCT
- cron: "0 5 * * *"
#* allow manual trigger of workflow when needed.
workflow_dispatch:
#* Stop stale workflows when pull requests are updated: https://stackoverflow.com/a/70972844
#* Does not apply to the main branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
# Declare default permissions as read only.
permissions: read-all
jobs:
build-image:
strategy:
matrix:
config:
[
{ name: c7g, label: ah-ubuntu_22_04-c7g_8x-100 },
{ name: c8g, label: ah-ubuntu_22_04-c8g_8x }
]
runs-on: ${{ matrix.config.label }}
steps:
- name: Checkout Tool-Solutions
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: Tool-Solutions
- name: Set up Docker
uses: docker/setup-docker-action@v4
- name: Build Tool-Solutions PyTorch
working-directory: ${{ github.workspace }}/Tool-Solutions/ML-Frameworks/pytorch-aarch64
run: ${{ github.workspace }}/Tool-Solutions/ML-Frameworks/pytorch-aarch64/build.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save image as a artifact
run: docker save toolsolutions-pytorch:latest -o toolsolutions-pytorch-image-${{ matrix.config.name }}.tar
- name: Upload build artifact
uses: actions/upload-artifact@v5
with:
name: toolsolutions-pytorch-image-${{ matrix.config.name }}
path: toolsolutions-pytorch-image-${{ matrix.config.name }}.tar
compression-level: 9
retention-days: 1
test:
needs: build-image
strategy:
fail-fast: false
matrix:
config:
[
{ name: c7g, label: ah-ubuntu_22_04-c7g_8x-100 },
{ name: c8g, label: ah-ubuntu_22_04-c8g_8x }
]
onednn_fpmath_mode: [FP32, BF16]
runs-on: ${{ matrix.config.label }}
steps:
- name: Download image artifact
uses: actions/download-artifact@v5
with:
name: toolsolutions-pytorch-image-${{ matrix.config.name }}
path: .
- name: Set up Docker
uses: docker/setup-docker-action@v4
- name: Load Docker image
run: docker load -i toolsolutions-pytorch-image-${{ matrix.config.name }}.tar
- name: Run smoke tests
run: |
docker run --rm \
-e ONEDNN_DEFAULT_FPMATH_MODE=${{ matrix.onednn_fpmath_mode }} \
toolsolutions-pytorch:latest ./test-examples.sh
- name: Run unit tests
run: |
docker run --rm \
-e ONEDNN_DEFAULT_FPMATH_MODE=${{ matrix.onednn_fpmath_mode }} \
toolsolutions-pytorch:latest ./run_unit_tests.sh