Skip to content

Commit 5c2f2ff

Browse files
authored
Add ccache support to TE and use it in GitHub actions (#2444)
* Add ccache support to TE and use it in GitHub actions Signed-off-by: Przemek Tredak <[email protected]> * Move to allowed action with sccache Signed-off-by: Przemek Tredak <[email protected]> * Properly handle sccache Signed-off-by: Przemek Tredak <[email protected]> * Fix typo Signed-off-by: Przemek Tredak <[email protected]> * Removing ccache from the custom docker workflows where we can't run the action in the container Signed-off-by: Przemek Tredak <[email protected]> * JAX already uses same cmake options to build the extension so there is no need to set CXX too Signed-off-by: Przemek Tredak <[email protected]> * Removed the unnecessary env variables Signed-off-by: Przemek Tredak <[email protected]> --------- Signed-off-by: Przemek Tredak <[email protected]>
1 parent dbd0197 commit 5c2f2ff

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ jobs:
2424
uses: actions/checkout@v3
2525
with:
2626
submodules: recursive
27+
- name: ccache
28+
uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad
2729
- name: 'Build'
28-
run: pip install --no-build-isolation . -v
30+
run: NVTE_USE_CCACHE=1 NVTE_CCACHE_BIN=sccache pip install --no-build-isolation . -v
2931
env:
3032
NVTE_FRAMEWORK: none
3133
MAX_JOBS: 1
34+
SCCACHE_GHA_ENABLED: "true"
3235
- name: 'Sanity check'
3336
run: python3 -c "import transformer_engine"
3437
working-directory: /
@@ -94,11 +97,15 @@ jobs:
9497
uses: actions/checkout@v3
9598
with:
9699
submodules: recursive
100+
- name: ccache
101+
uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad
97102
- name: 'Build'
98-
run: pip install --no-build-isolation . -v
103+
run: |
104+
NVTE_CCACHE_BIN=sccache NVTE_USE_CCACHE=1 pip install --no-build-isolation . -v
99105
env:
100106
NVTE_FRAMEWORK: jax
101107
MAX_JOBS: 1
108+
SCCACHE_GHA_ENABLED: "true"
102109
- name: 'Sanity check'
103110
run: python3 tests/jax/test_sanity_import.py
104111
all:
@@ -140,7 +147,6 @@ jobs:
140147
pip install pybind11[global] einops onnxscript && \
141148
pip install torch --no-cache-dir --index-url https://download.pytorch.org/whl/cu130
142149
'
143-
144150
- name: 'Build'
145151
run: docker exec builder bash -c 'pip install --no-cache-dir --no-build-isolation . -v --no-deps'
146152
env:

build_tools/build_ext.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ def _build_cmake(self, build_dir: Path, install_dir: Path) -> None:
6161
f"-DCMAKE_BUILD_TYPE={build_type}",
6262
f"-DCMAKE_INSTALL_PREFIX={install_dir}",
6363
]
64+
if bool(int(os.getenv("NVTE_USE_CCACHE", "0"))):
65+
ccache_bin = os.getenv("NVTE_CCACHE_BIN", "ccache")
66+
configure_command += [
67+
f"-DCMAKE_CXX_COMPILER_LAUNCHER={ccache_bin}",
68+
f"-DCMAKE_CUDA_COMPILER_LAUNCHER={ccache_bin}",
69+
]
6470
configure_command += self.cmake_flags
6571

6672
import pybind11

0 commit comments

Comments
 (0)