Skip to content

Commit 05e8510

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]>
1 parent 7ed0904 commit 05e8510

Some content is hidden

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

42 files changed

+320
-61
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:

WORKSPACE

Lines changed: 105 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,83 @@ local_repository(
4141
new_local_repository(
4242
name = "cuda",
4343
build_file = "@//third_party/cuda:BUILD",
44-
path = "/usr/local/cuda-12.1/",
44+
path = "/usr/local/cuda-11.8/",
4545
)
4646

47+
new_local_repository(
48+
name = "cublas",
49+
build_file = "@//third_party/cublas:BUILD",
50+
path = "/usr",
51+
)
4752
#############################################################################################################
4853
# Tarballs and fetched dependencies (default - use in cases when building from precompiled bin and tarballs)
4954
#############################################################################################################
5055

56+
# Pytorch 1.13
57+
# http_archive(
58+
# name = "libtorch",
59+
# build_file = "@//third_party/libtorch:BUILD",
60+
# sha256 = "0a013dceedb252f4965b666a2ad772d962135597db5889bd5d43644697c17dbc",
61+
# strip_prefix = "libtorch",
62+
# urls = ["https://download.pytorch.org/libtorch/cu117/libtorch-cxx11-abi-shared-with-deps-1.13.0%2Bcu117.zip"],
63+
# )
64+
65+
# http_archive(
66+
# name = "libtorch_pre_cxx11_abi",
67+
# build_file = "@//third_party/libtorch:BUILD",
68+
# sha256 = "cdbd43985ad9d5886793d5dc455d665cf3fd4b4617ef1094479678ff210ed0af",
69+
# strip_prefix = "libtorch",
70+
# urls = ["https://download.pytorch.org/libtorch/cu117/libtorch-shared-with-deps-1.13.0%2Bcu117.zip"],
71+
# )
72+
73+
# Pyt 1.14
74+
# http_archive(
75+
# name = "libtorch",
76+
# build_file = "@//third_party/libtorch:BUILD",
77+
# sha256 = "28f352d980191492758fbeb6773eda509d3d1917c59a7f52829af1c6b521bbc7",
78+
# strip_prefix = "libtorch",
79+
# urls = ["https://download.pytorch.org/libtorch/nightly/cu117/libtorch-cxx11-abi-shared-with-deps-1.14.0.dev20221114%2Bcu117.zip"],
80+
# )
81+
82+
# http_archive(
83+
# name = "libtorch_pre_cxx11_abi",
84+
# build_file = "@//third_party/libtorch:BUILD",
85+
# sha256 = "6e1ee2893cfd2ce3d69604d9988e0f5133aeee45da611edd07cb633f78966ce3",
86+
# strip_prefix = "libtorch",
87+
# urls = ["https://download.pytorch.org/libtorch/nightly/cu117/libtorch-shared-with-deps-1.14.0.dev20221114%2Bcu117.zip"],
88+
# )
89+
90+
# Pytorch 2.0
91+
# http_archive(
92+
# name = "libtorch",
93+
# build_file = "@//third_party/libtorch:BUILD",
94+
# # sha256 = "78f2646bbc46024d6be6db06eac19aea08206b1b84a065af04574a8d92ee3f01",
95+
# strip_prefix = "libtorch",
96+
# urls = ["https://download.pytorch.org/libtorch/cu117/libtorch-cxx11-abi-shared-with-deps-2.0.0%2Bcu117.zip"],
97+
# )
98+
#
99+
# http_archive(
100+
# name = "libtorch_pre_cxx11_abi",
101+
# build_file = "@//third_party/libtorch:BUILD",
102+
# # sha256 = "d76af42fd10554b0a9c0e50fd13e0988ea8d2d9912d2bc659d0019ed047882cc",
103+
# strip_prefix = "libtorch",
104+
# urls = ["https://download.pytorch.org/libtorch/cu117/libtorch-shared-with-deps-2.0.0%2Bcu117.zip"],
105+
# )
106+
51107
http_archive(
52108
name = "libtorch",
53109
build_file = "@//third_party/libtorch:BUILD",
54-
sha256 = "5ba55259b65e071346a2b547b8d1378595f1467a39aaa923fecb09f134f1bcba",
110+
sha256 = "999becce82b73e566d0ffe010cd21fea8cf3a33f90f09dcc6b01150b820ae063",
55111
strip_prefix = "libtorch",
56-
urls = ["https://download.pytorch.org/libtorch/nightly/cu121/libtorch-cxx11-abi-shared-with-deps-2.1.0.dev20230619%2Bcu121.zip"],
112+
urls = ["https://download.pytorch.org/libtorch/nightly/cu118/libtorch-cxx11-abi-shared-with-deps-2.1.0.dev20230605%2Bcu118.zip"],
57113
)
58114

59115
http_archive(
60116
name = "libtorch_pre_cxx11_abi",
61117
build_file = "@//third_party/libtorch:BUILD",
62-
sha256 = "8f6661bfc11597e77400e9e36cc8dd8e5e385ba82361d630d9ccede8518d7c7e",
118+
sha256 = "786cc728c63ea69c40bd8fb535cf8e5e1dfff1d43eaad3eb5256b9ed89c1b268",
63119
strip_prefix = "libtorch",
64-
urls = ["https://download.pytorch.org/libtorch/nightly/cu121/libtorch-shared-with-deps-2.1.0.dev20230619%2Bcu121.zip"],
120+
urls = ["https://download.pytorch.org/libtorch/nightly/cu118/libtorch-shared-with-deps-2.1.0.dev20230605%2Bcu118.zip"],
65121
)
66122

67123
# Download these tarballs manually from the NVIDIA website
@@ -71,23 +127,57 @@ http_archive(
71127
http_archive(
72128
name = "cudnn",
73129
build_file = "@//third_party/cudnn/archive:BUILD",
74-
sha256 = "79d77a769c7e7175abc7b5c2ed5c494148c0618a864138722c887f95c623777c",
75-
strip_prefix = "cudnn-linux-x86_64-8.8.1.3_cuda12-archive",
130+
strip_prefix = "cudnn-linux-x86_64-8.5.0.96_cuda11-archive",
76131
urls = [
77-
"https://developer.nvidia.com/downloads/compute/cudnn/secure/8.8.1/local_installers/12.0/cudnn-linux-x86_64-8.8.1.3_cuda12-archive.tar.xz",
132+
"file:////home/dperi/Downloads/cudnn/cudnn-linux-x86_64-8.5.0.96_cuda11-archive.tar.xz",
78133
],
79134
)
80135

136+
# http_archive(
137+
# name = "tensorrt",
138+
# urls = ["http://cuda-repo/release-candidates/Libraries/TensorRT/v8.5/8.5.1.7-d95eb1a4/11.8-r520/Linux-x64-agnostic/tar/TensorRT-8.5.1.7.Linux.x86_64-gnu.cuda-11.8.cudnn8.6.tar.gz",],
139+
# sha256 = "39cc7f077057d1363794e8ff51c4cf21a5dbeccf1116b0020ba0dae0f3063076",
140+
# build_file = "@//third_party/tensorrt/archive:BUILD",
141+
# strip_prefix = "TensorRT-8.5.1.7"
142+
# )
143+
81144
http_archive(
82145
name = "tensorrt",
146+
# urls = ["http://cuda-repo/release-candidates/Libraries/TensorRT/v8.5/8.5.1.7-d95eb1a4/11.8-r520/Linux-x64-agnostic/tar/TensorRT-8.5.1.7.Linux.x86_64-gnu.cuda-11.8.cudnn8.6.tar.gz",],
147+
urls = ["file:////home/dperi/Downloads/public_trt/TensorRT-8.6.1.6.Linux.x86_64-gnu.cuda-11.8.tar.gz",],
148+
# sha256 = "39cc7f077057d1363794e8ff51c4cf21a5dbeccf1116b0020ba0dae0f3063076",
83149
build_file = "@//third_party/tensorrt/archive:BUILD",
84-
sha256 = "0f8157a5fc5329943b338b893591373350afa90ca81239cdadd7580cd1eba254",
85-
strip_prefix = "TensorRT-8.6.1.6",
86-
urls = [
87-
"https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/secure/8.6.1/tars/TensorRT-8.6.1.6.Linux.x86_64-gnu.cuda-12.0.tar.gz",
88-
],
150+
strip_prefix = "TensorRT-8.6.1.6"
89151
)
90152

153+
# http_archive(
154+
# name = "tensorrt",
155+
# # urls = ["http://cuda-repo/release-candidates/Libraries/TensorRT/v8.5/8.5.1.7-d95eb1a4/11.8-r520/Linux-x64-agnostic/tar/TensorRT-8.5.1.7.Linux.x86_64-gnu.cuda-11.8.cudnn8.6.tar.gz",],
156+
# urls = ["file:////home/dperi/Downloads/public_trt/TensorRT-8.5.2.2.Linux.x86_64-gnu.cuda-11.8.cudnn8.6.tar.gz",],
157+
# # sha256 = "39cc7f077057d1363794e8ff51c4cf21a5dbeccf1116b0020ba0dae0f3063076",
158+
# build_file = "@//third_party/tensorrt/archive:BUILD",
159+
# strip_prefix = "TensorRT-8.5.2.2"
160+
# )
161+
162+
# http_archive(
163+
# name = "cudnn",
164+
# build_file = "@//third_party/cudnn/archive:BUILD",
165+
# # sha256 = "d07e15cf1f59ae822ce9cdb04e051cb936b99b727e586f2b61ed04a5f08s35bd2",
166+
# strip_prefix = "cudnn-linux-x86_64-8.4.1.50_cuda11.6-archive",
167+
# urls = [
168+
# "file:////home/dperi/Downloads/cudnn/cudnn-linux-x86_64-8.4.1.50_cuda11.6-archive.tar.xz",
169+
# ],
170+
# )
171+
172+
# http_archive(
173+
# name = "tensorrt",
174+
# urls = ["http://cuda-repo/release-candidates/Libraries/TensorRT/v8.4/8.4.3.1-74b5c2dc/11.6-r510/Linux-x64-agnostic/tar/TensorRT-8.4.3.1.Linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz",],
175+
# sha256 = "8d7c2085c1639dcc73875048c23598a8526ce3089136876e31d90258e49e4f61",
176+
# build_file = "@//third_party/tensorrt/archive:BUILD",
177+
# strip_prefix = "TensorRT-8.4.3.1"
178+
# )
179+
180+
91181
####################################################################################
92182
# Locally installed dependencies (use in cases of custom dependencies or aarch64)
93183
####################################################################################
@@ -111,11 +201,11 @@ http_archive(
111201
# build_file = "third_party/libtorch/BUILD"
112202
#)
113203

114-
#new_local_repository(
204+
# new_local_repository(
115205
# name = "cudnn",
116206
# path = "/usr/",
117207
# build_file = "@//third_party/cudnn/local:BUILD"
118-
#)
208+
# )
119209

120210
#new_local_repository(
121211
# name = "tensorrt",

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()

0 commit comments

Comments
 (0)