Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Separate compilation of mlir from test runs, transfer mlir binaries to matrix jobs via artifact #30

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d2d8842
Added cache to restore conda env
gshimansky Nov 30, 2023
11e0dc0
Added condition for conda checkout
gshimansky Nov 30, 2023
4714ab1
Moved conda install before cache, then env update
gshimansky Nov 30, 2023
0cb0f9e
Fixed env, added shell
gshimansky Nov 30, 2023
7da90f6
Remove env because it is not allowed
gshimansky Nov 30, 2023
bf97945
Fixed string concatenation with format
gshimansky Nov 30, 2023
bcd4d2d
Merge branch 'main' into gregory/test-faster-runs
gshimansky Nov 30, 2023
2d80ac7
Make building mlir a separate job that runs before size matrix
gshimansky Nov 30, 2023
c8d8b55
Moved checkout to first job
gshimansky Nov 30, 2023
5e5f6f3
Adde "with" to artifact calls
gshimansky Nov 30, 2023
510dd02
Merge branch 'main' into gregory/test-faster-runs
gshimansky Dec 1, 2023
f918f98
Merge branch 'main' into gregory/test-faster-runs
gshimansky Dec 4, 2023
7933d8a
Added restoring and creating of torch-mlir env before building torch-…
gshimansky Dec 4, 2023
77fc84d
Added missing "steps"
gshimansky Dec 4, 2023
333f4e0
Added missing shell
gshimansky Dec 4, 2023
6c746e5
Added repo checkout
gshimansky Dec 4, 2023
c603609
Fixed conda env name
gshimansky Dec 4, 2023
0da0582
Fixed conda env parameter
gshimansky Dec 4, 2023
72d8d44
Added missing cd, moved checkout to build action
gshimansky Dec 4, 2023
186f835
Use tar instead of moving separate files into artifactory
gshimansky Dec 5, 2023
b6f88a9
Moved checkout before using actions
gshimansky Dec 5, 2023
fe88b14
Moved artifact restore to the beginning
gshimansky Dec 5, 2023
5bd72f9
Added missing build
gshimansky Dec 5, 2023
e3fb6b4
DEBUG1
gshimansky Dec 5, 2023
5e001a1
Removed path argument
gshimansky Dec 5, 2023
01967f3
Added environment initialization in initial initial setup
gshimansky Dec 5, 2023
4495927
Moved environment setting to the end of action
gshimansky Dec 5, 2023
10e873f
Moved "if" inside of steps
gshimansky Dec 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions .github/actions/build_mlir/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Build torch-mlir
description: Checkout torch-mlir repo and build it in mlir-test conda env
description: Checkout torch-mlir repo and build it in mlir conda env

inputs:
conda_env:
required: true
type: string
description: Name of torch-mlir conda env

runs:
using: composite
Expand All @@ -11,10 +17,56 @@ runs:
path: torch-mlir
ref: 'cpu-proto'
submodules: recursive

- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash

- name: Restore Conda env cache
id: conda-cache
uses: actions/cache@v3
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 2
with:
path: ${{ env.CONDA }}/envs
key: >-
conda-${{ inputs.conda_env }}-
${{ hashFiles(format('tests/conda-envs/{0}.yaml', inputs.conda_env)) }}-
${{ steps.get-date.outputs.today }}-
${{ env.CACHE_NUMBER }}

- name: Update conda env for torch-mlir env
if: steps.conda-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/create_torch_mlir_conda_env
with:
conda_env: ${{ inputs.conda_env }}

- name: Build torch-mlir
shell: bash -el {0}
run: |
source ${CONDA}/bin/activate ${{ inputs.conda_env }}
source /opt/intel/oneapi/setvars.sh
tests/scripts/build-mlir.sh torch-mlir
cd torch-mlir
cmake -GNinja -Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DPython3_FIND_VIRTUALENV=ONLY \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DLLVM_TARGETS_TO_BUILD=host \
externals/llvm-project/llvm
cmake --build build
cd ..
tar cf torch-mlir.tar torch-mlir
echo PYTHONPATH=`pwd`/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir:`pwd`/torch-mlir/examples:$PYTHONPATH >> $GITHUB_ENV
echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH >> $GITHUB_ENV

- name: Upload built mlir
uses: actions/upload-artifact@v3
with:
name: torch-mlir-binary
path: torch-mlir.tar
if-no-files-found: error
19 changes: 19 additions & 0 deletions .github/actions/create_torch_mlir_conda_env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Install torch-mlir required python packages
description: Checkout torch-mlir repo and install required packages in an empty conda env

inputs:
conda_env:
required: true
type: string
description: Name of torch-mlir conda env

runs:
using: composite
steps:
- name: Install required packages
shell: bash -el {0}
run: |
${CONDA}/bin/conda env update --solver libmamba -n ${{ inputs.conda_env }} -f tests/conda-envs/${{ inputs.conda_env }}.yaml
source ${CONDA}/bin/activate ${{ inputs.conda_env }}
cd torch-mlir
pip install -r requirements.txt
31 changes: 27 additions & 4 deletions .github/actions/initial_setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ inputs:
runs:
using: composite
steps:
- name: Download mlir that was built in previous job
if: ${{ inputs.conda_env == 'mlir' }}
uses: actions/download-artifact@v3
with:
name: torch-mlir-binary

- name: Setup benchmarks package
if: ${{ inputs.conda_env == 'mlir' }}
shell: bash -el {0}
run: tar xf torch-mlir.tar

- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
Expand All @@ -33,16 +44,28 @@ runs:
${{ steps.get-date.outputs.today }}-
${{ env.CACHE_NUMBER }}

- name: Update conda env
if: steps.conda-cache.outputs.cache-hit != 'true'
- name: Update conda env for non-torch-mlir envs
if: steps.conda-cache.outputs.cache-hit != 'true' && inputs.conda_env != 'mlir'
shell: bash -el {0}
run: ${CONDA}/bin/conda env update --solver libmamba -n ${{ inputs.conda_env }} -f tests/conda-envs/${{ inputs.conda_env }}.yaml

- uses: ./.github/actions/build_mlir
if: ${{ inputs.conda_env == 'mlir' }}
- name: Update conda env for torch-mlir env
if: steps.conda-cache.outputs.cache-hit != 'true' && inputs.conda_env == 'mlir'
uses: ./.github/actions/create_torch_mlir_conda_env
with:
conda_env: ${{ inputs.conda_env }}

- name: Setup benchmarks package
shell: bash -el {0}
run: |
source ${CONDA}/bin/activate ${{ inputs.conda_env }}
pip install -e .

- name: Save environment variables for mlir env
if: ${{ inputs.conda_env == 'mlir' }}
shell: bash -el {0}
run: |
source ${CONDA}/bin/activate ${{ inputs.conda_env }}
source /opt/intel/oneapi/setvars.sh
echo PYTHONPATH=`pwd`/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir:`pwd`/torch-mlir/examples:$PYTHONPATH >> $GITHUB_ENV
echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH >> $GITHUB_ENV
16 changes: 16 additions & 0 deletions .github/workflows/mlp-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,25 @@ on:
required: true

jobs:
build_mlir:
runs-on:
- self-hosted
- glados
steps:
- uses: actions/checkout@v4
if: ${{ inputs.conda_env == 'mlir' }}

- name: Build mlir and upload to artifact storage
if: ${{ inputs.conda_env == 'mlir' }}
uses: ./.github/actions/build_mlir
with:
conda_env: ${{ inputs.conda_env }}

mlp_test:
runs-on:
- self-hosted
- glados
needs: build_mlir
strategy:
matrix:
bname:
Expand Down Expand Up @@ -54,6 +69,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/initial_setup
with:
conda_env: ${{ inputs.conda_env }}
Expand Down
3 changes: 0 additions & 3 deletions tests/scripts/build-mlir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ fi

source ${CONDA}/bin/activate mlir

env
${CONDA}/bin/conda list

cd $1
pip install -r requirements.txt

Expand Down