From 0c2c7bc8850b32a666dedc3d286f940a66ebf2dd Mon Sep 17 00:00:00 2001 From: Hansong <107070759+kirklandsign@users.noreply.github.com> Date: Tue, 25 Mar 2025 10:28:13 -0700 Subject: [PATCH 1/9] [TEST] Try to see if sccache is in use --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dbb66afdaa..c2b09716531 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,12 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() +find_program(SCCACHE sccache) +if(SCCACHE) + set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE} CACHE STRING "C compiler launcher" FORCE) + set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE} CACHE STRING "C++ compiler launcher" FORCE) +endif() + # Setup RPATH. # See https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling # Use separate rpaths during build and install phases From 3ff84b0c90a28898d2ea2584f3bf79ba7c7c8126 Mon Sep 17 00:00:00 2001 From: Hansong <107070759+kirklandsign@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:01:46 -0700 Subject: [PATCH 2/9] Update _android.yml --- .github/workflows/_android.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/_android.yml b/.github/workflows/_android.yml index a38ed4527e9..d55f078c9d6 100644 --- a/.github/workflows/_android.yml +++ b/.github/workflows/_android.yml @@ -57,6 +57,10 @@ jobs: cp examples/demo-apps/android/LlamaDemo/app/build/outputs/apk/debug/*.apk "${DEMO_APP_DIR}" cp examples/demo-apps/android/LlamaDemo/app/build/outputs/apk/androidTest/debug/*.apk "${DEMO_APP_DIR}" + sccache --show-stats + + + # Running Android emulator directly on the runner and not using Docker run-emulator: needs: build-llm-demo From 9350bd3eca41331888eb7542457f087f858d5f92 Mon Sep 17 00:00:00 2001 From: Hansong <107070759+kirklandsign@users.noreply.github.com> Date: Wed, 26 Mar 2025 10:38:16 -0700 Subject: [PATCH 3/9] Update pull.yml --- .github/workflows/pull.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index 1a083365220..58c67d88c84 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -186,6 +186,8 @@ jobs: # Test llama2 PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh -model stories110M -build_tool "${BUILD_TOOL}" -dtype "${DTYPE}" -mode "${MODE}" -upload "${ARTIFACTS_DIR_NAME}" + sccache --show-stats + test-llama-runner-linux-android: name: test-llama-runner-linux-android uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main From 35c708051b0535d65855b63a73262feac80e199a Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 26 Mar 2025 11:11:55 -0700 Subject: [PATCH 4/9] Trigger sccache --- .github/workflows/_android.yml | 6 ++++-- .github/workflows/android-perf.yml | 4 ++++ .github/workflows/android-release-artifacts.yml | 4 ++++ CMakeLists.txt | 6 ------ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/_android.yml b/.github/workflows/_android.yml index d55f078c9d6..88a37da45b7 100644 --- a/.github/workflows/_android.yml +++ b/.github/workflows/_android.yml @@ -22,6 +22,10 @@ jobs: script: | set -eux + # Use sccache for NDK compiler as well + export CMAKE_CXX_COMPILER_LAUNCHER=sccache + export CMAKE_C_COMPILER_LAUNCHER=sccache + # 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}" @@ -59,8 +63,6 @@ jobs: sccache --show-stats - - # Running Android emulator directly on the runner and not using Docker run-emulator: needs: build-llm-demo diff --git a/.github/workflows/android-perf.yml b/.github/workflows/android-perf.yml index 931bdbfe22d..8a74ac51a0c 100644 --- a/.github/workflows/android-perf.yml +++ b/.github/workflows/android-perf.yml @@ -353,6 +353,10 @@ jobs: script: | set -eux + # Use sccache for NDK compiler as well + export CMAKE_CXX_COMPILER_LAUNCHER=sccache + export CMAKE_C_COMPILER_LAUNCHER=sccache + # 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}" diff --git a/.github/workflows/android-release-artifacts.yml b/.github/workflows/android-release-artifacts.yml index e40b53a148b..a6d1f0a10ef 100644 --- a/.github/workflows/android-release-artifacts.yml +++ b/.github/workflows/android-release-artifacts.yml @@ -59,6 +59,10 @@ jobs: script: | set -eux + # Use sccache for NDK compiler as well + export CMAKE_CXX_COMPILER_LAUNCHER=sccache + export CMAKE_C_COMPILER_LAUNCHER=sccache + # 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}" diff --git a/CMakeLists.txt b/CMakeLists.txt index c2b09716531..6dbb66afdaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,12 +57,6 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() -find_program(SCCACHE sccache) -if(SCCACHE) - set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE} CACHE STRING "C compiler launcher" FORCE) - set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE} CACHE STRING "C++ compiler launcher" FORCE) -endif() - # Setup RPATH. # See https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling # Use separate rpaths during build and install phases From e97df94ab11ab9cd08ecae1462f910ce5ffb22d5 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 26 Mar 2025 11:29:39 -0700 Subject: [PATCH 5/9] Update --- .github/workflows/_android.yml | 2 -- .github/workflows/pull.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/_android.yml b/.github/workflows/_android.yml index 88a37da45b7..d2e82449c3c 100644 --- a/.github/workflows/_android.yml +++ b/.github/workflows/_android.yml @@ -61,8 +61,6 @@ jobs: cp examples/demo-apps/android/LlamaDemo/app/build/outputs/apk/debug/*.apk "${DEMO_APP_DIR}" cp examples/demo-apps/android/LlamaDemo/app/build/outputs/apk/androidTest/debug/*.apk "${DEMO_APP_DIR}" - sccache --show-stats - # Running Android emulator directly on the runner and not using Docker run-emulator: needs: build-llm-demo diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index 58c67d88c84..1a083365220 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -186,8 +186,6 @@ jobs: # Test llama2 PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh -model stories110M -build_tool "${BUILD_TOOL}" -dtype "${DTYPE}" -mode "${MODE}" -upload "${ARTIFACTS_DIR_NAME}" - sccache --show-stats - test-llama-runner-linux-android: name: test-llama-runner-linux-android uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main From 2041aa1cab9070871acb16257513ff50162add45 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 26 Mar 2025 17:42:40 -0700 Subject: [PATCH 6/9] Use stub in docker --- .ci/docker/common/install_cache.sh | 16 ++++++++++++++++ .ci/docker/ubuntu/Dockerfile | 12 ++++++------ .github/workflows/_android.yml | 4 ---- .github/workflows/android-perf.yml | 4 ---- .github/workflows/android-release-artifacts.yml | 4 ---- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.ci/docker/common/install_cache.sh b/.ci/docker/common/install_cache.sh index f17b4cc6068..230585fa435 100755 --- a/.ci/docker/common/install_cache.sh +++ b/.ci/docker/common/install_cache.sh @@ -89,10 +89,26 @@ init_sccache() { as_ci_user sccache --zero-stats || true } +function write_android_sccache_stub() { + BINARY=$1 + mv "/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$1" "/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/.$1" + cat >"/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$1" < Date: Thu, 27 Mar 2025 11:03:27 -0700 Subject: [PATCH 7/9] Update install_cache.sh --- .ci/docker/common/install_cache.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.ci/docker/common/install_cache.sh b/.ci/docker/common/install_cache.sh index 230585fa435..6ea81b10c38 100755 --- a/.ci/docker/common/install_cache.sh +++ b/.ci/docker/common/install_cache.sh @@ -109,6 +109,8 @@ write_sccache_stub gcc write_sccache_stub g++ write_sccache_stub clang write_sccache_stub clang++ -write_android_sccache_stub clang -write_android_sccache_stub clang++ +if [ -n "${ANDROID_NDK_VERSION}" ]; then + write_android_sccache_stub clang + write_android_sccache_stub clang++ +fi init_sccache From b14d160a07fbd06367097aa9ee5826a1ce348f3b Mon Sep 17 00:00:00 2001 From: Hansong <107070759+kirklandsign@users.noreply.github.com> Date: Thu, 27 Mar 2025 12:42:01 -0700 Subject: [PATCH 8/9] Update install_cache.sh --- .ci/docker/common/install_cache.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/docker/common/install_cache.sh b/.ci/docker/common/install_cache.sh index 6ea81b10c38..a6fa4141351 100755 --- a/.ci/docker/common/install_cache.sh +++ b/.ci/docker/common/install_cache.sh @@ -100,7 +100,7 @@ else exec /opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/.$1 "\$@" fi EOF - chmod a+x "/opt/toolchains/llvm/prebuilt/linux-x86_64/bin/${BINARY}" + chmod a+x "/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/${BINARY}" } write_sccache_stub cc From 06727c373b705fc973c6466fc98387532334d6ca Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Fri, 11 Apr 2025 14:32:44 -0700 Subject: [PATCH 9/9] Set in yml --- .ci/docker/common/install_cache.sh | 18 ------------------ .ci/docker/ubuntu/Dockerfile | 12 ++++++------ .github/workflows/_android.yml | 4 ++++ .github/workflows/android-perf.yml | 4 ++++ .../workflows/android-release-artifacts.yml | 4 ++++ 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.ci/docker/common/install_cache.sh b/.ci/docker/common/install_cache.sh index a6fa4141351..f17b4cc6068 100755 --- a/.ci/docker/common/install_cache.sh +++ b/.ci/docker/common/install_cache.sh @@ -89,28 +89,10 @@ init_sccache() { as_ci_user sccache --zero-stats || true } -function write_android_sccache_stub() { - BINARY=$1 - mv "/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$1" "/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/.$1" - cat >"/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$1" <