Skip to content

Commit a41c190

Browse files
committed
refactor: Move dynamo tests to tests/py/dynamo
Signed-off-by: Dheeraj Peri <[email protected]> chore: Apply linting Signed-off-by: Dheeraj Peri <[email protected]> chore: Reset WORKSPACE Signed-off-by: Dheeraj Peri <[email protected]>
1 parent bc8f59a commit a41c190

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+215
-46
lines changed

.circleci/config.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ commands:
519519
command: |
520520
set -e
521521
mkdir -p /tmp/artifacts/test_results
522-
cd tests/py
522+
cd tests/py/ts/
523523
pytest --junitxml=/tmp/artifacts/test_results/api/api_test_results.xml api/
524524
pytest --junitxml=/tmp/artifacts/test_results/models/models_test_results.xml models/
525525
pytest --junitxml=/tmp/artifacts/test_results/integrations/integrations_test_results.xml integrations/
@@ -733,49 +733,49 @@ commands:
733733
# =================== FX tests end ======================== #
734734

735735
# =================== Dynamo tests start ======================== #
736-
test-dynamo-fx_ts:
737-
description: "Test the Dynamo fx_ts_compat path"
736+
737+
test-dynamo-torch_compile:
738+
description: "Test Dynamo torch_compile tests"
738739
steps:
739740
- run:
740-
name: Run Dynamo fx_ts_compat core tests
741+
name: Run Dynamo torch_compile tests
741742
command: |
742-
cd py/torch_tensorrt/dynamo/fx_ts_compat/test
743-
pushd core/
744-
pytest --junitxml=/tmp/artifacts/test_results/dynamo/fx_ts_compat/test_results.xml
743+
cd tests/py/dynamo/backend/
744+
pytest --junitxml=/tmp/artifacts/test_results/dynamo/torch_compile/test_results.xml
745745
popd
746746
747747
- store_test_results:
748748
path: /tmp/artifacts
749749
- store_artifacts:
750750
path: /tmp/testlogs
751751

752-
test-dynamo-compile-core:
753-
description: "Test the Dynamo compile path"
752+
test-dynamo-models_torch_compile:
753+
description: "Test the Dynamo models via torch_compile path"
754754
steps:
755755
- run:
756-
name: Run Dynamo compile core tests
756+
name: Run Dynamo models via torch_compile path
757757
command: |
758-
cd py/torch_tensorrt/dynamo/backend
759-
pushd test/
760-
pytest --junitxml=/tmp/artifacts/test_results/dynamo/backend/test_results.xml
758+
cd tests/py/dynamo/models
759+
pip3 install timm
760+
pip3 install transformers
761+
pytest test_models.py --junitxml=/tmp/artifacts/test_results/dynamo/backend/test_results.xml --ir torch_compile
761762
popd
762763
763764
- store_test_results:
764765
path: /tmp/artifacts
765766
- store_artifacts:
766767
path: /tmp/testlogs
767768

768-
test-dynamo-compile:
769-
description: "Test the Dynamo compile path"
769+
test-dynamo-models_torch_export:
770+
description: "Test the Dynamo models via torch_export path"
770771
steps:
771772
- run:
772-
name: Run Dynamo compile E2E tests
773+
name: Run Dynamo models via torch_export path
773774
command: |
774-
cd py/torch_tensorrt/dynamo/
775-
pushd test/
775+
cd tests/py/dynamo/models
776776
pip3 install timm
777777
pip3 install transformers
778-
pytest --junitxml=/tmp/artifacts/test_results/dynamo/backend/test_results.xml --ir dynamo_compile
778+
pytest test_models_export.py --junitxml=/tmp/artifacts/test_results/dynamo/backend/test_results.xml --ir dynamo
779779
popd
780780
781781
- store_test_results:
@@ -1039,9 +1039,9 @@ jobs:
10391039
command: pip3 install --pre /tmp/dist/x86_64-linux/*cp39-cp39*.whl
10401040
# We install torch after torch-trt because pip automatically enforces the version constraint otherwise
10411041
- dump-test-env
1042-
- test-dynamo-compile
1043-
- test-dynamo-compile-core
1044-
- test-dynamo-fx_ts
1042+
- test-dynamo-torch_compile
1043+
- test-dynamo-models_torch_compile
1044+
- test-dynamo-models_torch_export
10451045

10461046
package-x86_64-linux:
10471047
parameters:

py/torch_tensorrt/dynamo/backend/lowering/_fusers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ def fuse_permute_linear(gm: torch.fx.GraphModule):
6969
gm.graph.eliminate_dead_code()
7070
gm.graph.lint()
7171
gm.recompile()
72-
return gm
72+
return gm

py/torch_tensorrt/dynamo/compile.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ def compile(
7474
+ "torch_executed_ops, pass_through_build_failures}"
7575
)
7676

77-
if "use_experimental_fx_rt" in kwargs:
78-
use_experimental_rt = kwargs["use_experimental_fx_rt"]
79-
80-
logger.info(f"Using {'C++' if use_experimental_rt else 'Python'} TRT Runtime")
81-
8277
if not isinstance(inputs, collections.abc.Sequence):
8378
inputs = [inputs]
8479

py/torch_tensorrt/dynamo/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
COSINE_THRESHOLD = 0.99
1212

13+
1314
def use_python_runtime_parser(use_python_runtime: Optional[bool] = None) -> bool:
1415
"""Parses a user-provided input argument regarding Python runtime
1516
@@ -40,6 +41,7 @@ def use_python_runtime_parser(use_python_runtime: Optional[bool] = None) -> bool
4041

4142
return using_python_runtime
4243

44+
4345
def cosine_similarity(gt_tensor, pred_tensor):
4446
gt_tensor = gt_tensor.flatten().to(torch.float32)
4547
pred_tensor = pred_tensor.flatten().to(torch.float32)
@@ -51,6 +53,7 @@ def cosine_similarity(gt_tensor, pred_tensor):
5153

5254
return res
5355

56+
5457
def prepare_inputs(
5558
inputs: Union[_Input.Input, torch.Tensor, Sequence, Dict],
5659
device: torch.device = torch.device("cuda"),

py/torch_tensorrt/dynamo/backend/test/test_backend_compiler.py renamed to tests/py/dynamo/backend/test_backend_compiler.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import torch
2+
import torch_tensorrt
13
from torch_tensorrt.dynamo.backend.lowering import partition
24
from torch.testing._internal.common_utils import run_tests, TestCase
3-
import torch
45
from copy import deepcopy
5-
from torch_tensorrt.dynamo.backend import compile
66
from utils import lower_graph_testing, DECIMALS_OF_AGREEMENT
77

88

@@ -33,8 +33,9 @@ def forward(self, x, y):
3333
torch._dynamo.reset()
3434

3535
# Validate that the results between Torch and Torch-TRT are similar
36-
optimized_model = compile(
36+
optimized_model = torch_tensorrt.compile(
3737
fx_graph,
38+
"torch_compile",
3839
inputs,
3940
min_block_size=1,
4041
pass_through_build_failures=True,
@@ -101,8 +102,9 @@ def forward(self, x, y):
101102
torch._dynamo.reset()
102103

103104
# Validate that the results between Torch and Torch-TRT are similar
104-
optimized_model = compile(
105+
optimized_model = torch_tensorrt.compile(
105106
fx_graph,
107+
"torch_compile",
106108
inputs,
107109
min_block_size=1,
108110
pass_through_build_failures=True,
@@ -143,8 +145,9 @@ def forward(self, x, y):
143145
]
144146

145147
# Validate that the results between Torch and Torch-TRT are similar
146-
optimized_model = compile(
148+
optimized_model = torch_tensorrt.compile(
147149
fx_graph,
150+
"torch_compile",
148151
inputs,
149152
min_block_size=1,
150153
pass_through_build_failures=True,

py/torch_tensorrt/dynamo/backend/test/test_decompositions.py renamed to tests/py/dynamo/backend/test_decompositions.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from utils import lower_graph_testing, DECIMALS_OF_AGREEMENT
33
from torch.testing._internal.common_utils import run_tests, TestCase
44
import torch
5-
from torch_tensorrt.dynamo.backend import compile
5+
import torch_tensorrt
66

77

88
class TestLowering(TestCase):
@@ -162,8 +162,12 @@ def forward(self, x, y, z):
162162
torch._dynamo.reset()
163163

164164
# Validate that the results between Torch and Torch-TRT are similar
165-
optimized_model = compile(
166-
fx_graph, inputs, min_block_size=1, pass_through_build_failures=True
165+
optimized_model = torch_tensorrt.compile(
166+
fx_graph,
167+
"torch_compile",
168+
inputs,
169+
min_block_size=1,
170+
pass_through_build_failures=True,
167171
)
168172
optimized_model_results = optimized_model(*inputs).detach().cpu()
169173
torch_model_results = fx_graph(*inputs).detach().cpu()

py/torch_tensorrt/dynamo/backend/test/test_pre_aot_lowering.py renamed to tests/py/dynamo/backend/test_pre_aot_lowering.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import torch
2+
import torch_tensorrt
23
from utils import lower_graph_testing
34
from torch.testing._internal.common_utils import run_tests, TestCase
4-
from torch_tensorrt.dynamo.backend import compile
55

66

77
class TestMaxPool1D(TestCase):
@@ -39,8 +39,12 @@ def forward(self, x):
3939
torch._dynamo.reset()
4040

4141
# Validate that the results between Torch and Torch-TRT are similar
42-
optimized_model = compile(
43-
fx_graph, inputs, min_block_size=1, pass_through_build_failures=True
42+
optimized_model = torch_tensorrt.compile(
43+
fx_graph,
44+
"torch_compile",
45+
inputs,
46+
min_block_size=1,
47+
pass_through_build_failures=True,
4448
)
4549
optimized_model_results = optimized_model(*inputs).detach().cpu()
4650
torch_model_results = fx_graph(*inputs).detach().cpu()
@@ -85,8 +89,12 @@ def forward(self, x, y):
8589
torch._dynamo.reset()
8690

8791
# Validate that the results between Torch and Torch-TRT are similar
88-
optimized_model = compile(
89-
fx_graph, inputs, min_block_size=1, pass_through_build_failures=True
92+
optimized_model = torch_tensorrt.compile(
93+
fx_graph,
94+
"torch_compile",
95+
inputs,
96+
min_block_size=1,
97+
pass_through_build_failures=True,
9098
)
9199
optimized_model_results = optimized_model(*inputs).detach().cpu()
92100
torch_model_results = fx_graph(*inputs).detach().cpu()

py/torch_tensorrt/dynamo/backend/test/test_specialized_models.py renamed to tests/py/dynamo/backend/test_specialized_models.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from utils import lower_graph_testing
22
from torch.testing._internal.common_utils import run_tests, TestCase
33
import torch
4-
from torch_tensorrt.dynamo.backend import compile
4+
import torch_tensorrt
55

66

77
class TestFakeTensors(TestCase):
@@ -40,8 +40,12 @@ def forward(self, x):
4040
torch._dynamo.reset()
4141

4242
# Validate that the results between Torch and Torch-TRT are similar
43-
optimized_model = compile(
44-
fx_graph, inputs, min_block_size=1, pass_through_build_failures=True
43+
optimized_model = torch_tensorrt.compile(
44+
fx_graph,
45+
"torch_compile",
46+
inputs,
47+
min_block_size=1,
48+
pass_through_build_failures=True,
4549
)
4650
optimized_model_results = optimized_model(*inputs).detach().cpu()
4751
torch_model_results = fx_graph(*inputs).detach().cpu()
@@ -92,8 +96,12 @@ def forward(self, x):
9296
torch._dynamo.reset()
9397

9498
# Validate that the results between Torch and Torch-TRT are similar
95-
optimized_model = compile(
96-
fx_graph, inputs, min_block_size=1, pass_through_build_failures=True
99+
optimized_model = torch_tensorrt.compile(
100+
fx_graph,
101+
"torch_compile",
102+
inputs,
103+
min_block_size=1,
104+
pass_through_build_failures=True,
97105
)
98106
optimized_model_results = optimized_model(*inputs).detach().cpu()
99107
torch_model_results = fx_graph(*inputs).detach().cpu()

0 commit comments

Comments
 (0)