Skip to content

Commit aa7f562

Browse files
authored
Switch to Ubuntu ARM also run tests in mac (#1935)
Changes: - Switches CI to native Ubuntu ARM runner - Run tests (cpp and python) in mac OS
1 parent 785c7e0 commit aa7f562

File tree

3 files changed

+54
-35
lines changed

3 files changed

+54
-35
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -73,40 +73,34 @@ jobs:
7373
tests/ctranslate2_test tests/data
7474
7575
76-
build-and-test-cpp-aarch64:
77-
runs-on: ubuntu-22.04
76+
build-and-test-cpp-arm64:
77+
runs-on: ${{ matrix.os }}
7878
env:
7979
CT2_VERBOSE: 1
8080
strategy:
8181
matrix:
82-
backend: [openblas]
8382

83+
include:
84+
- os: ubuntu-22.04-arm
85+
backend: openblas
86+
- os: macos-15
87+
backend: ruy
8488
steps:
8589
- uses: actions/checkout@v4
8690
with:
8791
submodules: recursive
8892

89-
- name: Install cross compiler and emulator
90-
run: |
91-
sudo apt-get update
92-
sudo apt-get install -y g++-aarch64-linux-gnu gfortran-aarch64-linux-gnu qemu-user-static
93-
9493
- name: Build with OpenBLAS and Ruy
9594
if: matrix.backend == 'openblas'
9695
run: |
9796
wget https://github.com/xianyi/OpenBLAS/archive/v0.3.13.tar.gz
9897
tar xzvf v0.3.13.tar.gz
9998
cd OpenBLAS-0.3.13
100-
make TARGET=ARMV8 CC=aarch64-linux-gnu-gcc FC=aarch64-linux-gnu-gfortran HOSTCC=gcc NO_LAPACK=1 -j $(nproc)
101-
sudo make PREFIX=/usr/aarch64-linux-gnu install
99+
make TARGET=ARMV8 NO_LAPACK=1 -j $(nproc)
100+
sudo make PREFIX=/usr/local install
102101
cd ..
103-
102+
export OpenBLAS_HOME=/usr/local
104103
cmake \
105-
-DCMAKE_SYSTEM_NAME=Linux \
106-
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
107-
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
108-
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
109-
-DCMAKE_FIND_ROOT_PATH=/usr/aarch64-linux-gnu \
110104
-DOPENMP_RUNTIME=COMP \
111105
-DCMAKE_INSTALL_PREFIX=$PWD/install \
112106
-DWITH_MKL=OFF \
@@ -115,7 +109,19 @@ jobs:
115109
-DBUILD_TESTS=ON \
116110
.
117111
make -j $(nproc) install
118-
112+
113+
- name: Build Ruy
114+
if: matrix.backend == 'ruy'
115+
run: |
116+
CMAKE_EXTRA_OPTIONS='-DCMAKE_OSX_ARCHITECTURES=arm64 -DWITH_ACCELERATE=ON -DWITH_MKL=OFF -DOPENMP_RUNTIME=NONE -DWITH_RUY=ON'
117+
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
118+
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \
119+
-DCMAKE_INSTALL_PREFIX=$PWD/install \
120+
-DBUILD_TESTS=ON \
121+
$CMAKE_EXTRA_OPTIONS \
122+
.
123+
make -j $(nproc) install
124+
119125
- name: Download test data
120126
run: |
121127
wget https://opennmt-models.s3.amazonaws.com/transliteration-aren-all.tar.gz
@@ -124,9 +130,6 @@ jobs:
124130
- name: Test
125131
run: |
126132
tests/ctranslate2_test tests/data
127-
env:
128-
QEMU_LD_PREFIX: /usr/aarch64-linux-gnu
129-
130133
131134
build-python-wheels:
132135
runs-on: ${{ matrix.os }}
@@ -183,7 +186,22 @@ jobs:
183186
runs-on: ${{ matrix.os }}
184187
strategy:
185188
matrix:
186-
os: [ubuntu-22.04, windows-2022]
189+
include:
190+
- os: ubuntu-22.04
191+
artifact_pattern: python-wheels-Linux-auto64
192+
wheel_pattern: "*cp310*manylinux*x86_64.whl"
193+
194+
- os: ubuntu-22.04-arm
195+
artifact_pattern: python-wheels-Linux-aarch64
196+
wheel_pattern: "*cp310*manylinux*_aarch64.whl"
197+
198+
#- os: windows-2022
199+
# artifact_pattern: python-wheels-Windows-auto64
200+
# wheel_pattern: "*cp310*win*.whl"
201+
202+
- os: macos-15
203+
artifact_pattern: python-wheels-macOS-arm64
204+
wheel_pattern: "*cp310*macosx*arm64.whl"
187205

188206
steps:
189207
- name: Set up Python 3.10.11
@@ -201,23 +219,18 @@ jobs:
201219
- name: Download Python wheels
202220
uses: actions/download-artifact@v4
203221
with:
204-
pattern: python-wheels-${{ runner.os }}-*
222+
pattern: ${{ matrix.artifact_pattern }}
205223
merge-multiple: true
206224
path: .
207225

208226
- name: Install wheel
209-
if: startsWith(matrix.os, 'ubuntu')
210-
run: |
211-
pip install *cp310*manylinux*x86_64.whl
212-
213-
- name: Install wheel
214-
if: startsWith(matrix.os, 'windows')
215227
shell: bash
216228
run: |
217-
pip install *cp310*win*.whl
218-
219-
- name: Run tests
220-
shell: bash
229+
ls -l
230+
find .
231+
pip install ${{ matrix.wheel_pattern }}
232+
233+
- name: Test Python wheel
221234
run: |
222235
pytest -v python/tests/ --ignore=python/tests/test_opennmt_tf.py
223236
@@ -256,7 +269,7 @@ jobs:
256269
257270
publish-python-wheels-on-pypi:
258271
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
259-
needs: [build-and-test-cpp-x86_64, build-python-wheels, test-python-wheels, check-python-style]
272+
needs: [build-and-test-cpp-x86_64, build-and-test-cpp-arm64, build-python-wheels, test-python-wheels, check-python-style]
260273
runs-on: ubuntu-22.04
261274

262275
steps:

python/tests/test_transformers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def _to_numpy(storage, device):
343343
)
344344

345345

346-
@test_utils.only_on_linux
346+
@test_utils.only_on_linux_and_intel
347347
def test_transformers_gptbigcode(clear_transformers_cache, tmp_dir):
348348
import transformers
349349

@@ -410,7 +410,7 @@ def test_transformers_lm_scoring(self, tmp_dir):
410410
assert not output.tokens
411411
assert not output.log_probs
412412

413-
@test_utils.only_on_linux
413+
@test_utils.only_on_linux_and_intel
414414
@test_utils.on_available_devices
415415
@pytest.mark.parametrize("return_log_probs", [True, False])
416416
@pytest.mark.parametrize("tensor_input", [True, False])

python/tests/test_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import platform
23
import sys
34

45
import numpy as np
@@ -39,6 +40,11 @@ def array_equal(a, b):
3940
sys.platform != "linux", reason="Test case only running on Linux"
4041
)
4142

43+
only_on_linux_and_intel = pytest.mark.skipif(
44+
sys.platform != "linux" or "Intel" not in platform.processor(),
45+
reason="Test case only running on Linux with Intel CPU",
46+
)
47+
4248
require_cuda = pytest.mark.skipif(
4349
ctranslate2.get_cuda_device_count() == 0, reason="Test case requires a CUDA device"
4450
)

0 commit comments

Comments
 (0)