Skip to content

Commit e91e766

Browse files
committed
fix CI errors
1 parent 9723376 commit e91e766

10 files changed

+120
-16
lines changed

tests/py/dynamo/conversion/test_bitwise_and_aten.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ def forward(self, lhs_val, rhs_val):
141141
mod, inputs, dynamic_shapes=({1: dyn_dim}, {0: dyn_dim})
142142
)
143143
trt_mod = torch_tensorrt.dynamo.compile(
144-
fx_mod, inputs=inputs, enable_precisions={torch.bool}, min_block_size=1
144+
fx_mod,
145+
inputs=inputs,
146+
enable_precisions={torch.bool},
147+
min_block_size=1,
148+
cache_built_engines=False,
149+
reuse_cached_engines=False,
145150
)
146151
with torch.no_grad():
147152
cuda_inputs = []

tests/py/dynamo/conversion/test_embedding_bag_aten.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,12 @@ def forward(self, weights, indices, offsets, per_sample_weights=None):
484484
dynamic_shapes["per_sample_weights"] = {}
485485
fx_mod = torch.export.export(mod, inputs, dynamic_shapes=dynamic_shapes)
486486
trt_mod = torch_tensorrt.dynamo.compile(
487-
fx_mod, inputs=inputs, enable_precisions=torch.float32, min_block_size=1
487+
fx_mod,
488+
inputs=inputs,
489+
enable_precisions=torch.float32,
490+
min_block_size=1,
491+
cache_built_engines=False,
492+
reuse_cached_engines=False,
488493
)
489494
# use the inputs with different shape to inference:
490495
if per_sample_weights is None:

tests/py/dynamo/conversion/test_index_select_aten.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ def forward(self, source_tensor, indice_tensor):
109109

110110
fx_mod = torch.export.export(mod, inputs, dynamic_shapes=dynamic_shapes)
111111
trt_mod = torch_tensorrt.dynamo.compile(
112-
fx_mod, inputs=inputs, enable_precisions=torch.float32, min_block_size=1
112+
fx_mod,
113+
inputs=inputs,
114+
enable_precisions=torch.float32,
115+
min_block_size=1,
116+
cache_built_engines=False,
117+
reuse_cached_engines=False,
113118
)
114119
# use different shape of inputs for inference:
115120
inputs = (source_tensor_1, indice_tensor)

tests/py/dynamo/models/test_dtype_support.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def forward(self, x):
4141
truncate_double=True,
4242
min_block_size=1,
4343
use_python_runtime=False,
44+
cache_built_engines=False,
45+
reuse_cached_engines=False,
4446
)
4547

4648
torch_model_results = mod(in_tensor)
@@ -79,6 +81,8 @@ def forward(self, x):
7981
truncate_double=True,
8082
min_block_size=1,
8183
use_python_runtime=True,
84+
cache_built_engines=False,
85+
reuse_cached_engines=False,
8286
)
8387

8488
torch_model_results = mod(in_tensor)
@@ -123,6 +127,8 @@ def forward(self, x):
123127
truncate_double=False,
124128
min_block_size=1,
125129
use_python_runtime=False,
130+
cache_built_engines=False,
131+
reuse_cached_engines=False,
126132
)
127133

128134
torch_model_results = mod(in_tensor)
@@ -162,6 +168,8 @@ def forward(self, x):
162168
truncate_double=False,
163169
min_block_size=1,
164170
use_python_runtime=True,
171+
cache_built_engines=False,
172+
reuse_cached_engines=False,
165173
)
166174

167175
torch_model_results = mod(in_tensor)
@@ -214,6 +222,8 @@ def forward(self, x):
214222
enabled_precisions={torch.float, torch.bfloat16, torch.half},
215223
min_block_size=1,
216224
use_python_runtime=False,
225+
cache_built_engines=False,
226+
reuse_cached_engines=False,
217227
)
218228

219229
torch_model_results = mod(in_tensor)
@@ -252,6 +262,8 @@ def forward(self, x):
252262
enabled_precisions={torch.float, torch.bfloat16, torch.half},
253263
min_block_size=1,
254264
use_python_runtime=True,
265+
cache_built_engines=False,
266+
reuse_cached_engines=False,
255267
)
256268

257269
torch_model_results = mod(in_tensor)
@@ -289,6 +301,8 @@ def forward(self, x):
289301
debug=True,
290302
min_block_size=1,
291303
device=device,
304+
cache_built_engines=False,
305+
reuse_cached_engines=False,
292306
)
293307

294308
torch_model_results = mod(*inputs)

tests/py/dynamo/models/test_dyn_models.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def forward(self, x):
3939
"ir": ir,
4040
"pass_through_build_failures": True,
4141
"min_block_size": 1,
42+
"cache_built_engines": False,
43+
"reuse_cached_engines": False,
4244
}
4345
if ir == "torch_compile":
4446
input_bs4 = torch.randn((4, 3, 224, 224)).to("cuda")
@@ -96,6 +98,8 @@ def forward(self, x):
9698
"pass_through_build_failures": True,
9799
"torch_executed_ops": {"torch.ops.aten.abs.default"},
98100
"min_block_size": 1,
101+
"cache_built_engines": False,
102+
"reuse_cached_engines": False,
99103
}
100104

101105
if ir == "torch_compile":
@@ -147,6 +151,8 @@ def forward(self, x):
147151
"ir": ir,
148152
"pass_through_build_failures": True,
149153
"min_block_size": 1,
154+
"cache_built_engines": False,
155+
"reuse_cached_engines": False,
150156
}
151157

152158
if ir == "torch_compile":
@@ -190,6 +196,8 @@ def test_resnet_dynamic(ir):
190196
"ir": ir,
191197
"pass_through_build_failures": True,
192198
"min_block_size": 1,
199+
"cache_built_engines": False,
200+
"reuse_cached_engines": False,
193201
}
194202

195203
if ir == "torch_compile":
@@ -252,6 +260,8 @@ def forward(self, x):
252260
"pass_through_build_failures": True,
253261
"optimization_level": 1,
254262
"min_block_size": 1,
263+
"cache_built_engines": False,
264+
"reuse_cached_engines": False,
255265
}
256266

257267
trt_mod = torchtrt.compile(model, **compile_spec)
@@ -284,6 +294,8 @@ def forward(self, x):
284294
"enabled_precisions": {torch.float},
285295
"ir": ir,
286296
"min_block_size": 1,
297+
"cache_built_engines": False,
298+
"reuse_cached_engines": False,
287299
}
288300
inputs_bs2 = torch.randn(2, 2, 10).to("cuda")
289301
if ir == "torch_compile":
@@ -338,6 +350,8 @@ def forward(self, x):
338350
"pass_through_build_failures": True,
339351
"min_block_size": 1,
340352
"torch_executed_ops": {"torch.ops.aten.add.Tensor"},
353+
"cache_built_engines": False,
354+
"reuse_cached_engines": False,
341355
}
342356

343357
# Compile the model

tests/py/dynamo/models/test_engine_cache.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def __init__(
2121
engine_cache_dir: str,
2222
) -> None:
2323
self.engine_cache_dir = engine_cache_dir
24+
if not os.path.exists(self.engine_cache_dir):
25+
os.makedirs(self.engine_cache_dir, exist_ok=True)
2426

2527
def save(
2628
self,
@@ -99,18 +101,18 @@ def test_dynamo_compile_with_default_disk_engine_cache(self):
99101
cos_sim = cosine_similarity(results[0], results[1])
100102
assertions.assertTrue(
101103
cos_sim > COSINE_THRESHOLD,
102-
msg=f"test_dynamo_compile_with_default_disk_engine_cache: results[0] doesn't match with results[1]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
104+
msg=f"results[0] doesn't match with results[1]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
103105
)
104106

105107
cos_sim = cosine_similarity(results[1], results[2])
106108
assertions.assertTrue(
107109
cos_sim > COSINE_THRESHOLD,
108-
msg=f"test_dynamo_compile_with_default_disk_engine_cache: results[1] doesn't match with results[2]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
110+
msg=f"results[1] doesn't match with results[2]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
109111
)
110112

111113
assertions.assertTrue(
112114
times[0] > times[2],
113-
msg=f"test_dynamo_compile_with_default_disk_engine_cache: Engine caching didn't speed up the compilation. Time taken without engine caching: {times[0]} ms, time taken with engine caching: {times[2]} ms",
115+
msg=f"Engine caching didn't speed up the compilation. Time taken without engine caching: {times[0]} ms, time taken with engine caching: {times[2]} ms",
114116
)
115117

116118
def test_dynamo_compile_with_custom_engine_cache(self):
@@ -167,18 +169,18 @@ def test_dynamo_compile_with_custom_engine_cache(self):
167169
cos_sim = cosine_similarity(results[0], results[1])
168170
assertions.assertTrue(
169171
cos_sim > COSINE_THRESHOLD,
170-
msg=f"test_dynamo_compile_with_custom_engine_cache: results[0] doesn't match with results[1]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
172+
msg=f"results[0] doesn't match with results[1]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
171173
)
172174

173175
cos_sim = cosine_similarity(results[1], results[2])
174176
assertions.assertTrue(
175177
cos_sim > COSINE_THRESHOLD,
176-
msg=f"test_dynamo_compile_with_custom_engine_cache: results[1] doesn't match with results[2]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
178+
msg=f"results[1] doesn't match with results[2]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
177179
)
178180

179181
assertions.assertTrue(
180182
times[0] > times[2],
181-
msg=f"test_dynamo_compile_with_custom_engine_cache: Engine caching didn't speed up the compilation. Time taken without engine caching: {times[0]} ms, time taken with engine caching: {times[2]} ms",
183+
msg=f"Engine caching didn't speed up the compilation. Time taken without engine caching: {times[0]} ms, time taken with engine caching: {times[2]} ms",
182184
)
183185

184186
def test_torch_compile_with_default_disk_engine_cache(self):
@@ -231,18 +233,18 @@ def test_torch_compile_with_default_disk_engine_cache(self):
231233
cos_sim = cosine_similarity(results[0], results[1])
232234
assertions.assertTrue(
233235
cos_sim > COSINE_THRESHOLD,
234-
msg=f"test_torch_compile_with_default_disk_engine_cache: results[0] doesn't match with results[1]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
236+
msg=f"results[0] doesn't match with results[1]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
235237
)
236238

237239
cos_sim = cosine_similarity(results[1], results[2])
238240
assertions.assertTrue(
239241
cos_sim > COSINE_THRESHOLD,
240-
msg=f"test_torch_compile_with_default_disk_engine_cache: results[1] doesn't match with results[2]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
242+
msg=f"results[1] doesn't match with results[2]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
241243
)
242244

243245
assertions.assertTrue(
244246
times[0] > times[2],
245-
msg=f"test_torch_compile_with_default_disk_engine_cache: Engine caching didn't speed up the compilation. Time taken without engine caching: {times[0]} ms, time taken with engine caching: {times[2]} ms",
247+
msg=f"Engine caching didn't speed up the compilation. Time taken without engine caching: {times[0]} ms, time taken with engine caching: {times[2]} ms",
246248
)
247249

248250
def test_torch_compile_with_custom_engine_cache(self):
@@ -295,16 +297,16 @@ def test_torch_compile_with_custom_engine_cache(self):
295297
cos_sim = cosine_similarity(results[0], results[1])
296298
assertions.assertTrue(
297299
cos_sim > COSINE_THRESHOLD,
298-
msg=f"test_torch_compile_with_custom_engine_cache: results[0] doesn't match with results[1]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
300+
msg=f"results[0] doesn't match with results[1]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
299301
)
300302

301303
cos_sim = cosine_similarity(results[1], results[2])
302304
assertions.assertTrue(
303305
cos_sim > COSINE_THRESHOLD,
304-
msg=f"test_torch_compile_with_custom_engine_cache: results[1] doesn't match with results[2]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
306+
msg=f"results[1] doesn't match with results[2]. Cosine sim score: {cos_sim} Threshold: {COSINE_THRESHOLD}",
305307
)
306308

307309
assertions.assertTrue(
308310
times[0] > times[2],
309-
msg=f"test_torch_compile_with_custom_engine_cache: Engine caching didn't speed up the compilation. Time taken without engine caching: {times[0]} ms, time taken with engine caching: {times[2]} ms",
311+
msg=f"Engine caching didn't speed up the compilation. Time taken without engine caching: {times[0]} ms, time taken with engine caching: {times[2]} ms",
310312
)

tests/py/dynamo/models/test_export_kwargs_serde.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def forward(self, x, b=5, c=None, d=None):
6363
"optimization_level": 1,
6464
"min_block_size": 1,
6565
"ir": "dynamo",
66+
"cache_built_engines": False,
67+
"reuse_cached_engines": False,
6668
}
6769

6870
exp_program = torch.export.export(model, args=tuple(args), kwargs=kwargs)
@@ -122,6 +124,8 @@ def forward(self, x, b=5, c=None, d=None):
122124
"optimization_level": 1,
123125
"min_block_size": 1,
124126
"ir": "dynamo",
127+
"cache_built_engines": False,
128+
"reuse_cached_engines": False,
125129
}
126130

127131
exp_program = torchtrt.dynamo.trace(model, **compile_spec)
@@ -190,6 +194,8 @@ def forward(self, x, b=5, c=None, d=None):
190194
"optimization_level": 1,
191195
"min_block_size": 1,
192196
"ir": "dynamo",
197+
"cache_built_engines": False,
198+
"reuse_cached_engines": False,
193199
}
194200

195201
exp_program = torchtrt.dynamo.trace(model, **compile_spec)
@@ -271,6 +277,8 @@ def forward(self, x, b=None, c=None, d=None, e=[]):
271277
"optimization_level": 1,
272278
"min_block_size": 1,
273279
"ir": "dynamo",
280+
"cache_built_engines": False,
281+
"reuse_cached_engines": False,
274282
}
275283

276284
exp_program = torchtrt.dynamo.trace(model, **compile_spec)
@@ -358,6 +366,8 @@ def forward(self, x, b=None, c=None, d=None, e=[]):
358366
"optimization_level": 1,
359367
"min_block_size": 1,
360368
"ir": "dynamo",
369+
"cache_built_engines": False,
370+
"reuse_cached_engines": False,
361371
}
362372

363373
exp_program = torchtrt.dynamo.trace(model, **compile_spec)
@@ -444,6 +454,8 @@ def forward(self, x, b=None, c=None, d=None, e=[]):
444454
"optimization_level": 1,
445455
"min_block_size": 1,
446456
"ir": "dynamo",
457+
"cache_built_engines": False,
458+
"reuse_cached_engines": False,
447459
}
448460

449461
exp_program = torchtrt.dynamo.trace(model, **compile_spec)
@@ -505,6 +517,8 @@ def forward(self, x, b=5, c=None, d=None):
505517
"optimization_level": 1,
506518
"min_block_size": 1,
507519
"ir": "dynamo",
520+
"cache_built_engines": False,
521+
"reuse_cached_engines": False,
508522
}
509523

510524
exp_program = torch.export.export(model, args=tuple(args), kwargs=kwargs)

0 commit comments

Comments
 (0)