diff --git a/.ci/scripts/test_llava.sh b/.ci/scripts/test_llava.sh index 60589c96d47..7876c287176 100644 --- a/.ci/scripts/test_llava.sh +++ b/.ci/scripts/test_llava.sh @@ -8,6 +8,10 @@ set -exu # shellcheck source=/dev/null +BUILD_TYPE=${1:-Debug} + +echo "Building with BUILD_TYPE: $BUILD_TYPE" + if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then PYTHON_EXECUTABLE=python3 fi @@ -15,7 +19,7 @@ fi cmake_install_executorch_libraries() { cmake \ -DCMAKE_INSTALL_PREFIX=cmake-out \ - -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \ -DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \ @@ -27,7 +31,7 @@ cmake_install_executorch_libraries() { -Bcmake-out . - cmake --build cmake-out -j9 --target install --config Debug + cmake --build cmake-out -j9 --target install --config ${BUILD_TYPE} } cmake_build_llava_runner() { @@ -36,7 +40,7 @@ cmake_build_llava_runner() { cmake \ -DCMAKE_INSTALL_PREFIX=cmake-out \ - -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \ -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \ -DEXECUTORCH_BUILD_XNNPACK=ON \ @@ -45,7 +49,7 @@ cmake_build_llava_runner() { ${dir} - cmake --build cmake-out/${dir} -j9 --config Debug + cmake --build cmake-out/${dir} -j9 --config ${BUILD_TYPE} } # only export the one without custom op for now since it's diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 9c45406fa80..7a6aad15505 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -270,6 +270,34 @@ jobs: # Test llama2 PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}" + test-llava-runner-macos: + name: test-llava-runner-macos + uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + strategy: + fail-fast: false + with: + runner: macos-m1-stable + python-version: '3.11' + submodules: 'true' + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + timeout: 900 + script: | + # The generic Linux job chooses to use base env, not the one setup by the image + CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]") + conda activate "${CONDA_ENV}" + + PYTHON_EXECUTABLE=python bash .ci/scripts/setup-macos.sh "cmake" + + # install Llava requirements + bash examples/models/llama2/install_requirements.sh + bash examples/models/llava/install_requirements.sh + + # run python unittest + python -m unittest examples.models.llava.test.test_llava + + # run e2e (export, tokenizer and runner) + PYTHON_EXECUTABLE=python bash .ci/scripts/test_llava.sh Release + test-qnn-model: name: test-qnn-model uses: pytorch/test-infra/.github/workflows/linux_job.yml@main diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f4ad1ddf8d..d25113a03ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -786,8 +786,12 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER) endif() add_executable(executor_runner ${_executor_runner__srcs}) - if(CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT APPLE) - target_link_options(executor_runner PRIVATE "LINKER:--gc-sections") + if(CMAKE_BUILD_TYPE STREQUAL "Release") + if(APPLE) + target_link_options(executor_runner PRIVATE "LINKER:-dead_strip") + else() + target_link_options(executor_runner PRIVATE "LINKER:--gc-sections") + endif() endif() target_link_libraries(executor_runner ${_executor_runner_libs}) target_compile_options(executor_runner PUBLIC ${_common_compile_options}) diff --git a/examples/models/llava/CMakeLists.txt b/examples/models/llava/CMakeLists.txt index 9bb9d9cf9d6..a1a6fc8c939 100644 --- a/examples/models/llava/CMakeLists.txt +++ b/examples/models/llava/CMakeLists.txt @@ -203,7 +203,11 @@ endif() add_executable(llava_main ${_srcs}) if(CMAKE_BUILD_TYPE STREQUAL "Release") - target_link_options(llava_main PRIVATE "LINKER:--gc-sections,-s") + if(APPLE) + target_link_options(llava_main PRIVATE "LINKER:-dead_strip,-s") + else() + target_link_options(llava_main PRIVATE "LINKER:--gc-sections,-s") + endif() endif() target_include_directories(llava_main PUBLIC ${_common_include_directories})