"src/git@developer.sourcefind.cn:OpenDAS/nni.git" did not exist on "00ddf3aa0ac4a134b946cb53ffaf26f6621697bd"
Unverified Commit a59d41d6 authored by Yichen Yan's avatar Yichen Yan Committed by GitHub
Browse files

[CI] Enable `ccache` for CIBW on Linux (#1184)

* Enable ccache for linux cibw, unify ccache settings.

* hash cc files to avoid get stuck in some case

* Add comments about ccache version

* fix wrong gitignore
parent 4a9cb470
...@@ -129,13 +129,6 @@ jobs: ...@@ -129,13 +129,6 @@ jobs:
echo "UV_CACHE_DIR=${XDG_CACHE_HOME}/uv" | tee -a "${GITHUB_ENV}" echo "UV_CACHE_DIR=${XDG_CACHE_HOME}/uv" | tee -a "${GITHUB_ENV}"
echo "PRE_COMMIT_HOME=${XDG_CACHE_HOME}/pip/.pre-commit" | tee -a "${GITHUB_ENV}" echo "PRE_COMMIT_HOME=${XDG_CACHE_HOME}/pip/.pre-commit" | tee -a "${GITHUB_ENV}"
- name: Set environment (GitHub-hosted runners)
if: ${{ !startsWith(matrix.runner.name, 'self-hosted') }}
run: |
# Enable ccache on GitHub-hosted runners to speed up builds
echo "CMAKE_C_COMPILER_LAUNCHER=ccache" | tee -a "${GITHUB_ENV}"
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" | tee -a "${GITHUB_ENV}"
# Do not use ccache on self-hosted runners, as it will download/upload caches which is slow. # Do not use ccache on self-hosted runners, as it will download/upload caches which is slow.
# Self-hosted runners usually have more CPU power to compile without ccache. # Self-hosted runners usually have more CPU power to compile without ccache.
- name: Setup ccache (GitHub-hosted runners) - name: Setup ccache (GitHub-hosted runners)
...@@ -144,8 +137,13 @@ jobs: ...@@ -144,8 +137,13 @@ jobs:
uses: hendrikmuhs/ccache-action@v1 uses: hendrikmuhs/ccache-action@v1
with: with:
create-symlink: true create-symlink: true
key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}-${{ matrix.runner.name }}-${{ matrix.runner.toolkit }}
evict-old-files: "7d" evict-old-files: "7d"
append-timestamp: false
key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.runner.toolkit }}-${{ hashFiles('**/*.cc') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-${{ matrix.runner.toolkit }}-${{ hashFiles('**/*.cc') }}
${{ runner.os }}-${{ runner.arch }}-${{ matrix.runner.toolkit }}
${{ runner.os }}-${{ runner.arch }}
- name: Set environment (CUDA) - name: Set environment (CUDA)
if: contains(matrix.runner.toolkit, 'CUDA') if: contains(matrix.runner.toolkit, 'CUDA')
......
...@@ -44,11 +44,11 @@ jobs: ...@@ -44,11 +44,11 @@ jobs:
runs-on: macos-latest runs-on: macos-latest
timeout-minutes: 30 timeout-minutes: 30
env: env:
# NO_VERSION_LABEL disables embedding the toolchain / git commit hash in version metadata. # `NO_VERSION_LABEL=ON` disables embedding the toolchain / git commit hash in version metadata.
# Otherwise, the version of the SDist has a git hash suffix (e.g., 0.1.0+gitabcdef12), # Otherwise, the version of the SDist has a git hash suffix (e.g., 0.1.0+gitabcdef12),
# but the package built from the SDist has no way to get the git hash (it is not a git repo), # but the package built from the SDist has no way to get the git hash (it is not a git repo),
# leading to inconsistent versions between SDist and built packages (+gitabcdef12 vs. +gitunknown). # leading to inconsistent versions between SDist and built packages (+gitabcdef12 vs. +gitunknown).
NO_VERSION_LABEL: 'OFF' NO_VERSION_LABEL: 'ON'
steps: steps:
- name: Checkout repository - name: Checkout repository
...@@ -72,18 +72,20 @@ jobs: ...@@ -72,18 +72,20 @@ jobs:
uses: hendrikmuhs/ccache-action@v1 uses: hendrikmuhs/ccache-action@v1
with: with:
create-symlink: true create-symlink: true
key: ccache-${{ runner.os }}-${{ runner.arch }}
evict-old-files: "7d" evict-old-files: "7d"
append-timestamp: false
key: sdist-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.cc') }}
restore-keys: |
sdist-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.cc') }}
sdist-${{ runner.os }}-${{ runner.arch }}
${{ runner.os }}-${{ runner.arch }}
- name: Test SDist buildable - name: Test SDist buildable
run: | run: |
TEMP_DIR="$(mktemp -d -t tilelang-sdist-test)" TEMP_DIR="$(mktemp -d -t tilelang-sdist-test)"
cp -r dist "${TEMP_DIR}/dist" cp -r dist "${TEMP_DIR}/dist"
uv venv --seed "${TEMP_DIR}/venv"
source "${TEMP_DIR}/venv/bin/activate"
cd "${TEMP_DIR}" cd "${TEMP_DIR}"
python3 -m pip install --upgrade pip setuptools wheel uv pip install -v dist/*.tar.gz
python3 -m pip install -v dist/*.tar.gz
python3 -c "import tilelang; print(tilelang.__version__)" python3 -c "import tilelang; print(tilelang.__version__)"
- name: Upload SDist - name: Upload SDist
...@@ -125,14 +127,19 @@ jobs: ...@@ -125,14 +127,19 @@ jobs:
fetch-depth: 1 fetch-depth: 1
submodules: recursive submodules: recursive
# NB: CIBW builds wheels in containers on Linux - name: Setup ccache
- name: Setup ccache (macOS only)
if: runner.os == 'macOS'
uses: hendrikmuhs/ccache-action@v1 uses: hendrikmuhs/ccache-action@v1
with: with:
create-symlink: true create-symlink: true
key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}-${{ matrix.target.toolkit }}
evict-old-files: "7d" evict-old-files: "7d"
append-timestamp: false
key: wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}-${{ hashFiles('**/*.cc') }}
restore-keys: |
wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}-${{ hashFiles('**/*.cc') }}
wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}
wheel-${{ runner.os }}-${{ runner.arch }}
${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}
${{ runner.os }}-${{ runner.arch }}
- name: Set CIBW_BUILD - name: Set CIBW_BUILD
run: | run: |
...@@ -147,6 +154,11 @@ jobs: ...@@ -147,6 +154,11 @@ jobs:
echo "CUDA_VERSION=${CUDA_VERSION}" | tee -a "${GITHUB_ENV}" echo "CUDA_VERSION=${CUDA_VERSION}" | tee -a "${GITHUB_ENV}"
fi fi
if [[ "${{ runner.os }}" == "Linux" ]]; then
HOST_CCACHE_DIR="$(ccache --get-config cache_dir)"
echo "CIBW_BEFORE_BUILD_LINUX=yum install -y ccache && ccache -o cache_dir=/host${HOST_CCACHE_DIR}" | tee -a "${GITHUB_ENV}"
fi
- name: Build wheels - name: Build wheels
uses: pypa/cibuildwheel@v3.2 uses: pypa/cibuildwheel@v3.2
with: with:
......
...@@ -104,4 +104,4 @@ cmake-build/ ...@@ -104,4 +104,4 @@ cmake-build/
cmake-build-*/ cmake-build-*/
# Git version for sdist # Git version for sdist
_git_commit.txt .git_commit.txt
...@@ -41,7 +41,16 @@ endif() ...@@ -41,7 +41,16 @@ endif()
find_program(CCACHE_PROGRAM ccache) find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM) if(CCACHE_PROGRAM)
message(STATUS "Using ccache: ${CCACHE_PROGRAM}") message(STATUS "Using ccache: ${CCACHE_PROGRAM} with base_dir=${CMAKE_SOURCE_DIR}")
if(APPLE)
# Passing configs like `ccache base_dir=/xxx cc ...` is supported
# (likely) since ccache 4.x, which has been provided by homebrew.
# Our Linux builder image (manylinux2014 & manylinux_2_28) still
# provides ccache 3.x and do not support this form.
# `cibuildwheel` uses fixed folder on Linux (`/project`) as working directory,
# so cache would work without setting `base_dir`.
set(CCACHE_PROGRAM "${CCACHE_PROGRAM};base_dir=${CMAKE_SOURCE_DIR}")
endif()
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "C compiler launcher") set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "C compiler launcher")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "CXX compiler launcher") set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "CXX compiler launcher")
set(CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "CUDA compiler launcher") set(CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "CUDA compiler launcher")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment