Skip to content

Commit 1871c3a

Browse files
guangy10Guang Yang
andauthored
Run CI on Linux platform (#40)
Co-authored-by: Guang Yang <[email protected]>
1 parent d3c5448 commit 1871c3a

File tree

4 files changed

+47
-33
lines changed

4 files changed

+47
-33
lines changed

.github/workflows/test_models.yml

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,32 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
build:
14+
discover-tests:
15+
runs-on: ubuntu-22.04
16+
outputs:
17+
model_names: ${{ steps.set-matrix.outputs.model_names }}
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Find model tests
21+
id: set-matrix
22+
run: |
23+
# Find all test files and extract model names correctly
24+
MODEL_NAMES=$(find tests/models -name "test_modeling_*.py" -type f | sed 's|tests/models/test_modeling_||' | sed 's|\.py$||' | paste -sd "," -)
25+
echo "model_names=[\"${MODEL_NAMES//,/\",\"}\"]" >> $GITHUB_OUTPUT
26+
27+
# Display all discovered models
28+
echo "Discovered models:"
29+
echo "$MODEL_NAMES" | tr ',' '\n' | sort | awk '{print "- " $0}'
30+
31+
run-tests:
32+
needs: discover-tests
1533
strategy:
1634
fail-fast: false
1735
matrix:
18-
test-modeling:
19-
# The model name MUST match with the tests/models/test_modeling_<name>.py
20-
- common
21-
- albert
22-
- bert
23-
- cvt
24-
- deit
25-
- distilbert
26-
- dit
27-
- efficientnet
28-
- focalnet
29-
- gemma
30-
- gemma2
31-
- llama
32-
- mobilevit
33-
- mobilevit2
34-
- olmo
35-
- phi4
36-
- pvt
37-
- qwen2
38-
- roberta
39-
- smollm
40-
- swin
41-
- t5
42-
- vit
43-
- whisper
36+
test-modeling: ${{ fromJson(needs.discover-tests.outputs.model_names) }}
4437
executorch-version: ['0.4.0', '0.6.0rc', 'nightly']
45-
python-version: ['3.10', '3.11', '3.12']
46-
os: [macos-15]
38+
python-version: ['3.11']
39+
os: [macos-15, ubuntu-22.04]
4740

4841
# Custom job name, now shortened and cleaner
4942
name: ${{ matrix.test-modeling }} (et=${{ matrix.executorch-version }}, py=${{ matrix.python-version }}, ${{ matrix.os }})
@@ -73,6 +66,5 @@ jobs:
7366
pip install '.[tests]'
7467
pip list
7568
- name: Run tests
76-
working-directory: tests
7769
run: |
78-
RUN_SLOW=1 pytest models/test_modeling_${{ matrix.test-modeling }}.py -s -vvvv --durations=0 --log-cli-level=INFO
70+
RUN_SLOW=1 pytest tests/models/test_modeling_${{ matrix.test-modeling }}.py -s -vvvv --durations=0 --log-cli-level=INFO

tests/models/test_modeling_gemma.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import logging
1818
import os
1919
import subprocess
20+
import sys
2021
import tempfile
2122
import unittest
2223

@@ -32,6 +33,10 @@
3233
from ..utils import check_causal_lm_output_quality
3334

3435

36+
is_linux_ci = sys.platform.startswith("linux") and os.environ.get("GITHUB_ACTIONS") == "true"
37+
38+
39+
@pytest.mark.skipif(is_linux_ci, reason="OOM on linux runner")
3540
class ExecuTorchModelIntegrationTest(unittest.TestCase):
3641
def __init__(self, *args, **kwargs):
3742
super().__init__(*args, **kwargs)

tests/models/test_modeling_gemma2.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import logging
1818
import os
1919
import subprocess
20+
import sys
2021
import tempfile
2122
import unittest
2223

@@ -32,6 +33,10 @@
3233
from ..utils import check_causal_lm_output_quality
3334

3435

36+
is_linux_ci = sys.platform.startswith("linux") and os.environ.get("GITHUB_ACTIONS") == "true"
37+
38+
39+
@pytest.mark.skipif(is_linux_ci, reason="OOM on linux runner")
3540
class ExecuTorchModelIntegrationTest(unittest.TestCase):
3641
def __init__(self, *args, **kwargs):
3742
super().__init__(*args, **kwargs)

tests/models/test_modeling_llama.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import logging
1818
import os
1919
import subprocess
20+
import sys
2021
import tempfile
2122
import unittest
2223

@@ -32,6 +33,9 @@
3233
from ..utils import check_causal_lm_output_quality
3334

3435

36+
is_linux_ci = sys.platform.startswith("linux") and os.environ.get("GITHUB_ACTIONS") == "true"
37+
38+
3539
class ExecuTorchModelIntegrationTest(unittest.TestCase):
3640
def __init__(self, *args, **kwargs):
3741
super().__init__(*args, **kwargs)
@@ -43,15 +47,23 @@ def test_llama3_2_1b_export_to_executorch(self):
4347
task = "text-generation"
4448
recipe = "xnnpack"
4549
with tempfile.TemporaryDirectory() as tempdir:
50+
out_dir = f"{tempdir}/executorch"
4651
subprocess.run(
47-
f"optimum-cli export executorch --model {model_id} --task {task} --recipe {recipe} --output_dir {tempdir}/executorch",
52+
f"optimum-cli export executorch --model {model_id} --task {task} --recipe {recipe} --output_dir {out_dir}",
4853
shell=True,
4954
check=True,
5055
)
51-
self.assertTrue(os.path.exists(f"{tempdir}/executorch/model.pte"))
56+
pte_full_path = f"{out_dir}/model.pte"
57+
self.assertTrue(os.path.exists(pte_full_path))
58+
59+
# Explicitly delete the PTE file to free up disk space
60+
if os.path.exists(pte_full_path):
61+
os.remove(pte_full_path)
62+
gc.collect()
5263

5364
@slow
5465
@pytest.mark.run_slow
66+
@pytest.mark.skipif(is_linux_ci, reason="OOM on linux runner")
5567
def test_llama3_2_1b_text_generation(self):
5668
# TODO: Switch to use meta-llama/Llama-3.2-1B once https://github.com/huggingface/optimum/issues/2127 is fixed
5769
# model_id = "lama/Llama-3.2-1B"

0 commit comments

Comments
 (0)