From b01947cc2d5bf2e0f9dd5fb9fea8b031c5a5f302 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Mon, 6 Apr 2026 15:43:18 +0800 Subject: [PATCH 1/4] perf(test): reduce redundant .pt2 AOTInductor compilations in GPU CI Strategy 1: Share frozen .pt2 in setUpClass for test_dp_freeze.py and test_change_bias.py to avoid redundant AOTInductor compilations. Strategy 2: Remove test_min_nbor_dist_roundtrip_pt2 (already covered by the .pte test since they share identical metadata storage). Strategy 3: Move dp.init() from per-test SetUp() to static SetUpTestSuite() in 9 C++ test files to avoid per-test model loading. Strategy 4: Parallelize gen scripts in test_cc_local.sh (2 groups of 3). Estimated savings: ~15 min out of 44 min total GPU CI time. --- ..._deeppot_a_fparam_aparam_nframes_ptexpt.cc | 12 ++- .../test_deeppot_a_fparam_aparam_ptexpt.cc | 24 ++++- .../test_deeppot_default_fparam_ptexpt.cc | 12 ++- .../api_cc/tests/test_deeppot_dpa1_ptexpt.cc | 24 ++++- .../api_cc/tests/test_deeppot_dpa2_ptexpt.cc | 24 ++++- .../api_cc/tests/test_deeppot_dpa3_ptexpt.cc | 24 ++++- .../api_cc/tests/test_deeppot_dpa_ptexpt.cc | 24 ++++- .../tests/test_deeppot_model_devi_ptexpt.cc | 53 +++++++--- source/api_cc/tests/test_deeppot_ptexpt.cc | 60 ++++++++--- source/install/test_cc_local.sh | 23 +++-- .../pt_expt/model/test_model_compression.py | 18 +--- source/tests/pt_expt/test_change_bias.py | 99 +++++++------------ source/tests/pt_expt/test_dp_freeze.py | 31 +++--- 13 files changed, 273 insertions(+), 155 deletions(-) diff --git a/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc b/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc index b6da8a37a7..fb4da8f7fa 100644 --- a/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc @@ -113,13 +113,18 @@ class TestInferDeepPotAFparamAparamNFramesPtExpt : public ::testing::Test { std::vector expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/fparam_aparam.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/fparam_aparam.pt2"); natoms = expected_e.size() / nframes; EXPECT_EQ(nframes * natoms * 3, expected_f.size()); @@ -144,6 +149,9 @@ class TestInferDeepPotAFparamAparamNFramesPtExpt : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotAFparamAparamNFramesPtExpt::dp; + TYPED_TEST_SUITE(TestInferDeepPotAFparamAparamNFramesPtExpt, ValueTypes); TYPED_TEST(TestInferDeepPotAFparamAparamNFramesPtExpt, cpu_build_nlist) { diff --git a/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc b/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc index 0ef30df29e..301df42717 100644 --- a/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc @@ -73,13 +73,18 @@ class TestInferDeepPotAFParamAParamPtExpt : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/fparam_aparam.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/fparam_aparam.pt2"); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -100,6 +105,9 @@ class TestInferDeepPotAFParamAParamPtExpt : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotAFParamAParamPtExpt::dp; + TYPED_TEST_SUITE(TestInferDeepPotAFParamAParamPtExpt, ValueTypes); TYPED_TEST(TestInferDeepPotAFParamAParamPtExpt, cpu_build_nlist) { @@ -325,18 +333,26 @@ TYPED_TEST(TestInferDeepPotAFParamAParamPtExpt, cpu_lmp_nlist_atomic) { template class TestInferDeepPotNoDefaultFParamPtExpt : public ::testing::Test { protected: - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/fparam_aparam.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/fparam_aparam.pt2"); }; void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotNoDefaultFParamPtExpt::dp; + TYPED_TEST_SUITE(TestInferDeepPotNoDefaultFParamPtExpt, ValueTypes); TYPED_TEST(TestInferDeepPotNoDefaultFParamPtExpt, no_default_fparam) { diff --git a/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc b/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc index 88db060521..32365c21ea 100644 --- a/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc @@ -78,13 +78,18 @@ class TestInferDeepPotDefaultFParamPtExpt : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/fparam_aparam_default.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/fparam_aparam_default.pt2"); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -105,6 +110,9 @@ class TestInferDeepPotDefaultFParamPtExpt : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotDefaultFParamPtExpt::dp; + TYPED_TEST_SUITE(TestInferDeepPotDefaultFParamPtExpt, ValueTypes); TYPED_TEST(TestInferDeepPotDefaultFParamPtExpt, attrs) { diff --git a/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc index 53a631f6f8..db716ddc91 100644 --- a/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc @@ -72,13 +72,18 @@ class TestInferDeepPotDpa1PtExpt : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/deeppot_dpa1.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/deeppot_dpa1.pt2"); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -99,6 +104,9 @@ class TestInferDeepPotDpa1PtExpt : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotDpa1PtExpt::dp; + TYPED_TEST_SUITE(TestInferDeepPotDpa1PtExpt, ValueTypes); TYPED_TEST(TestInferDeepPotDpa1PtExpt, cpu_build_nlist) { @@ -218,13 +226,18 @@ class TestInferDeepPotDpa1PtExptNoPbc : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/deeppot_dpa1.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/deeppot_dpa1.pt2"); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -245,6 +258,9 @@ class TestInferDeepPotDpa1PtExptNoPbc : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotDpa1PtExptNoPbc::dp; + TYPED_TEST_SUITE(TestInferDeepPotDpa1PtExptNoPbc, ValueTypes); TYPED_TEST(TestInferDeepPotDpa1PtExptNoPbc, cpu_build_nlist) { diff --git a/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc index 4bbf1292b0..b40bd57e8e 100644 --- a/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc @@ -71,13 +71,18 @@ class TestInferDeepPotDpa2PtExpt : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/deeppot_dpa2.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/deeppot_dpa2.pt2"); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -98,6 +103,9 @@ class TestInferDeepPotDpa2PtExpt : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotDpa2PtExpt::dp; + TYPED_TEST_SUITE(TestInferDeepPotDpa2PtExpt, ValueTypes); TYPED_TEST(TestInferDeepPotDpa2PtExpt, cpu_build_nlist) { @@ -492,13 +500,18 @@ class TestInferDeepPotDpa2PtExptNoPbc : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/deeppot_dpa2.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/deeppot_dpa2.pt2"); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -519,6 +532,9 @@ class TestInferDeepPotDpa2PtExptNoPbc : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotDpa2PtExptNoPbc::dp; + TYPED_TEST_SUITE(TestInferDeepPotDpa2PtExptNoPbc, ValueTypes); TYPED_TEST(TestInferDeepPotDpa2PtExptNoPbc, cpu_build_nlist) { diff --git a/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc index 2767f5c641..162ffca719 100644 --- a/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc @@ -71,13 +71,18 @@ class TestInferDeepPotDpa3PtExpt : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/deeppot_dpa3.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/deeppot_dpa3.pt2"); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -98,6 +103,9 @@ class TestInferDeepPotDpa3PtExpt : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotDpa3PtExpt::dp; + TYPED_TEST_SUITE(TestInferDeepPotDpa3PtExpt, ValueTypes); TYPED_TEST(TestInferDeepPotDpa3PtExpt, cpu_build_nlist) { @@ -492,13 +500,18 @@ class TestInferDeepPotDpa3PtExptNoPbc : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/deeppot_dpa3.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/deeppot_dpa3.pt2"); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -519,6 +532,9 @@ class TestInferDeepPotDpa3PtExptNoPbc : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotDpa3PtExptNoPbc::dp; + TYPED_TEST_SUITE(TestInferDeepPotDpa3PtExptNoPbc, ValueTypes); TYPED_TEST(TestInferDeepPotDpa3PtExptNoPbc, cpu_build_nlist) { diff --git a/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc index 769c166d12..ee035a9d28 100644 --- a/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc @@ -70,13 +70,18 @@ class TestInferDeepPotDpaPtExpt : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/deeppot_dpa1.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/deeppot_dpa1.pt2"); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -97,6 +102,9 @@ class TestInferDeepPotDpaPtExpt : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotDpaPtExpt::dp; + TYPED_TEST_SUITE(TestInferDeepPotDpaPtExpt, ValueTypes); TYPED_TEST(TestInferDeepPotDpaPtExpt, cpu_build_nlist) { @@ -482,13 +490,18 @@ class TestInferDeepPotDpaPtExptNoPbc : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/deeppot_dpa1.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/deeppot_dpa1.pt2"); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -509,6 +522,9 @@ class TestInferDeepPotDpaPtExptNoPbc : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotDpaPtExptNoPbc::dp; + TYPED_TEST_SUITE(TestInferDeepPotDpaPtExptNoPbc, ValueTypes); TYPED_TEST(TestInferDeepPotDpaPtExptNoPbc, cpu_build_nlist) { diff --git a/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc b/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc index 69f5082295..b2cee94c0b 100644 --- a/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc @@ -32,25 +32,37 @@ class TestInferDeepPotModeDeviPtExpt : public ::testing::Test { 0.25852028, 0.25852028, 0.25852028}; int natoms; - deepmd::DeepPot dp0; - deepmd::DeepPot dp1; - deepmd::DeepPotModelDevi dp_md; + static deepmd::DeepPot dp0; + static deepmd::DeepPot dp1; + static deepmd::DeepPotModelDevi dp_md; - void SetUp() override { -#ifndef BUILD_PYTORCH - GTEST_SKIP() << "Skip because PyTorch support is not enabled."; -#endif + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH dp0.init("../../tests/infer/model_devi_md0.pt2"); dp1.init("../../tests/infer/model_devi_md1.pt2"); dp_md.init( std::vector({"../../tests/infer/model_devi_md0.pt2", "../../tests/infer/model_devi_md1.pt2"})); +#endif + } + + void SetUp() override { +#ifndef BUILD_PYTORCH + GTEST_SKIP() << "Skip because PyTorch support is not enabled."; +#endif natoms = coord.size() / 3; }; void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotModeDeviPtExpt::dp0; +template +deepmd::DeepPot TestInferDeepPotModeDeviPtExpt::dp1; +template +deepmd::DeepPotModelDevi TestInferDeepPotModeDeviPtExpt::dp_md; + TYPED_TEST_SUITE(TestInferDeepPotModeDeviPtExpt, ValueTypes); TYPED_TEST(TestInferDeepPotModeDeviPtExpt, attrs) { @@ -414,25 +426,38 @@ class TestInferDeepPotModeDeviPtExptPrecomputed : public ::testing::Test { 1.735782978938303146e-04, 2.441022592033971239e-05, 7.333090508662540210e-05}; // max min mystd - deepmd::DeepPot dp0; - deepmd::DeepPot dp1; - deepmd::DeepPotModelDevi dp_md; + static deepmd::DeepPot dp0; + static deepmd::DeepPot dp1; + static deepmd::DeepPotModelDevi dp_md; - void SetUp() override { -#ifndef BUILD_PYTORCH - GTEST_SKIP() << "Skip because PyTorch support is not enabled."; -#endif + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH dp0.init("../../tests/infer/model_devi_md0.pt2"); dp1.init("../../tests/infer/model_devi_md1.pt2"); dp_md.init( std::vector({"../../tests/infer/model_devi_md0.pt2", "../../tests/infer/model_devi_md1.pt2"})); +#endif + } + + void SetUp() override { +#ifndef BUILD_PYTORCH + GTEST_SKIP() << "Skip because PyTorch support is not enabled."; +#endif natoms = coord.size() / 3; }; void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotModeDeviPtExptPrecomputed::dp0; +template +deepmd::DeepPot TestInferDeepPotModeDeviPtExptPrecomputed::dp1; +template +deepmd::DeepPotModelDevi + TestInferDeepPotModeDeviPtExptPrecomputed::dp_md; + TYPED_TEST_SUITE(TestInferDeepPotModeDeviPtExptPrecomputed, ValueTypes); template diff --git a/source/api_cc/tests/test_deeppot_ptexpt.cc b/source/api_cc/tests/test_deeppot_ptexpt.cc index 2cda44bb19..4b77b9ce2f 100644 --- a/source/api_cc/tests/test_deeppot_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_ptexpt.cc @@ -54,15 +54,18 @@ class TestInferDeepPotAPtExpt : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/deeppot_sea.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - std::string file_name = "../../tests/infer/deeppot_sea.pt2"; - - dp.init(file_name); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -83,6 +86,9 @@ class TestInferDeepPotAPtExpt : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotAPtExpt::dp; + TYPED_TEST_SUITE(TestInferDeepPotAPtExpt, ValueTypes); TYPED_TEST(TestInferDeepPotAPtExpt, cpu_build_nlist) { @@ -452,14 +458,18 @@ class TestInferDeepPotAPtExptNoPbc : public ::testing::Test { double expected_tot_e; std::vector expected_tot_v; - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/deeppot_sea.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - std::string file_name = "../../tests/infer/deeppot_sea.pt2"; - dp.init(file_name); natoms = expected_e.size(); EXPECT_EQ(natoms * 3, expected_f.size()); @@ -480,6 +490,9 @@ class TestInferDeepPotAPtExptNoPbc : public ::testing::Test { void TearDown() override {}; }; +template +deepmd::DeepPot TestInferDeepPotAPtExptNoPbc::dp; + TYPED_TEST_SUITE(TestInferDeepPotAPtExptNoPbc, ValueTypes); TYPED_TEST(TestInferDeepPotAPtExptNoPbc, cpu_build_nlist) { @@ -664,16 +677,23 @@ TEST(TestDeepPotPTExptParser, load_tiny_file) { template class TestDeepPotPTExptMetadata : public ::testing::Test { protected: - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/deeppot_sea.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/deeppot_sea.pt2"); }; void TearDown() override {}; }; +template +deepmd::DeepPot TestDeepPotPTExptMetadata::dp; + TYPED_TEST_SUITE(TestDeepPotPTExptMetadata, ValueTypes); TYPED_TEST(TestDeepPotPTExptMetadata, type_map) { @@ -707,16 +727,23 @@ TYPED_TEST(TestDeepPotPTExptMetadata, no_default_fparam) { template class TestDeepPotPTExptJsonTypes : public ::testing::Test { protected: - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/fparam_aparam.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/fparam_aparam.pt2"); }; void TearDown() override {}; }; +template +deepmd::DeepPot TestDeepPotPTExptJsonTypes::dp; + TYPED_TEST_SUITE(TestDeepPotPTExptJsonTypes, ValueTypes); TYPED_TEST(TestDeepPotPTExptJsonTypes, integer_fields) { @@ -743,16 +770,23 @@ TYPED_TEST(TestDeepPotPTExptJsonTypes, float_field) { template class TestDeepPotPTExptJsonDefaults : public ::testing::Test { protected: - deepmd::DeepPot dp; + static deepmd::DeepPot dp; + static void SetUpTestSuite() { +#ifdef BUILD_PYTORCH + dp.init("../../tests/infer/fparam_aparam_default.pt2"); +#endif + } void SetUp() override { #ifndef BUILD_PYTORCH GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif - dp.init("../../tests/infer/fparam_aparam_default.pt2"); }; void TearDown() override {}; }; +template +deepmd::DeepPot TestDeepPotPTExptJsonDefaults::dp; + TYPED_TEST_SUITE(TestDeepPotPTExptJsonDefaults, ValueTypes); TYPED_TEST(TestDeepPotPTExptJsonDefaults, boolean_true) { diff --git a/source/install/test_cc_local.sh b/source/install/test_cc_local.sh index 0866eb45b8..ca90bf68d6 100755 --- a/source/install/test_cc_local.sh +++ b/source/install/test_cc_local.sh @@ -66,12 +66,23 @@ else: _GEN_ENV="LD_PRELOAD=${_LSAN_LIB} LSAN_OPTIONS=detect_leaks=0" fi fi - env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_sea.py - env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa1.py - env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa2.py - env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa3.py - env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_fparam_aparam.py - env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_model_devi.py + # Run gen scripts in parallel (2 groups of 3) for faster model generation. + # PID tracking ensures set -e still catches failures. + env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_sea.py & + PID1=$! + env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa1.py & + PID2=$! + env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa2.py & + PID3=$! + wait $PID1 $PID2 $PID3 + + env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa3.py & + PID4=$! + env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_fparam_aparam.py & + PID5=$! + env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_model_devi.py & + PID6=$! + wait $PID4 $PID5 $PID6 fi if [ "${ENABLE_PADDLE:-TRUE}" == "TRUE" ]; then PADDLE_INFERENCE_DIR=${BUILD_TMP_DIR}/paddle_inference_install_dir diff --git a/source/tests/pt_expt/model/test_model_compression.py b/source/tests/pt_expt/model/test_model_compression.py index fb7681a8bb..95a66b528d 100644 --- a/source/tests/pt_expt/model/test_model_compression.py +++ b/source/tests/pt_expt/model/test_model_compression.py @@ -352,20 +352,10 @@ def test_freeze_compress_eval_pt2(self) -> None: if os.path.exists(compressed_pt2_path): os.unlink(compressed_pt2_path) - def test_min_nbor_dist_roundtrip_pt2(self) -> None: - """Test that min_nbor_dist survives freeze → load round-trip via .pt2.""" - md = self._make_model() - md.min_nbor_dist = 0.5 - - model_data = {"model": md.serialize(), "min_nbor_dist": 0.5} - with tempfile.NamedTemporaryFile(suffix=".pt2", delete=False) as f: - pt2_path = f.name - try: - deserialize_to_file(pt2_path, model_data) - loaded_data = serialize_from_file(pt2_path) - self.assertAlmostEqual(loaded_data["min_nbor_dist"], 0.5) - finally: - os.unlink(pt2_path) + # test_min_nbor_dist_roundtrip_pt2 removed: .pte and .pt2 share identical + # metadata storage (metadata.json in ZIP), so the .pte round-trip test + # (test_min_nbor_dist_roundtrip) already covers this path. Removing saves + # one redundant AOTInductor compilation (~82s). if __name__ == "__main__": diff --git a/source/tests/pt_expt/test_change_bias.py b/source/tests/pt_expt/test_change_bias.py index 9dcd1811e3..03329642e9 100644 --- a/source/tests/pt_expt/test_change_bias.py +++ b/source/tests/pt_expt/test_change_bias.py @@ -147,6 +147,24 @@ def setUpClass(cls) -> None: # Record original bias cls.original_bias = to_numpy(trainer.wrapper.model.get_out_bias()) + # Pre-freeze shared .pte and .pt2 files so individual tests don't + # each pay the AOTInductor compilation cost (~82s per .pt2). + from deepmd.pt_expt.entrypoints.main import ( + freeze, + ) + + cls.shared_pte = os.path.join(cls.tmpdir, "shared.pte") + freeze(model=cls.model_path, output=cls.shared_pte) + cls.shared_pt2 = os.path.join(cls.tmpdir, "shared.pt2") + # Clear default device: tests/pt/__init__.py may set a fake device + # for CPU fallback, which poisons AOTInductor compilation. + saved_device = torch.get_default_device() + torch.set_default_device(None) + try: + freeze(model=cls.model_path, output=cls.shared_pt2) + finally: + torch.set_default_device(saved_device) + @classmethod def tearDownClass(cls) -> None: os.chdir(cls.old_cwd) @@ -213,9 +231,6 @@ def test_change_bias_with_user_defined(self) -> None: np.testing.assert_allclose(updated_bias, expected_bias) def test_change_bias_frozen_pte(self) -> None: - from deepmd.pt_expt.entrypoints.main import ( - freeze, - ) from deepmd.pt_expt.model.model import ( BaseModel, ) @@ -223,19 +238,15 @@ def test_change_bias_frozen_pte(self) -> None: serialize_from_file, ) - # Freeze the checkpoint - pte_path = os.path.join(self.tmpdir, "frozen.pte") - freeze(model=self.model_path, output=pte_path) - - # Get original bias - original_data = serialize_from_file(pte_path) + # Get original bias from shared frozen file + original_data = serialize_from_file(self.shared_pte) original_model = BaseModel.deserialize(original_data["model"]) original_bias = to_numpy(original_model.get_out_bias()) # Run change-bias on the frozen model output_pte = os.path.join(self.tmpdir, "frozen_updated.pte") run_dp( - f"dp --pt-expt change-bias {pte_path} " + f"dp --pt-expt change-bias {self.shared_pte} " f"-s {self.data_file[0]} -o {output_pte}" ) @@ -252,9 +263,6 @@ def test_change_bias_frozen_pte(self) -> None: def test_change_bias_frozen_pt2(self) -> None: """Change-bias on a .pt2 frozen model.""" - from deepmd.pt_expt.entrypoints.main import ( - freeze, - ) from deepmd.pt_expt.model.model import ( BaseModel, ) @@ -262,16 +270,13 @@ def test_change_bias_frozen_pt2(self) -> None: serialize_from_file, ) - pt2_path = os.path.join(self.tmpdir, "frozen.pt2") - freeze(model=self.model_path, output=pt2_path) - - original_data = serialize_from_file(pt2_path) + original_data = serialize_from_file(self.shared_pt2) original_model = BaseModel.deserialize(original_data["model"]) original_bias = to_numpy(original_model.get_out_bias()) output_pt2 = os.path.join(self.tmpdir, "frozen_updated.pt2") run_dp( - f"dp --pt-expt change-bias {pt2_path} " + f"dp --pt-expt change-bias {self.shared_pt2} " f"-s {self.data_file[0]} -o {output_pt2}" ) @@ -286,9 +291,6 @@ def test_change_bias_frozen_pt2(self) -> None: def test_change_bias_frozen_pt2_user_defined(self) -> None: """Change-bias with user-defined values on a .pt2 model.""" - from deepmd.pt_expt.entrypoints.main import ( - freeze, - ) from deepmd.pt_expt.model.model import ( BaseModel, ) @@ -296,11 +298,8 @@ def test_change_bias_frozen_pt2_user_defined(self) -> None: serialize_from_file, ) - pt2_path = os.path.join(self.tmpdir, "frozen_ud.pt2") - freeze(model=self.model_path, output=pt2_path) - output_pt2 = os.path.join(self.tmpdir, "frozen_ud_updated.pt2") - run_dp(f"dp --pt-expt change-bias {pt2_path} -b 1.0 2.0 -o {output_pt2}") + run_dp(f"dp --pt-expt change-bias {self.shared_pt2} -b 1.0 2.0 -o {output_pt2}") updated_data = serialize_from_file(output_pt2) updated_model = BaseModel.deserialize(updated_data["model"]) @@ -311,9 +310,6 @@ def test_change_bias_frozen_pt2_user_defined(self) -> None: def test_change_bias_pt2_pte_consistency(self) -> None: """Change-bias on .pte and .pt2 should produce same bias values.""" - from deepmd.pt_expt.entrypoints.main import ( - freeze, - ) from deepmd.pt_expt.model.model import ( BaseModel, ) @@ -321,19 +317,14 @@ def test_change_bias_pt2_pte_consistency(self) -> None: serialize_from_file, ) - pte_path = os.path.join(self.tmpdir, "cons.pte") - pt2_path = os.path.join(self.tmpdir, "cons.pt2") - freeze(model=self.model_path, output=pte_path) - freeze(model=self.model_path, output=pt2_path) - output_pte = os.path.join(self.tmpdir, "cons_updated.pte") output_pt2 = os.path.join(self.tmpdir, "cons_updated.pt2") run_dp( - f"dp --pt-expt change-bias {pte_path} " + f"dp --pt-expt change-bias {self.shared_pte} " f"-s {self.data_file[0]} -o {output_pte}" ) run_dp( - f"dp --pt-expt change-bias {pt2_path} " + f"dp --pt-expt change-bias {self.shared_pt2} " f"-s {self.data_file[0]} -o {output_pt2}" ) @@ -346,26 +337,19 @@ def test_change_bias_pt2_pte_consistency(self) -> None: def test_change_bias_pte_preserves_model_def_script(self) -> None: """change_bias on .pte should preserve model_def_script (training config).""" - from deepmd.pt_expt.entrypoints.main import ( - freeze, - ) from deepmd.pt_expt.utils.serialization import ( serialize_from_file, ) - # Freeze the checkpoint (embeds training config as model_def_script) - pte_path = os.path.join(self.tmpdir, "frozen_mds.pte") - freeze(model=self.model_path, output=pte_path) - - # Verify training config is present - original_data = serialize_from_file(pte_path) + # Verify training config is present in shared frozen file + original_data = serialize_from_file(self.shared_pte) self.assertIn("model_def_script", original_data) original_mds = original_data["model_def_script"] self.assertIn("type_map", original_mds) # training config has model params # Run change-bias with user-defined values output_pte = os.path.join(self.tmpdir, "frozen_mds_updated.pte") - run_dp(f"dp --pt-expt change-bias {pte_path} -b 0.1 3.2 -o {output_pte}") + run_dp(f"dp --pt-expt change-bias {self.shared_pte} -b 0.1 3.2 -o {output_pte}") # Verify model_def_script is preserved in the output updated_data = serialize_from_file(output_pte) @@ -374,36 +358,19 @@ def test_change_bias_pte_preserves_model_def_script(self) -> None: def test_change_bias_pt2_preserves_model_def_script(self) -> None: """change_bias on .pt2 should preserve model_def_script (training config).""" - from deepmd.pt_expt.entrypoints.main import ( - freeze, - ) from deepmd.pt_expt.utils.serialization import ( serialize_from_file, ) - # Freeze to .pt2 - # Clear default device: tests/pt/__init__.py sets it to "cuda:9999999" - # for CPU fallback, which poisons AOTInductor compilation. - pt2_path = os.path.join(self.tmpdir, "frozen_mds.pt2") - torch.set_default_device(None) - try: - freeze(model=self.model_path, output=pt2_path) - finally: - torch.set_default_device("cuda:9999999") - - # Verify training config is present - original_data = serialize_from_file(pt2_path) + # Verify training config is present in shared frozen file + original_data = serialize_from_file(self.shared_pt2) self.assertIn("model_def_script", original_data) original_mds = original_data["model_def_script"] self.assertIn("type_map", original_mds) # training config has model params - # Run change-bias with user-defined values (same device workaround) + # Run change-bias with user-defined values output_pt2 = os.path.join(self.tmpdir, "frozen_mds_updated.pt2") - torch.set_default_device(None) - try: - run_dp(f"dp --pt-expt change-bias {pt2_path} -b 0.1 3.2 -o {output_pt2}") - finally: - torch.set_default_device("cuda:9999999") + run_dp(f"dp --pt-expt change-bias {self.shared_pt2} -b 0.1 3.2 -o {output_pt2}") # Verify model_def_script is preserved in the output updated_data = serialize_from_file(output_pt2) diff --git a/source/tests/pt_expt/test_dp_freeze.py b/source/tests/pt_expt/test_dp_freeze.py index 60eab4f50a..add8313752 100644 --- a/source/tests/pt_expt/test_dp_freeze.py +++ b/source/tests/pt_expt/test_dp_freeze.py @@ -57,6 +57,13 @@ def setUpClass(cls) -> None: cls.ckpt_file = os.path.join(cls.tmpdir, "model.pt") torch.save({"model": state_dict}, cls.ckpt_file) + # Pre-freeze shared .pte and .pt2 files so individual tests don't + # each pay the AOTInductor compilation cost (~82s per .pt2). + cls.shared_pte = os.path.join(cls.tmpdir, "shared.pte") + freeze(model=cls.ckpt_file, output=cls.shared_pte) + cls.shared_pt2 = os.path.join(cls.tmpdir, "shared.pt2") + freeze(model=cls.ckpt_file, output=cls.shared_pt2) + @classmethod def tearDownClass(cls) -> None: shutil.rmtree(cls.tmpdir) @@ -98,9 +105,7 @@ def test_freeze_default_suffix(self) -> None: def test_freeze_pt2(self) -> None: """Freeze to .pt2 (AOTInductor) and verify the file is loadable.""" - output = os.path.join(self.tmpdir, "frozen_model.pt2") - freeze(model=self.ckpt_file, output=output) - self.assertTrue(os.path.exists(output)) + self.assertTrue(os.path.exists(self.shared_pt2)) # Verify the .pt2 can be loaded and evaluated via DeepPot import numpy as np @@ -109,7 +114,7 @@ def test_freeze_pt2(self) -> None: DeepPot, ) - dp = DeepPot(output) + dp = DeepPot(self.shared_pt2) self.assertEqual(dp.get_type_map(), ["O", "H", "B"]) rcut = dp.get_rcut() self.assertGreater(rcut, 0.0) @@ -134,11 +139,6 @@ def test_freeze_pt2_eval_consistency(self) -> None: DeepPot, ) - pte_path = os.path.join(self.tmpdir, "consistency.pte") - pt2_path = os.path.join(self.tmpdir, "consistency.pt2") - freeze(model=self.ckpt_file, output=pte_path) - freeze(model=self.ckpt_file, output=pt2_path) - coord = np.array( [0.0, 0.0, 0.1, 1.0, 0.3, 0.2, 0.1, 1.9, 3.4], dtype=np.float64, @@ -146,8 +146,8 @@ def test_freeze_pt2_eval_consistency(self) -> None: box = np.array([5.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 5.0], dtype=np.float64) atype = [0, 1, 2] - dp_pte = DeepPot(pte_path) - dp_pt2 = DeepPot(pt2_path) + dp_pte = DeepPot(self.shared_pte) + dp_pt2 = DeepPot(self.shared_pt2) e_pte, f_pte, v_pte = dp_pte.eval(coord, box, atype) e_pt2, f_pt2, v_pt2 = dp_pt2.eval(coord, box, atype) @@ -171,11 +171,6 @@ def test_freeze_pt2_nopbc_negative_coords(self) -> None: DeepPot, ) - pte_path = os.path.join(self.tmpdir, "nopbc_neg.pte") - pt2_path = os.path.join(self.tmpdir, "nopbc_neg.pt2") - freeze(model=self.ckpt_file, output=pte_path) - freeze(model=self.ckpt_file, output=pt2_path) - # Coordinates with negative values — no periodic box coord = np.array( [-1.0, -2.0, 0.5, 1.0, 0.3, -0.2, 0.1, -1.9, 3.4], @@ -183,8 +178,8 @@ def test_freeze_pt2_nopbc_negative_coords(self) -> None: ) atype = [0, 1, 2] - dp_pte = DeepPot(pte_path) - dp_pt2 = DeepPot(pt2_path) + dp_pte = DeepPot(self.shared_pte) + dp_pt2 = DeepPot(self.shared_pt2) e_pte, f_pte, v_pte = dp_pte.eval(coord, None, atype) e_pt2, f_pt2, v_pt2 = dp_pt2.eval(coord, None, atype) From e81f8ba158ef9ac7cb2e06543a153a9a2d0740ed Mon Sep 17 00:00:00 2001 From: Han Wang Date: Mon, 6 Apr 2026 17:15:03 +0800 Subject: [PATCH 2/4] perf(test): remove stale .pt2/.pte before regeneration in CI Delete existing generated model files before running gen scripts, so stale files from a previous code version cannot be accidentally reused if the model format changes. --- source/install/test_cc_local.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/install/test_cc_local.sh b/source/install/test_cc_local.sh index ca90bf68d6..f970d57cae 100755 --- a/source/install/test_cc_local.sh +++ b/source/install/test_cc_local.sh @@ -59,6 +59,9 @@ else: # runtime to be preloaded (otherwise dlopen fails). We disable leak detection # in the gen scripts to avoid false reports from torch/paddle internals. INFER_SCRIPT_PATH=${SCRIPT_PATH}/../tests/infer + # Remove stale generated model files so they can't be accidentally reused + # if gen scripts change format or the code version changes. + rm -f ${INFER_SCRIPT_PATH}/*.pt2 ${INFER_SCRIPT_PATH}/*.pte _GEN_ENV="" if echo "${CXXFLAGS:-}" | grep -q fsanitize=leak; then _LSAN_LIB=$(gcc -print-file-name=liblsan.so 2>/dev/null || true) From b212945f5497aeee46f86a8ff8ee7a0cf32203ff Mon Sep 17 00:00:00 2001 From: Han Wang Date: Mon, 6 Apr 2026 23:54:10 +0800 Subject: [PATCH 3/4] fix: address reviewer comments on BUILD_PT_EXPT guards and wait propagation - Use #if defined(BUILD_PYTORCH) && BUILD_PT_EXPT instead of #ifdef BUILD_PYTORCH in SetUpTestSuite/SetUp to guard .pt2-specific code paths correctly - Add #include "DeepPotPTExpt.h" for BUILD_PT_EXPT macro definition - Wait on each PID separately in test_cc_local.sh so any gen script failure is caught by set -e --- ..._deeppot_a_fparam_aparam_nframes_ptexpt.cc | 5 ++-- .../test_deeppot_a_fparam_aparam_ptexpt.cc | 9 ++++--- .../test_deeppot_default_fparam_ptexpt.cc | 5 ++-- .../api_cc/tests/test_deeppot_dpa1_ptexpt.cc | 9 ++++--- .../api_cc/tests/test_deeppot_dpa2_ptexpt.cc | 9 ++++--- .../api_cc/tests/test_deeppot_dpa3_ptexpt.cc | 9 ++++--- .../api_cc/tests/test_deeppot_dpa_ptexpt.cc | 9 ++++--- .../tests/test_deeppot_model_devi_ptexpt.cc | 9 ++++--- source/api_cc/tests/test_deeppot_ptexpt.cc | 27 ++++++++++--------- source/install/test_cc_local.sh | 10 ++++--- 10 files changed, 57 insertions(+), 44 deletions(-) diff --git a/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc b/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc index fb4da8f7fa..1822633aa7 100644 --- a/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc @@ -8,6 +8,7 @@ #include #include "DeepPot.h" +#include "DeepPotPTExpt.h" #include "test_utils.h" template @@ -116,13 +117,13 @@ class TestInferDeepPotAFparamAparamNFramesPtExpt : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/fparam_aparam.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif diff --git a/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc b/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc index 301df42717..f90235f4ab 100644 --- a/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc @@ -9,6 +9,7 @@ #include #include "DeepPot.h" +#include "DeepPotPTExpt.h" #include "neighbor_list.h" #include "test_utils.h" @@ -76,13 +77,13 @@ class TestInferDeepPotAFParamAParamPtExpt : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/fparam_aparam.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif @@ -336,13 +337,13 @@ class TestInferDeepPotNoDefaultFParamPtExpt : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/fparam_aparam.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif }; diff --git a/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc b/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc index 32365c21ea..dc34364f81 100644 --- a/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc @@ -10,6 +10,7 @@ #include #include "DeepPot.h" +#include "DeepPotPTExpt.h" #include "neighbor_list.h" #include "test_utils.h" @@ -81,13 +82,13 @@ class TestInferDeepPotDefaultFParamPtExpt : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/fparam_aparam_default.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif diff --git a/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc index db716ddc91..802dd3ec72 100644 --- a/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc @@ -10,6 +10,7 @@ #include #include "DeepPot.h" +#include "DeepPotPTExpt.h" #include "neighbor_list.h" #include "test_utils.h" @@ -75,13 +76,13 @@ class TestInferDeepPotDpa1PtExpt : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/deeppot_dpa1.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif @@ -229,13 +230,13 @@ class TestInferDeepPotDpa1PtExptNoPbc : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/deeppot_dpa1.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif diff --git a/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc index b40bd57e8e..e29664b282 100644 --- a/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc @@ -9,6 +9,7 @@ #include #include "DeepPot.h" +#include "DeepPotPTExpt.h" #include "neighbor_list.h" #include "test_utils.h" @@ -74,13 +75,13 @@ class TestInferDeepPotDpa2PtExpt : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/deeppot_dpa2.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif @@ -503,13 +504,13 @@ class TestInferDeepPotDpa2PtExptNoPbc : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/deeppot_dpa2.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif diff --git a/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc index 162ffca719..430a56e2b2 100644 --- a/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc @@ -9,6 +9,7 @@ #include #include "DeepPot.h" +#include "DeepPotPTExpt.h" #include "neighbor_list.h" #include "test_utils.h" @@ -74,13 +75,13 @@ class TestInferDeepPotDpa3PtExpt : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/deeppot_dpa3.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif @@ -503,13 +504,13 @@ class TestInferDeepPotDpa3PtExptNoPbc : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/deeppot_dpa3.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif diff --git a/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc index ee035a9d28..14229d8522 100644 --- a/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc @@ -8,6 +8,7 @@ #include #include "DeepPot.h" +#include "DeepPotPTExpt.h" #include "neighbor_list.h" #include "test_utils.h" @@ -73,13 +74,13 @@ class TestInferDeepPotDpaPtExpt : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/deeppot_dpa1.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif @@ -493,13 +494,13 @@ class TestInferDeepPotDpaPtExptNoPbc : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/deeppot_dpa1.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif diff --git a/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc b/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc index b2cee94c0b..9b8a373a86 100644 --- a/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc @@ -9,6 +9,7 @@ #include #include "DeepPot.h" +#include "DeepPotPTExpt.h" #include "neighbor_list.h" #include "test_utils.h" @@ -37,7 +38,7 @@ class TestInferDeepPotModeDeviPtExpt : public ::testing::Test { static deepmd::DeepPotModelDevi dp_md; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp0.init("../../tests/infer/model_devi_md0.pt2"); dp1.init("../../tests/infer/model_devi_md1.pt2"); dp_md.init( @@ -47,7 +48,7 @@ class TestInferDeepPotModeDeviPtExpt : public ::testing::Test { } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif natoms = coord.size() / 3; @@ -431,7 +432,7 @@ class TestInferDeepPotModeDeviPtExptPrecomputed : public ::testing::Test { static deepmd::DeepPotModelDevi dp_md; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp0.init("../../tests/infer/model_devi_md0.pt2"); dp1.init("../../tests/infer/model_devi_md1.pt2"); dp_md.init( @@ -441,7 +442,7 @@ class TestInferDeepPotModeDeviPtExptPrecomputed : public ::testing::Test { } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif natoms = coord.size() / 3; diff --git a/source/api_cc/tests/test_deeppot_ptexpt.cc b/source/api_cc/tests/test_deeppot_ptexpt.cc index 4b77b9ce2f..783d8711ba 100644 --- a/source/api_cc/tests/test_deeppot_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_ptexpt.cc @@ -10,6 +10,7 @@ #include #include "DeepPot.h" +#include "DeepPotPTExpt.h" #include "neighbor_list.h" #include "test_utils.h" @@ -57,13 +58,13 @@ class TestInferDeepPotAPtExpt : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/deeppot_sea.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif @@ -461,13 +462,13 @@ class TestInferDeepPotAPtExptNoPbc : public ::testing::Test { static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/deeppot_sea.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif @@ -636,7 +637,7 @@ TYPED_TEST(TestInferDeepPotAPtExptNoPbc, cpu_build_nlist_nframes) { // ========== Parser / metadata coverage tests ========== TEST(TestDeepPotPTExptParser, load_nonexistent_file) { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif deepmd::DeepPot dp; @@ -644,7 +645,7 @@ TEST(TestDeepPotPTExptParser, load_nonexistent_file) { } TEST(TestDeepPotPTExptParser, load_invalid_zip) { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif std::string tmpfile = "test_invalid.pt2"; @@ -659,7 +660,7 @@ TEST(TestDeepPotPTExptParser, load_invalid_zip) { } TEST(TestDeepPotPTExptParser, load_tiny_file) { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif std::string tmpfile = "test_tiny.pt2"; @@ -679,12 +680,12 @@ class TestDeepPotPTExptMetadata : public ::testing::Test { protected: static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/deeppot_sea.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif }; @@ -729,12 +730,12 @@ class TestDeepPotPTExptJsonTypes : public ::testing::Test { protected: static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/fparam_aparam.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif }; @@ -772,12 +773,12 @@ class TestDeepPotPTExptJsonDefaults : public ::testing::Test { protected: static deepmd::DeepPot dp; static void SetUpTestSuite() { -#ifdef BUILD_PYTORCH +#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT dp.init("../../tests/infer/fparam_aparam_default.pt2"); #endif } void SetUp() override { -#ifndef BUILD_PYTORCH +#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT GTEST_SKIP() << "Skip because PyTorch support is not enabled."; #endif }; diff --git a/source/install/test_cc_local.sh b/source/install/test_cc_local.sh index f970d57cae..b49858daff 100755 --- a/source/install/test_cc_local.sh +++ b/source/install/test_cc_local.sh @@ -70,14 +70,16 @@ else: fi fi # Run gen scripts in parallel (2 groups of 3) for faster model generation. - # PID tracking ensures set -e still catches failures. + # Wait on each PID separately so any failure is caught by set -e. env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_sea.py & PID1=$! env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa1.py & PID2=$! env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa2.py & PID3=$! - wait $PID1 $PID2 $PID3 + wait $PID1 + wait $PID2 + wait $PID3 env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa3.py & PID4=$! @@ -85,7 +87,9 @@ else: PID5=$! env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_model_devi.py & PID6=$! - wait $PID4 $PID5 $PID6 + wait $PID4 + wait $PID5 + wait $PID6 fi if [ "${ENABLE_PADDLE:-TRUE}" == "TRUE" ]; then PADDLE_INFERENCE_DIR=${BUILD_TMP_DIR}/paddle_inference_install_dir From 44392f8c852c316d08ca435ace05746f9016f2e0 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Mon, 6 Apr 2026 23:55:31 +0800 Subject: [PATCH 4/4] fix: add TearDownTestSuite to release CUDA resources before static destruction Static DeepPot objects holding CUDA resources (via shared_ptr) were being destroyed after the CUDA driver shut down, causing "CUDA error: driver shutting down" crashes. Adding TearDownTestSuite() that resets each static DeepPot/DeepPotModelDevi to a default-constructed (empty) state ensures CUDA resources are released while the driver is still alive. --- .../test_deeppot_a_fparam_aparam_nframes_ptexpt.cc | 2 ++ .../tests/test_deeppot_a_fparam_aparam_ptexpt.cc | 4 ++++ .../tests/test_deeppot_default_fparam_ptexpt.cc | 2 ++ source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc | 4 ++++ source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc | 4 ++++ source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc | 4 ++++ source/api_cc/tests/test_deeppot_dpa_ptexpt.cc | 4 ++++ .../api_cc/tests/test_deeppot_model_devi_ptexpt.cc | 12 ++++++++++++ source/api_cc/tests/test_deeppot_ptexpt.cc | 10 ++++++++++ 9 files changed, 46 insertions(+) diff --git a/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc b/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc index 1822633aa7..c72b210f7c 100644 --- a/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc @@ -148,6 +148,8 @@ class TestInferDeepPotAFparamAparamNFramesPtExpt : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template diff --git a/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc b/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc index f90235f4ab..fe1ec116b8 100644 --- a/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc @@ -104,6 +104,8 @@ class TestInferDeepPotAFParamAParamPtExpt : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template @@ -349,6 +351,8 @@ class TestInferDeepPotNoDefaultFParamPtExpt : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template diff --git a/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc b/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc index dc34364f81..996dcb1b50 100644 --- a/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc @@ -109,6 +109,8 @@ class TestInferDeepPotDefaultFParamPtExpt : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template diff --git a/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc index 802dd3ec72..c5d3b90303 100644 --- a/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc @@ -103,6 +103,8 @@ class TestInferDeepPotDpa1PtExpt : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template @@ -257,6 +259,8 @@ class TestInferDeepPotDpa1PtExptNoPbc : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template diff --git a/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc index e29664b282..67bb8f129f 100644 --- a/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc @@ -102,6 +102,8 @@ class TestInferDeepPotDpa2PtExpt : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template @@ -531,6 +533,8 @@ class TestInferDeepPotDpa2PtExptNoPbc : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template diff --git a/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc index 430a56e2b2..a76a11e94f 100644 --- a/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa3_ptexpt.cc @@ -102,6 +102,8 @@ class TestInferDeepPotDpa3PtExpt : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template @@ -531,6 +533,8 @@ class TestInferDeepPotDpa3PtExptNoPbc : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template diff --git a/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc b/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc index 14229d8522..faa51a7fde 100644 --- a/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_dpa_ptexpt.cc @@ -101,6 +101,8 @@ class TestInferDeepPotDpaPtExpt : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template @@ -521,6 +523,8 @@ class TestInferDeepPotDpaPtExptNoPbc : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template diff --git a/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc b/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc index 9b8a373a86..6da4185adf 100644 --- a/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_model_devi_ptexpt.cc @@ -55,6 +55,12 @@ class TestInferDeepPotModeDeviPtExpt : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { + dp0 = deepmd::DeepPot(); + dp1 = deepmd::DeepPot(); + dp_md = deepmd::DeepPotModelDevi(); + } }; template @@ -449,6 +455,12 @@ class TestInferDeepPotModeDeviPtExptPrecomputed : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { + dp0 = deepmd::DeepPot(); + dp1 = deepmd::DeepPot(); + dp_md = deepmd::DeepPotModelDevi(); + } }; template diff --git a/source/api_cc/tests/test_deeppot_ptexpt.cc b/source/api_cc/tests/test_deeppot_ptexpt.cc index 783d8711ba..cfde173a82 100644 --- a/source/api_cc/tests/test_deeppot_ptexpt.cc +++ b/source/api_cc/tests/test_deeppot_ptexpt.cc @@ -85,6 +85,8 @@ class TestInferDeepPotAPtExpt : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template @@ -489,6 +491,8 @@ class TestInferDeepPotAPtExptNoPbc : public ::testing::Test { }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template @@ -690,6 +694,8 @@ class TestDeepPotPTExptMetadata : public ::testing::Test { #endif }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template @@ -740,6 +746,8 @@ class TestDeepPotPTExptJsonTypes : public ::testing::Test { #endif }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template @@ -783,6 +791,8 @@ class TestDeepPotPTExptJsonDefaults : public ::testing::Test { #endif }; void TearDown() override {}; + + static void TearDownTestSuite() { dp = deepmd::DeepPot(); } }; template