Skip to content

Run unittests in debug mode at pull time and release mode on trunk builds #8550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for buck we are ignoring and using whatever's default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. I think that whether the code works with optimized/debug build flags is orthogonal to the choice of build system. (The ExecuTorch .buckconfig is configured to produce debug builds by default.)

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
Loading