File tree 6 files changed +63
-15
lines changed
onnxscript/tools/benchmark
6 files changed +63
-15
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,32 @@ jobs:
106
106
name : IR profiling results
107
107
path : tests/ir/serde_test_profiles
108
108
109
+ dort :
110
+ strategy :
111
+ fail-fast : false
112
+ matrix :
113
+ os : [ubuntu-latest]
114
+ transformers : ["4.37.2", "4.41.2"]
115
+ torch : ["release", "nightly"]
116
+ python_version : ["3.11"]
117
+ nox-tag : ["test-dort"]
118
+ name :
119
+ - dort
120
+ runs-on : ${{ matrix.os }}
121
+ steps :
122
+ - uses : actions/checkout@v4
123
+ - name : Setup Python ${{ matrix.python_version }}
124
+ uses : actions/setup-python@v5
125
+ with :
126
+ python-version : ${{ matrix.python_version }}
127
+ - name : Install nox
128
+ run : python -m pip install nox
129
+ - name : Pull Test Data
130
+ run : git lfs pull
131
+ - run : |
132
+ nox -t ${{ matrix.nox-tag }} --forcecolor -- ${{ matrix.torch }} ${{ matrix.transformers }}
133
+ name: Run tests
134
+
109
135
build_docs :
110
136
strategy :
111
137
fail-fast : false
Original file line number Diff line number Diff line change 19
19
'numpy==1.26.4; python_version>="3.9"' ,
20
20
"packaging" ,
21
21
"parameterized" ,
22
- "pyinstrument" ,
23
22
"pytest-cov" ,
24
23
"pytest-randomly" ,
25
24
"pytest-subtests" ,
@@ -153,3 +152,32 @@ def test_experimental_torchlib_onnx_ir(session):
153
152
* session .posargs ,
154
153
env = {"TORCHLIB_EXPERIMENTAL_USE_IR" : "1" },
155
154
)
155
+
156
+
157
+ @nox .session (tags = ["test-dort" ])
158
+ def test_dort (session ):
159
+ """Test the conversion of a couple of models from transformers."""
160
+ session .install (
161
+ * COMMON_TEST_DEPENDENCIES ,
162
+ )
163
+ torch_version , transformers_version = session .posargs
164
+
165
+ if torch_version == "nighly" :
166
+ session .install (
167
+ "--pre" ,
168
+ "torch" ,
169
+ "torchvision" ,
170
+ "torchaudio" ,
171
+ "--index-url" ,
172
+ "https://download.pytorch.org/whl/nightly/cpu" ,
173
+ )
174
+ else :
175
+ session .install ("torch" , "torchvision" , "torchaudio" )
176
+
177
+ session .install ("torch" , "torchvision" , "torchaudio" )
178
+ session .install (f"transformers=={ transformers_version } " )
179
+ session .install ("onnxruntime-training==1.17.1" )
180
+
181
+ session .run ("pip" , "list" )
182
+ session .run ("pytest" , "onnxscript" )
183
+ session .run ("pytest" , "tests" )
Original file line number Diff line number Diff line change @@ -62,6 +62,11 @@ def test_export_model_llama_cpu_eager(self):
62
62
63
63
@unittest .skipIf (not has_transformers (), reason = "transformers missing" )
64
64
@unittest .skipIf (not is_onnxruntime_training (), reason = "onnxruntime-training is needed" )
65
+ @unittest .skipIf (
66
+ torch_older_than ("2.4" ),
67
+ reason = "TypeError: _functionalize_sync(): "
68
+ "argument 't' (position 1) must be Tensor, not NoneType" ,
69
+ )
65
70
def test_export_model_phi_cpu_dynamo (self ):
66
71
args = [
67
72
"--verbose" ,
Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ beartype!=0.16.0
24
24
expecttest == 0.1.6
25
25
hypothesis
26
26
parameterized
27
- pyinstrument
28
27
pytest-cov
29
28
pytest-randomly
30
29
pytest-subtests
Original file line number Diff line number Diff line change 10
10
import numpy as np
11
11
import onnx
12
12
import onnxruntime
13
+ import torch
13
14
14
15
from onnxscript import optimizer
15
16
from onnxscript ._legacy_ir import visitor
@@ -29,7 +30,7 @@ def skip_if_no_cuda(reason: str):
29
30
def skip_dec (func ):
30
31
@functools .wraps (func )
31
32
def wrapper (self , * args , ** kwargs ):
32
- if not onnxruntime .get_device () == "GPU" :
33
+ if not torch . cuda . is_available () or not onnxruntime .get_device () == "GPU" :
33
34
raise unittest .SkipTest (f"GPU is not available. { reason } " )
34
35
return func (self , * args , ** kwargs )
35
36
Original file line number Diff line number Diff line change 1
1
# Copyright (c) Microsoft Corporation.
2
2
# Licensed under the MIT License.
3
+ # pylint: disable=import-outside-toplevel
3
4
from __future__ import annotations
4
5
5
6
import pathlib
8
9
import onnx
9
10
import onnx .backend .test
10
11
import parameterized
11
- import pyinstrument
12
12
13
13
import onnxscript .testing
14
14
from onnxscript import ir
25
25
26
26
27
27
class SerdeTest (unittest .TestCase ):
28
- def setUp (self ) -> None :
29
- self .profiler = pyinstrument .Profiler ()
30
-
31
- def tearDown (self ) -> None :
32
- self .profiler .reset ()
33
-
34
28
@parameterized .parameterized .expand (test_args )
35
29
def test_serialization_deserialization_produces_same_model (
36
30
self , _ : str , model_path : pathlib .Path
@@ -41,13 +35,8 @@ def test_serialization_deserialization_produces_same_model(
41
35
onnx .checker .check_model (model )
42
36
43
37
# Profile the serialization and deserialization process
44
- self .profiler .start ()
45
38
ir_model = ir .serde .deserialize_model (model )
46
39
serialized = ir .serde .serialize_model (ir_model )
47
- self .profiler .stop ()
48
- profile_path = pathlib .Path (__file__ ).parent / "serde_test_profiles"
49
- profile_path .mkdir (exist_ok = True )
50
- self .profiler .write_html (profile_path / f"{ self .id ().split ('.' )[- 1 ]} .html" )
51
40
52
41
onnxscript .testing .assert_onnx_proto_equal (serialized , model )
53
42
onnx .checker .check_model (serialized )
You can’t perform that action at this time.
0 commit comments