diff --git a/.github/workflows/_test_cadence.yml b/.github/workflows/_test_cadence.yml new file mode 100644 index 00000000000..5b81ddc3f82 --- /dev/null +++ b/.github/workflows/_test_cadence.yml @@ -0,0 +1,77 @@ +name: Test Cadence + +permissions: + id-token: write + contents: read + +on: + workflow_call: + inputs: + docker-image: + description: 'Docker image to use' + required: false + type: string + default: ci-image:executorch-ubuntu-22.04-clang12 + runner: + description: 'Runner type' + required: false + type: string + default: linux.8xlarge.memory + ref: + description: 'Git ref to checkout' + required: false + type: string + default: ${{ github.sha }} + timeout: + description: 'Job timeout in minutes' + required: false + type: number + default: 90 + +jobs: + test-aot: + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + with: + job-name: test-aot + runner: ${{ inputs.runner }} + docker-image: ${{ inputs.docker-image }} + submodules: recursive + ref: ${{ inputs.ref }} + timeout: ${{ inputs.timeout }} + script: | + set -eux + conda create -y -n cadence_test python=3.12 > /dev/null + conda activate cadence_test + + ./install_requirements.sh > /dev/null + pip install -e . --no-build-isolation > /dev/null + pip install beartype later pyre_extensions pytest-xdist + + python -m pytest backends/cadence/aot/tests/ -v -n auto + + test-ops: + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + with: + job-name: test-ops + runner: ${{ inputs.runner }} + docker-image: ${{ inputs.docker-image }} + submodules: recursive + ref: ${{ inputs.ref }} + timeout: ${{ inputs.timeout }} + download-artifact: cadence-runner-build + script: | + set -eux + conda create -y -n cadence_test python=3.12 > /dev/null + conda activate cadence_test + + ./install_requirements.sh > /dev/null + pip install -e . --no-build-isolation > /dev/null + pip install beartype later pyre_extensions pytest-xdist + + # Use the pre-built runner from the build job + mkdir -p cmake-out/backends/cadence + cp "${RUNNER_ARTIFACT_DIR}/cadence_runner" cmake-out/backends/cadence/cadence_runner + chmod +x cmake-out/backends/cadence/cadence_runner + + export PYTHONPATH="${PYTHONPATH:-}:$(pwd)/backends/cadence/utils/FACTO" + python -m pytest examples/cadence/operators/ -v -n auto diff --git a/.github/workflows/build-cadence-runner.yml b/.github/workflows/build-cadence-runner.yml index 09725add21a..b0450981c1f 100644 --- a/.github/workflows/build-cadence-runner.yml +++ b/.github/workflows/build-cadence-runner.yml @@ -1,4 +1,4 @@ -name: Build Cadence +name: Cadence Build & Test on: pull_request: @@ -13,7 +13,7 @@ concurrency: cancel-in-progress: true jobs: - cpu: + cpu-build: uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main permissions: id-token: write @@ -25,6 +25,7 @@ jobs: submodules: recursive ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} timeout: 90 + upload-artifact: cadence-runner-build script: | set -eux # The generic Linux job chooses to use base env, not the one setup by the image @@ -33,3 +34,15 @@ jobs: ./install_requirements.sh > /dev/null bash backends/cadence/build_cadence_runner.sh + + # Copy runner binary to artifact dir for downstream test jobs + cp cmake-out/backends/cadence/cadence_runner "${RUNNER_ARTIFACT_DIR}/" + + cpu-test: + needs: cpu-build + permissions: + id-token: write + contents: read + uses: ./.github/workflows/_test_cadence.yml + with: + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}