From a99523f2bf3be9217a02bf8739a5c19d9e873efb Mon Sep 17 00:00:00 2001 From: "A bot of @njzjz" Date: Tue, 6 Oct 2026 13:11:32 +0800 Subject: [PATCH 1/6] fix(pt): use C++20 with PyTorch 2.14+ PyTorch 2.14 requires C++20 for its C++ API. Raise DeePMD-kit's C++ standard when building against 2.14 or newer while preserving the existing requirements for older PyTorch releases. Fixes deepmodeling/deepmd-kit#6048. Agent: ChatGPT Model: GPT-5.6 Sol --- source/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 1161f59ee7..4ccc18542c 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -404,7 +404,10 @@ if(ENABLE_PYTORCH AND NOT DEEPMD_C_ROOT) else() set(DEEPMD_TORCH_HAS_CUDA FALSE) endif() - if(NOT Torch_VERSION VERSION_LESS "2.1.0") + # PyTorch 2.14 raised the minimum C++ standard from C++17 to C++20. + if(NOT Torch_VERSION VERSION_LESS "2.14.0") + set_if_higher(CMAKE_CXX_STANDARD 20) + elseif(NOT Torch_VERSION VERSION_LESS "2.1.0") set_if_higher(CMAKE_CXX_STANDARD 17) elseif(NOT Torch_VERSION VERSION_LESS "1.5.0") set_if_higher(CMAKE_CXX_STANDARD 14) From 211985a95dc61df087eb70b3d8996be8110bc313 Mon Sep 17 00:00:00 2001 From: "A bot of @njzjz" Date: Tue, 6 Oct 2026 13:11:40 +0800 Subject: [PATCH 2/6] docs: skip PyTorch operators in Read the Docs build The documentation build does not execute DeePMD's custom PyTorch operators, so avoid compiling them in RTD. This also keeps docs builds independent of PyTorch's C++ toolchain requirements. Fixes deepmodeling/deepmd-kit#6048. Agent: ChatGPT Model: GPT-5.6 Sol --- .readthedocs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 4b829fc279..9631c71e80 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -7,7 +7,8 @@ build: post_create_environment: - pip install uv post_install: - - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install -r doc/requirements.txt + # RTD renders documentation without executing custom PyTorch operators. + - DP_ENABLE_PYTORCH=0 VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install -r doc/requirements.txt apt_packages: - inkscape sphinx: From 60f500b7aa3833ed560dc2be3d0c71edd677223d Mon Sep 17 00:00:00 2001 From: "A bot of @njzjz" Date: Tue, 6 Oct 2026 14:12:08 +0800 Subject: [PATCH 3/6] fix(pt): honor PyTorch C++ standard in CUDA builds Agent: ChatGPT Model: GPT-5.6 Sol --- source/op/pt/CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/op/pt/CMakeLists.txt b/source/op/pt/CMakeLists.txt index 6948f50335..5195f9a813 100644 --- a/source/op/pt/CMakeLists.txt +++ b/source/op/pt/CMakeLists.txt @@ -212,9 +212,18 @@ if(USE_CUDA_TOOLKIT AND DEEPMD_TORCH_HAS_CUDA) ${DEEPMD_PT_CUDA_ARCHITECTURES}) endif() target_link_libraries(deepmd_op_pt PRIVATE CUDA::cublas CUDA::cublasLt) - # libtorch headers require C++17; the CUDA sources must match. - set_target_properties(deepmd_op_pt PROPERTIES CUDA_STANDARD 17 - CUDA_STANDARD_REQUIRED ON) + # libtorch headers require at least C++17, and PyTorch 2.14+ requires + # C++20. Preserve an explicitly higher CUDA standard requested by the user. + set(DEEPMD_PT_CUDA_STANDARD 17) + if(NOT Torch_VERSION VERSION_LESS "2.14.0") + set_if_higher(DEEPMD_PT_CUDA_STANDARD 20) + endif() + if(DEFINED CMAKE_CUDA_STANDARD) + set_if_higher(DEEPMD_PT_CUDA_STANDARD ${CMAKE_CUDA_STANDARD}) + endif() + set_target_properties( + deepmd_op_pt PROPERTIES CUDA_STANDARD ${DEEPMD_PT_CUDA_STANDARD} + CUDA_STANDARD_REQUIRED ON) if(DEEPMD_ENABLE_DPA1_HIGH_LMAX) target_compile_definitions(deepmd_op_pt PRIVATE DEEPMD_ENABLE_DPA1_HIGH_LMAX=1) From aeb89f10c85802c5268eb3a093749298d22486ab Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 Oct 2026 06:13:09 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- source/op/pt/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/op/pt/CMakeLists.txt b/source/op/pt/CMakeLists.txt index 5195f9a813..af7d573ec5 100644 --- a/source/op/pt/CMakeLists.txt +++ b/source/op/pt/CMakeLists.txt @@ -212,8 +212,8 @@ if(USE_CUDA_TOOLKIT AND DEEPMD_TORCH_HAS_CUDA) ${DEEPMD_PT_CUDA_ARCHITECTURES}) endif() target_link_libraries(deepmd_op_pt PRIVATE CUDA::cublas CUDA::cublasLt) - # libtorch headers require at least C++17, and PyTorch 2.14+ requires - # C++20. Preserve an explicitly higher CUDA standard requested by the user. + # libtorch headers require at least C++17, and PyTorch 2.14+ requires C++20. + # Preserve an explicitly higher CUDA standard requested by the user. set(DEEPMD_PT_CUDA_STANDARD 17) if(NOT Torch_VERSION VERSION_LESS "2.14.0") set_if_higher(DEEPMD_PT_CUDA_STANDARD 20) From 78f1656a8a54b2a32d41b7dbd4d014dfd8696836 Mon Sep 17 00:00:00 2001 From: "A bot of @njzjz" Date: Tue, 6 Oct 2026 14:13:34 +0800 Subject: [PATCH 5/6] fix(pt): guard optional CUDA standard override Agent: ChatGPT Model: GPT-5.6 Sol --- source/op/pt/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/op/pt/CMakeLists.txt b/source/op/pt/CMakeLists.txt index af7d573ec5..ddfe38253b 100644 --- a/source/op/pt/CMakeLists.txt +++ b/source/op/pt/CMakeLists.txt @@ -218,7 +218,7 @@ if(USE_CUDA_TOOLKIT AND DEEPMD_TORCH_HAS_CUDA) if(NOT Torch_VERSION VERSION_LESS "2.14.0") set_if_higher(DEEPMD_PT_CUDA_STANDARD 20) endif() - if(DEFINED CMAKE_CUDA_STANDARD) + if(CMAKE_CUDA_STANDARD) set_if_higher(DEEPMD_PT_CUDA_STANDARD ${CMAKE_CUDA_STANDARD}) endif() set_target_properties( From 552663dc8148d382ac88ec53cb43d9768df93435 Mon Sep 17 00:00:00 2001 From: "A bot of @njzjz" Date: Tue, 13 Oct 2026 22:18:36 +0800 Subject: [PATCH 6/6] test(lmp): parse reference JSON after backend startup logs The PyTorch DPA4 LAMMPS reference subprocess prints one JSON record at the end, while Warp 1.18 prints initialization messages to stdout. Decode the final JSON line to avoid 15 setup errors in Test C++. Agent: ChatGPT Model: GPT-6 --- source/lmp/tests/dpa4_spin_harness.py | 3 ++- source/lmp/tests/test_lammps_dpa4_chg_spin_deepspin_pt2.py | 3 ++- source/lmp/tests/test_lammps_dpa4_zbl_pt2.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/lmp/tests/dpa4_spin_harness.py b/source/lmp/tests/dpa4_spin_harness.py index c48eb5f600..26a4cd3f95 100644 --- a/source/lmp/tests/dpa4_spin_harness.py +++ b/source/lmp/tests/dpa4_spin_harness.py @@ -176,7 +176,8 @@ def compute_expected( proc = sp.run([sys.executable, "-c", script], capture_output=True, text=True) if proc.returncode != 0: raise RuntimeError(f"Failed to compute expected values:\n{proc.stderr}") - result = json.loads(proc.stdout.strip()) + # Warp and other backends may log to stdout before the final JSON payload. + result = json.loads(proc.stdout.strip().splitlines()[-1]) # Raw DeepEval force_mag (dE/dspin), scaled by LAMMPS's own # spin_norm / hbar unit convention (see HBAR_METAL) before comparison. diff --git a/source/lmp/tests/test_lammps_dpa4_chg_spin_deepspin_pt2.py b/source/lmp/tests/test_lammps_dpa4_chg_spin_deepspin_pt2.py index 3d76b17aac..775725c703 100644 --- a/source/lmp/tests/test_lammps_dpa4_chg_spin_deepspin_pt2.py +++ b/source/lmp/tests/test_lammps_dpa4_chg_spin_deepspin_pt2.py @@ -180,7 +180,8 @@ def _compute_expected() -> None: proc = sp.run([sys.executable, "-c", script], capture_output=True, text=True) if proc.returncode != 0: raise RuntimeError(f"Failed to compute expected values:\n{proc.stderr}") - result = json.loads(proc.stdout.strip()) + # Warp and other backends may log to stdout before the final JSON payload. + result = json.loads(proc.stdout.strip().splitlines()[-1]) # Raw DeepEval force_mag (dE/dspin), scaled by LAMMPS's own # spin_norm / hbar unit convention (see ``_HBAR_METAL`` above) before diff --git a/source/lmp/tests/test_lammps_dpa4_zbl_pt2.py b/source/lmp/tests/test_lammps_dpa4_zbl_pt2.py index 099e236294..32f20257df 100644 --- a/source/lmp/tests/test_lammps_dpa4_zbl_pt2.py +++ b/source/lmp/tests/test_lammps_dpa4_zbl_pt2.py @@ -188,7 +188,8 @@ def _compute_expected() -> None: proc = sp.run([sys.executable, "-c", script], capture_output=True, text=True) if proc.returncode != 0: raise RuntimeError(f"Failed to compute expected values:\n{proc.stderr}") - result = json.loads(proc.stdout.strip()) + # Warp and other backends may log to stdout before the final JSON payload. + result = json.loads(proc.stdout.strip().splitlines()[-1]) expected_e = result["e"] expected_ae = np.array(result["ae"])