Skip to content

Commit

Permalink
Run unittests in debug mode at pull time and release mode on trunk bu…
Browse files Browse the repository at this point in the history
…ilds (#8550)

Per discussion in discord with @mergennachin. Motivation was to have debug coverage to catch debug-only test failures.
  • Loading branch information
swolchok authored Feb 20, 2025
1 parent 9de9ed4 commit 254eeca
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .ci/scripts/setup-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fi
# have already been installed, so we use PyTorch build from source here instead
# of nightly. This allows CI to test against latest commits from PyTorch
install_executorch "use-pt-pinned-commit"
build_executorch_runner "${BUILD_TOOL}"
build_executorch_runner "${BUILD_TOOL}" "${2:-Release}"

if [[ "${GITHUB_BASE_REF:-}" == *main* || "${GITHUB_BASE_REF:-}" == *gh* ]]; then
do_not_use_nightly_on_ci
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/setup-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ install_pytorch_and_domains
# We build PyTorch from source here instead of using nightly. This allows CI to test against
# the pinned commit from PyTorch
install_executorch "use-pt-pinned-commit"
build_executorch_runner "${BUILD_TOOL}"
build_executorch_runner "${BUILD_TOOL}" "${2:-Release}"

if [[ "${GITHUB_BASE_REF:-}" == *main* || "${GITHUB_BASE_REF:-}" == *gh* ]]; then
do_not_use_nightly_on_ci
Expand Down
10 changes: 9 additions & 1 deletion .ci/scripts/unittest-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ else
exit 1
fi

BUILD_MODE=$2
if [[ "${BUILD_MODE:-}" =~ ^(Debug|Release)$ ]]; then
echo "Running tests in build mode ${BUILD_MODE} ..."
else
echo "Unsupported build mode ${BUILD_MODE}, options are Debug or Release."
exit 1
fi

# The generic Linux job chooses to use base env, not the one setup by the image
eval "$(conda shell.bash hook)"
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
Expand All @@ -25,7 +33,7 @@ source .ci/scripts/setup-vulkan-linux-deps.sh
PYTHON_EXECUTABLE=python \
EXECUTORCH_BUILD_PYBIND=ON \
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
.ci/scripts/setup-linux.sh "$BUILD_TOOL"
.ci/scripts/setup-linux.sh "$BUILD_TOOL" "$BUILD_MODE"

# Install llama3_2_vision dependencies.
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
Expand Down
10 changes: 9 additions & 1 deletion .ci/scripts/unittest-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ else
exit 1
fi

BUILD_MODE=$2
if [[ $BUILD_MODE =~ ^(Debug|Release)$ ]]; then
echo "Running tests in build mode ${BUILD_MODE} ..."
else
echo "Unsupported build mode ${BUILD_MODE}, options are Debug or Release."
exit 1
fi

bash .ci/scripts/setup-conda.sh
eval "$(conda shell.bash hook)"

Expand All @@ -27,7 +35,7 @@ PYTHON_EXECUTABLE=python \
EXECUTORCH_BUILD_PYBIND=ON \
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
${CONDA_RUN} --no-capture-output \
.ci/scripts/setup-macos.sh cmake
.ci/scripts/setup-macos.sh "${BUILD_TOOL}" "${BUILD_MODE}"

# Install llama3_2_vision dependencies.
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
Expand Down
4 changes: 2 additions & 2 deletions .ci/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ build_executorch_runner_cmake() {
pushd "${CMAKE_OUTPUT_DIR}" || return
# This command uses buck2 to gather source files and buck2 could crash flakily
# on MacOS
retry cmake -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" -DCMAKE_BUILD_TYPE=Release ..
retry cmake -DPYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}" -DCMAKE_BUILD_TYPE="${1:-Release}" ..
popd || return

if [ "$(uname)" == "Darwin" ]; then
Expand All @@ -124,7 +124,7 @@ build_executorch_runner() {
if [[ $1 == "buck2" ]]; then
build_executorch_runner_buck2
elif [[ $1 == "cmake" ]]; then
build_executorch_runner_cmake
build_executorch_runner_cmake "$2"
else
echo "Invalid build tool $1. Only buck2 and cmake are supported atm"
exit 1
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/_unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
required: true
type: string
description: Name of the docker image to use.
build-mode:
required: true
type: string
description: Build mode to use, Debug or Release.
build-tool:
required: true
type: string
Expand All @@ -30,7 +34,7 @@ jobs:
timeout: 90
script: |
set -eux
.ci/scripts/unittest-linux.sh "${{ inputs.build-tool }}"
.ci/scripts/unittest-linux.sh "${{ inputs.build-tool }}" "${{ inputs.build-mode }}"
macos:
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
Expand All @@ -41,4 +45,4 @@ jobs:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
script: |
set -eux
.ci/scripts/unittest-macos.sh "${{ inputs.build-tool }}"
.ci/scripts/unittest-macos.sh "${{ inputs.build-tool }}" "${{ inputs.build-mode }}"
2 changes: 2 additions & 0 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ jobs:
id-token: write
contents: read
with:
build-mode: Debug
build-tool: cmake
docker-image: executorch-ubuntu-22.04-clang12

Expand All @@ -376,6 +377,7 @@ jobs:
id-token: write
contents: read
with:
build-mode: Debug
build-tool: buck2
docker-image: executorch-ubuntu-22.04-clang12

Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,13 @@ jobs:
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
# Test llama2
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh -model stories110M -build_tool "${BUILD_TOOL}" -mode "${MODE}" -dtype "${DTYPE}" -pt2e_quantize "${PT2E_QUANTIZE}"
unittest-release:
uses: ./.github/workflows/_unittest.yml
permissions:
id-token: write
contents: read
with:
build-mode: Release
build-tool: cmake
docker-image: executorch-ubuntu-22.04-clang12

0 comments on commit 254eeca

Please sign in to comment.