Skip to content

Commit 8f22a22

Browse files
committed
ci
1 parent ef9f070 commit 8f22a22

File tree

4 files changed

+77
-88
lines changed

4 files changed

+77
-88
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -67,45 +67,30 @@ jobs:
6767
run: python -m pip freeze
6868

6969
- name: tiny-llm torch.export.export
70-
run: |
71-
export PYTHONPATH=.
72-
python _unittests/ut_torch_models/test_tiny_llms.py
70+
run: PYTHONPATH=. python _unittests/ut_torch_models/test_tiny_llms.py
7371

7472
- name: tiny-llm onnx
75-
run: |
76-
export PYTHONPATH=.
77-
python _unittests/ut_torch_models/test_tiny_llms_onnx.py
73+
run: PYTHONPATH=. python _unittests/ut_torch_models/test_tiny_llms_onnx.py
7874
continue-on-error: true # connectivity issues
7975

8076
- name: tiny-llm example
81-
run: |
82-
export PYTHONPATH=.
83-
python _doc/examples/plot_export_tiny_llm.py
77+
run: PYTHONPATH=. python _doc/examples/plot_export_tiny_llm.py
8478
continue-on-error: true # connectivity issues
8579

8680
- name: tiny-llm bypass
87-
run: |
88-
export PYTHONPATH=.
89-
python _doc/examples/plot_export_tiny_llm_patched.py
81+
run: PYTHONPATH=. python _doc/examples/plot_export_tiny_llm_patched.py
9082
continue-on-error: true # connectivity issues
9183

84+
- name: run tests bypassed
85+
run: PYTHONPATH=. python _unittests/ut_torch_models/test_tiny_llms_bypassed.py
86+
9287
- name: run tests
9388
run: |
9489
pip install pytest
95-
export PYTHONPATH=.
96-
UNITTEST_GOING=1 pytest --durations=10 _unittests --ignore _unittests/ut_reference/test_backend_extended_reference_evaluator.py --ignore _unittests/ut_reference/test_backend_onnxruntime_evaluator.py
97-
export PYTHONPATH=
90+
PYTHONPATH=. UNITTEST_GOING=1 pytest --durations=10 _unittests --ignore _unittests/ut_reference/test_backend_extended_reference_evaluator.py --ignore _unittests/ut_reference/test_backend_onnxruntime_evaluator.py --ignore _unittests/ut_torch_models/test_tiny_llms_bypassed.py
9891
9992
- name: run backend tests python
100-
run: |
101-
pip install pytest
102-
export PYTHONPATH=.
103-
UNITTEST_GOING=1 pytest --durations=10 _unittests/ut_reference/test_backend_extended_reference_evaluator.py
104-
export PYTHONPATH=
93+
run: PYTHONPATH=. UNITTEST_GOING=1 pytest --durations=10 _unittests/ut_reference/test_backend_extended_reference_evaluator.py
10594

10695
- name: run backend tests onnxruntime
107-
run: |
108-
pip install pytest
109-
export PYTHONPATH=.
110-
UNITTEST_GOING=1 pytest --durations=10 _unittests/ut_reference/test_backend_onnxruntime_evaluator.py --maxfail=15
111-
export PYTHONPATH=
96+
run: PYTHONPATH=. UNITTEST_GOING=1 pytest --durations=10 _unittests/ut_reference/test_backend_onnxruntime_evaluator.py --maxfail=15

.github/workflows/documentation.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,25 @@ jobs:
5454
run: python -m pip freeze
5555

5656
- name: tiny-llm torch.export.export
57-
run: |
58-
export PYTHONPATH=.
59-
python _unittests/ut_torch_models/test_tiny_llms.py
57+
run: PYTHONPATH=. python _unittests/ut_torch_models/test_tiny_llms.py
6058

6159
- name: tiny-llm onnx
62-
run: |
63-
export PYTHONPATH=.
64-
python _unittests/ut_torch_models/test_tiny_llms_onnx.py
60+
run: PYTHONPATH=. python _unittests/ut_torch_models/test_tiny_llms_onnx.py
6561
continue-on-error: true
6662

6763
- name: tiny-llm example
68-
run: |
69-
export PYTHONPATH=.
70-
python _doc/examples/plot_export_tiny_llm.py
64+
run: PYTHONPATH=. python _doc/examples/plot_export_tiny_llm.py
7165

7266
- name: tiny-llm bypass
73-
run: |
74-
export PYTHONPATH=.
75-
python _doc/examples/plot_export_tiny_llm_patched.py
67+
run: PYTHONPATH=. python _doc/examples/plot_export_tiny_llm_patched.py
68+
69+
- name: run tests bypassed
70+
run: PYTHONPATH=. python _unittests/ut_torch_models/test_tiny_llms_bypassed.py
7671

7772
- name: Generate coverage report
7873
run: |
79-
pip install pytest
80-
pip install pytest-cov
81-
export PYTHONPATH=.
82-
UNITTEST_GOING=1 pytest --cov=./onnx_diagnostic/ --cov-report=xml --durations=10 _unittests --ignore _unittests/ut_reference/test_backend_extended_reference_evaluator.py --ignore _unittests/ut_reference/test_backend_onnxruntime_evaluator.py
83-
export PYTHONPATH=
74+
pip install pytest pytest-cov
75+
export PYTHONPATH=. UNITTEST_GOING=1 pytest --cov=./onnx_diagnostic/ --cov-report=xml --durations=10 _unittests --ignore _unittests/ut_reference/test_backend_extended_reference_evaluator.py --ignore _unittests/ut_reference/test_backend_onnxruntime_evaluator.py --ignore _unittests/ut_torch_models/test_tiny_llms_bypassed.py
8476
8577
- name: Upload coverage reports to Codecov
8678
uses: codecov/codecov-action@v3
Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import copy
22
import unittest
33
import torch
4-
from transformers.cache_utils import DynamicCache
54
from onnx_diagnostic.ext_test_case import ExtTestCase, ignore_warnings, requires_transformers
65
from onnx_diagnostic.torch_models.llms import get_tiny_llm
76
from onnx_diagnostic.helpers import string_type
8-
from onnx_diagnostic.torch_export_patches import bypass_export_some_errors
9-
from onnx_diagnostic.torch_export_patches.patches.patch_transformers import (
10-
patched_DynamicCache,
11-
)
127

138

149
class TestTinyLlm(ExtTestCase):
@@ -33,47 +28,6 @@ def test_export_tiny_llm_1(self):
3328
got = ep.module()(**inputs)
3429
self.assertEqualArrayAny(expected, got)
3530

36-
@ignore_warnings(UserWarning)
37-
def test_export_tiny_llm_2_bypassed(self):
38-
data = get_tiny_llm()
39-
model, inputs = data["model"], data["inputs"]
40-
expected = model(**copy.deepcopy(inputs))
41-
self.assertEqual(
42-
{"attention_mask", "past_key_values", "input_ids", "position_ids"}, set(inputs)
43-
)
44-
45-
with bypass_export_some_errors(
46-
patch_torch=False, patch_transformers=True, catch_constraints=False, verbose=10
47-
) as modificator:
48-
49-
for k in patched_DynamicCache._PATCHES_:
50-
self.assertEqual(getattr(patched_DynamicCache, k), getattr(DynamicCache, k))
51-
52-
inputs = modificator(copy.deepcopy(inputs))
53-
54-
def debug():
55-
print("***", string_type(inputs, with_shape=True))
56-
print("***", data["dynamic_shapes"])
57-
import torch.export._draft_export
58-
59-
ep, report = torch.export._draft_export.draft_export(
60-
model,
61-
(),
62-
kwargs=inputs,
63-
dynamic_shapes=data["dynamic_shapes"],
64-
strict=False,
65-
)
66-
print(report)
67-
68-
if self._debug():
69-
debug()
70-
71-
ep = torch.export.export(
72-
model, (), kwargs=inputs, dynamic_shapes=data["dynamic_shapes"], strict=False
73-
)
74-
got = ep.module()(**inputs)
75-
self.assertEqualArrayAny(expected, got)
76-
7731

7832
if __name__ == "__main__":
7933
unittest.main(verbosity=2)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import copy
2+
import unittest
3+
import torch
4+
from transformers.cache_utils import DynamicCache
5+
from onnx_diagnostic.ext_test_case import ExtTestCase, ignore_warnings
6+
from onnx_diagnostic.torch_models.llms import get_tiny_llm
7+
from onnx_diagnostic.helpers import string_type
8+
from onnx_diagnostic.torch_export_patches import bypass_export_some_errors
9+
from onnx_diagnostic.torch_export_patches.patches.patch_transformers import (
10+
patched_DynamicCache,
11+
)
12+
13+
14+
class TestTinyLlmBypassed(ExtTestCase):
15+
@ignore_warnings(UserWarning)
16+
def test_export_tiny_llm_2_bypassed(self):
17+
data = get_tiny_llm()
18+
model, inputs = data["model"], data["inputs"]
19+
expected = model(**copy.deepcopy(inputs))
20+
self.assertEqual(
21+
{"attention_mask", "past_key_values", "input_ids", "position_ids"}, set(inputs)
22+
)
23+
24+
with bypass_export_some_errors(
25+
patch_torch=False, patch_transformers=True, catch_constraints=False, verbose=10
26+
) as modificator:
27+
28+
for k in patched_DynamicCache._PATCHES_:
29+
self.assertEqual(getattr(patched_DynamicCache, k), getattr(DynamicCache, k))
30+
31+
inputs = modificator(copy.deepcopy(inputs))
32+
33+
def debug():
34+
print("***", string_type(inputs, with_shape=True))
35+
print("***", data["dynamic_shapes"])
36+
import torch.export._draft_export
37+
38+
ep, report = torch.export._draft_export.draft_export(
39+
model,
40+
(),
41+
kwargs=inputs,
42+
dynamic_shapes=data["dynamic_shapes"],
43+
strict=False,
44+
)
45+
print(report)
46+
47+
if self._debug():
48+
debug()
49+
50+
ep = torch.export.export(
51+
model, (), kwargs=inputs, dynamic_shapes=data["dynamic_shapes"], strict=False
52+
)
53+
got = ep.module()(**inputs)
54+
self.assertEqualArrayAny(expected, got)
55+
56+
57+
if __name__ == "__main__":
58+
unittest.main(verbosity=2)

0 commit comments

Comments
 (0)