Skip to content

Commit fac3f76

Browse files
fix test sdpa converter test cpp build issue (#4405)
1 parent c07bc68 commit fac3f76

3 files changed

Lines changed: 6 additions & 14 deletions

File tree

core/runtime/execute_engine.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,6 @@ std::vector<at::Tensor> execute_engine(std::vector<at::Tensor> inputs, c10::intr
390390
compiled_engine->cudagraph.capture_begin();
391391
ctx->enqueueV3(recording_stream);
392392
compiled_engine->cudagraph.capture_end();
393-
// Newer torch reworked at::cuda::CUDAGraph: capture_end() no longer
394-
// instantiates the executable graph here, and the C++ replay() (unlike
395-
// the Python wrapper) does not instantiate on demand -- it throws
396-
// "replay before instantiated". Instantiate explicitly once the graph
397-
// is captured. Guarded by has_graph_exec() so it stays correct if a
398-
// future torch goes back to instantiating inside capture_end().
399-
if (!compiled_engine->cudagraph.has_graph_exec()) {
400-
compiled_engine->cudagraph.instantiate();
401-
}
402-
403393
if (compiled_engine->profile_execution) {
404394
cudaError_t debug_dump_err = cudaGraphDebugDotPrint(
405395
compiled_engine->cudagraph.raw_cuda_graph(),

tests/core/conversion/converters/test_scaled_dot_product_attention.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ TEST(Converters, ATenScaledDotProductAttnMaskBoolDoesNotProduceNaN) {
7979
auto value = at::arange(16, {at::kCUDA}).to(at::kFloat).reshape({1, 1, 4, 4}) / 11.0;
8080
auto attn_mask =
8181
at::tensor(
82-
{1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1}, at::TensorOptions().dtype(at::kBool).device(at::kCUDA))
82+
{true, false, true, false, false, true, false, true, true, true, false, false, false, false, true, true},
83+
at::TensorOptions().device(at::kCUDA))
8384
.reshape({1, 1, 4, 4});
8485
auto params = torch_tensorrt::core::ir::get_static_params(g->inputs(), {});
8586
auto jit_results = torch_tensorrt::tests::util::RunGraph(g, params, {query, key, value, attn_mask});
@@ -89,8 +90,8 @@ TEST(Converters, ATenScaledDotProductAttnMaskBoolDoesNotProduceNaN) {
8990
params = torch_tensorrt::core::ir::get_static_params(g->inputs(), {});
9091
auto trt_results = torch_tensorrt::tests::util::RunGraphEngine(g, params, {query, key, value, attn_mask});
9192

92-
ASSERT_FALSE(torch::isnan(jit_results[0]).any().item<bool>());
93-
ASSERT_FALSE(torch::isnan(trt_results[0]).any().item<bool>());
93+
ASSERT_FALSE(at::isnan(jit_results[0]).any().item<bool>());
94+
ASSERT_FALSE(at::isnan(trt_results[0]).any().item<bool>());
9495
ASSERT_TRUE(torch_tensorrt::tests::util::almostEqual(jit_results[0], trt_results[0]));
9596
}
9697

tests/py/dynamo/conversion/harness.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,12 @@ def generate_graph(
311311
):
312312
mod = mod.eval()
313313
if use_dynamo_tracer:
314+
device = default_device()
315+
mod = mod.to(device.to(torch.device))
314316
if torch_export_dynamic_shapes is None:
315317
torch_export_dynamic_shapes = get_dynamic_shapes_args(
316318
mod, original_inputs
317319
)
318-
device = default_device()
319320
torch_export_inputs = get_torch_inputs(original_inputs, device)
320321
exported_program = torch.export.export(
321322
mod,

0 commit comments

Comments
 (0)