Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/test_cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
if: matrix.enable_paddle
- run: |
export LD_LIBRARY_PATH=${{ github.workspace }}/dp_test/lib:$LD_LIBRARY_PATH
source/install/retry_on_sigterm.sh 3 pytest --cov=deepmd source/lmp/tests
source/install/retry_on_sigterm.sh 3 source/install/pytest_with_junit.sh lammps pytest --cov=deepmd source/lmp/tests
env:
OMP_NUM_THREADS: 1
TF_INTRA_OP_PARALLELISM_THREADS: 1
Expand All @@ -103,7 +103,7 @@ jobs:
# test ipi
- run: |
export PATH=${{ github.workspace }}/dp_test/bin:$PATH
pytest --cov=deepmd source/ipi/tests
source/install/pytest_with_junit.sh ipi pytest --cov=deepmd source/ipi/tests
env:
OMP_NUM_THREADS: 1
TF_INTRA_OP_PARALLELISM_THREADS: 1
Expand All @@ -119,6 +119,18 @@ jobs:
continue-on-error: true
with:
use_oidc: true
- name: Upload C++ test reports
if: ${{ always() && hashFiles('source/build_tests/generator-reports/**', 'source/build_tests/gtest-reports/**', 'source/build_tests/pytest-reports/**') != '' }}
uses: actions/upload-artifact@v7
continue-on-error: true
with:
name: cpp-cpu-tf-${{ matrix.enable_tensorflow }}-pt-${{ matrix.enable_pytorch }}-pd-${{ matrix.enable_paddle }}-lsan-${{ matrix.check_memleak }}
path: |
source/build_tests/generator-reports/**
source/build_tests/gtest-reports/**
source/build_tests/pytest-reports/**
if-no-files-found: ignore
retention-days: 14
permissions:
id-token: write
pass:
Expand Down
32 changes: 29 additions & 3 deletions .github/workflows/test_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,27 @@ jobs:
- name: Verify float64 CUDA kernels are enabled
run: |
python -c "import torch; import deepmd.pt.cxx_op; from deepmd.pt_expt.kernels.cuda.dpa4.so2_conv_train import op_available, float64_available; assert torch.cuda.is_available(); assert op_available(); assert float64_available() is True"
- run: python -m pytest ${{ matrix.pytest-args }} --ignore=source/tests/pd
- name: Test Python
run: >-
python -m pytest ${{ matrix.pytest-args }} --ignore=source/tests/pd
--junitxml=test-reports/python-${{ matrix.shard }}.xml
-o junit_duration_report=total
env:
NUM_WORKERS: 0
CUDA_VISIBLE_DEVICES: 0
# See https://jax.readthedocs.io/en/latest/gpu_memory_allocation.html
XLA_PYTHON_CLIENT_PREALLOCATE: false
XLA_PYTHON_CLIENT_ALLOCATOR: platform
FLAGS_use_stride_compute_kernel: 0
- name: Upload Python test reports
if: ${{ always() && hashFiles('test-reports/python-*.xml') != '' }}
uses: actions/upload-artifact@v7
continue-on-error: true
with:
name: python-cuda-${{ matrix.shard }}
path: test-reports/python-*.xml
if-no-files-found: ignore
retention-days: 14

test_cc:
name: Test ${{ matrix.name }} on CUDA
Expand Down Expand Up @@ -222,8 +235,8 @@ jobs:
run: |
export LD_LIBRARY_PATH=$MPI_HOME/lib:$CUDA_PATH/lib64:/usr/lib/x86_64-linux-gnu/:$GITHUB_WORKSPACE/dp_test/lib:$LD_LIBRARY_PATH
export PATH=$GITHUB_WORKSPACE/dp_test/bin:$PATH
python -m pytest -s source/lmp/tests || (cat log.lammps && exit 1)
python -m pytest source/ipi/tests
source/install/pytest_with_junit.sh lammps python -m pytest -s source/lmp/tests || (cat log.lammps && exit 1)
source/install/pytest_with_junit.sh ipi python -m pytest source/ipi/tests
env:
OMP_NUM_THREADS: 1
TF_INTRA_OP_PARALLELISM_THREADS: 1
Expand All @@ -232,6 +245,19 @@ jobs:
DPA4SPIN_LMP_REQUIRED: 1
CUDA_VISIBLE_DEVICES: 0
ENABLE_PADDLE: 0
- name: Upload C++ test reports
if: ${{ always() && hashFiles('source/build_tests/generator-reports/**', 'source/build_tests/gtest-reports/**', 'source/build_tests/pytest-reports/**', 'source/build_lammps_kokkos/test-reports/**') != '' }}
uses: actions/upload-artifact@v7
continue-on-error: true
with:
name: cpp-cuda-${{ matrix.suite }}
path: |
source/build_tests/generator-reports/**
source/build_tests/gtest-reports/**
source/build_tests/pytest-reports/**
source/build_lammps_kokkos/test-reports/**
if-no-files-found: ignore
retention-days: 14
pass:
name: Pass testing on CUDA
needs: [test_python, test_cc]
Expand Down
18 changes: 18 additions & 0 deletions source/api_c/tests/test_deeppot_universal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ class UniversalDeepPotCTest : public ::testing::TestWithParam<ModelCase> {
}
ASSERT_TRUE(path_exists(param.model_path))
<< "Model artifact is not available: " << param.model_path;
}

// Call after capability skips so unsupported cases do not load a model.
void InitModel() {
const auto& param = GetParam();
std::string model_path = param.model_path;
if (param.convert_pbtxt) {
converted_model = "deeppot_c_universal_" + param.name + ".pb";
Expand Down Expand Up @@ -92,7 +96,11 @@ class FParamAParamDeepPotCTest
loaded_ref = load_fparam_ref(param.ref_path);
ref = &loaded_ref;
}
}

// Call after capability skips so unsupported cases do not load a model.
void InitModel() {
const auto& param = GetParam();
std::string model_path = param.model_path;
if (param.convert_pbtxt) {
converted_model = "deeppot_c_fparam_aparam_" + param.name + ".pb";
Expand All @@ -116,6 +124,7 @@ class FParamAParamDeepPotCTest
};

TEST_P(UniversalDeepPotCTest, Metadata) {
ASSERT_NO_FATAL_FAILURE(InitModel());
const auto& ref = *GetParam().ref;

EXPECT_DOUBLE_EQ(DP_DeepPotGetCutoff(dp), ref.cutoff);
Expand Down Expand Up @@ -347,6 +356,7 @@ void check_fparam_compute_float(DP_DeepPot* dp,
}

TEST_P(UniversalDeepPotCTest, ComputeDouble) {
ASSERT_NO_FATAL_FAILURE(InitModel());
check_compute_double(dp, *GetParam().ref, GetParam().double_tol);
}

Expand All @@ -355,10 +365,12 @@ TEST_P(UniversalDeepPotCTest, ComputeFloat) {
GTEST_SKIP() << backend_name(GetParam().backend)
<< " does not provide float inference coverage.";
}
ASSERT_NO_FATAL_FAILURE(InitModel());
check_compute_float(dp, *GetParam().ref, GetParam().float_tol);
}

TEST_P(UniversalDeepPotCTest, ComputeLegacyDouble) {
ASSERT_NO_FATAL_FAILURE(InitModel());
const std::vector<double>& box = deepmd_test::deeppot_box();
check_compute_legacy_double(dp, *GetParam().ref, box.data(),
GetParam().double_tol);
Expand All @@ -369,6 +381,7 @@ TEST_P(UniversalDeepPotCTest, ComputeLegacyFloat) {
GTEST_SKIP() << backend_name(GetParam().backend)
<< " does not provide float inference coverage.";
}
ASSERT_NO_FATAL_FAILURE(InitModel());
const std::vector<double>& box_double = deepmd_test::deeppot_box();
const std::vector<float> box(box_double.begin(), box_double.end());
check_compute_legacy_float(dp, *GetParam().ref, box.data(),
Expand All @@ -380,6 +393,7 @@ TEST_P(UniversalDeepPotCTest, ComputeLegacyNoPbcDouble) {
GTEST_SKIP() << backend_name(GetParam().backend)
<< " NoPBC reference is not available.";
}
ASSERT_NO_FATAL_FAILURE(InitModel());
check_compute_legacy_double(dp, *GetParam().no_pbc_ref, nullptr,
GetParam().double_tol);
}
Expand All @@ -393,17 +407,20 @@ TEST_P(UniversalDeepPotCTest, ComputeLegacyNoPbcFloat) {
GTEST_SKIP() << backend_name(GetParam().backend)
<< " NoPBC reference is not available.";
}
ASSERT_NO_FATAL_FAILURE(InitModel());
check_compute_legacy_float(dp, *GetParam().no_pbc_ref, nullptr,
GetParam().float_tol);
}

TEST_P(FParamAParamDeepPotCTest, Metadata) {
ASSERT_NO_FATAL_FAILURE(InitModel());
EXPECT_EQ(DP_DeepPotGetDimFParam(dp), 1);
EXPECT_EQ(DP_DeepPotGetDimAParam(dp), 1);
EXPECT_FALSE(DP_DeepPotHasDefaultFParam(dp));
}

TEST_P(FParamAParamDeepPotCTest, ComputeDouble) {
ASSERT_NO_FATAL_FAILURE(InitModel());
check_fparam_compute_double(dp, *ref, GetParam().double_tol);
}

Expand All @@ -412,6 +429,7 @@ TEST_P(FParamAParamDeepPotCTest, ComputeFloat) {
GTEST_SKIP() << backend_name(GetParam().backend)
<< " does not provide float inference coverage.";
}
ASSERT_NO_FATAL_FAILURE(InitModel());
check_fparam_compute_float(dp, *ref, GetParam().float_tol);
}

Expand Down
Loading
Loading