From f7824d4dda608996ecf8a8f87f11e8a29e964f11 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 24 Aug 2025 13:57:25 +0000 Subject: [PATCH 1/8] Initial plan From 3d67554e2693dc936bf68c29fe22be9001b52a31 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 24 Aug 2025 14:19:17 +0000 Subject: [PATCH 2/8] Initial exploration and understanding of DeePMD-kit codebase Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> --- examples/water/se_e2_a/input_v2_compat.json | 84 ++++++++++++++++++ .../set.000/atomic_polarizability.npy | Bin 0 -> 272 bytes test_dp_test/set.000/box.npy | Bin 0 -> 200 bytes test_dp_test/set.000/coord.npy | Bin 0 -> 272 bytes test_dp_test/set.000/polarizability.npy | Bin 0 -> 200 bytes test_dp_test/type.raw | 6 ++ test_dp_test/type_map.raw | 2 + test_dp_test_dipole_detail.out | 2 + test_dp_test_ener_detail.e.out | 2 + test_dp_test_ener_detail.e_peratom.out | 2 + test_dp_test_ener_detail.f.out | 7 ++ test_dp_test_ener_detail.v.out | 2 + test_dp_test_ener_detail.v_peratom.out | 2 + test_dp_test_global_dipole_detail.out | 2 + test_dp_test_global_polar_detail.out | 2 + test_dp_test_polar_detail.out | 2 + 16 files changed, 115 insertions(+) create mode 100644 examples/water/se_e2_a/input_v2_compat.json create mode 100644 test_dp_test/set.000/atomic_polarizability.npy create mode 100644 test_dp_test/set.000/box.npy create mode 100644 test_dp_test/set.000/coord.npy create mode 100644 test_dp_test/set.000/polarizability.npy create mode 100644 test_dp_test/type.raw create mode 100644 test_dp_test/type_map.raw create mode 100644 test_dp_test_dipole_detail.out create mode 100644 test_dp_test_ener_detail.e.out create mode 100644 test_dp_test_ener_detail.e_peratom.out create mode 100644 test_dp_test_ener_detail.f.out create mode 100644 test_dp_test_ener_detail.v.out create mode 100644 test_dp_test_ener_detail.v_peratom.out create mode 100644 test_dp_test_global_dipole_detail.out create mode 100644 test_dp_test_global_polar_detail.out create mode 100644 test_dp_test_polar_detail.out diff --git a/examples/water/se_e2_a/input_v2_compat.json b/examples/water/se_e2_a/input_v2_compat.json new file mode 100644 index 0000000000..2505332cdb --- /dev/null +++ b/examples/water/se_e2_a/input_v2_compat.json @@ -0,0 +1,84 @@ +{ + "_comment1": " model parameters", + "model": { + "type_map": [ + "O", + "H" + ], + "descriptor": { + "type": "se_e2_a", + "sel": [ + 46, + 92 + ], + "rcut_smth": 0.5, + "rcut": 6.0, + "neuron": [ + 25, + 50, + 100 + ], + "resnet_dt": false, + "axis_neuron": 16, + "type_one_side": true, + "precision": "float64", + "seed": 1, + "_comment2": " that's all" + }, + "fitting_net": { + "neuron": [ + 240, + 240, + 240 + ], + "resnet_dt": true, + "precision": "float64", + "seed": 1, + "_comment3": " that's all" + }, + "_comment4": " that's all" + }, + "learning_rate": { + "type": "exp", + "decay_steps": 5000, + "start_lr": 0.001, + "stop_lr": 3.51e-08, + "_comment5": "that's all" + }, + "loss": { + "type": "ener", + "start_pref_e": 0.02, + "limit_pref_e": 1, + "start_pref_f": 1000, + "limit_pref_f": 1, + "start_pref_v": 0, + "limit_pref_v": 0, + "_comment6": " that's all" + }, + "training": { + "training_data": { + "systems": [ + "../data/data_0/", + "../data/data_1/", + "../data/data_2/" + ], + "batch_size": "auto", + "_comment7": "that's all" + }, + "validation_data": { + "systems": [ + "../data/data_3" + ], + "batch_size": 1, + "numb_btch": 3, + "_comment8": "that's all" + }, + "numb_steps": 1000000, + "seed": 10, + "disp_file": "lcurve.out", + "disp_freq": 100, + "save_freq": 1000, + "_comment9": "that's all" + }, + "_comment10": "that's all" +} \ No newline at end of file diff --git a/test_dp_test/set.000/atomic_polarizability.npy b/test_dp_test/set.000/atomic_polarizability.npy new file mode 100644 index 0000000000000000000000000000000000000000..59ce6c7b5b4b5884f9727ea89ce1a6cd0cf6dd60 GIT binary patch literal 272 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-7CM?b3bhL41FmVyrZaNu?6$usF>PbT^=tcCUjMsz!*A~XD^R}7qB&+8 z?tQU8CmgjPc)~7wnEY`l--b-(?H$$PYK+H?C~ mP`=@`hU>An_t>9!{b@nu$}{^fLgi0F`R14Zwy{>+u?GO2Wp4HW literal 0 HcmV?d00001 diff --git a/test_dp_test/set.000/box.npy b/test_dp_test/set.000/box.npy new file mode 100644 index 0000000000000000000000000000000000000000..b7c43fa8e84745f1f2f3de6f56c47ab7d751e51d GIT binary patch literal 200 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= hXCxM+0{I$-ItrGWItsN4WCJb+Fwk;<(6~s#@&G(89J2rb literal 0 HcmV?d00001 diff --git a/test_dp_test/set.000/coord.npy b/test_dp_test/set.000/coord.npy new file mode 100644 index 0000000000000000000000000000000000000000..65e86d40546f208debd73d5dda8e801b70b1eea9 GIT binary patch literal 272 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-ItqpsnmP)#3giMV&6xf}Usq^4REw;0e^|xhP-x3_eQ^P!1BfT0r{VBT z1Ehe>;Z5KUxz^XL4h&#$!5%0Gl;Ls!ssbwgWe=gbpz<70eShr1#)|MbKxh_+vu8kn S1uNDzW fTl3BS(BbZd@rU;9uY}5MfT literal 0 HcmV?d00001 diff --git a/test_dp_test/type.raw b/test_dp_test/type.raw new file mode 100644 index 0000000000..4eeae61de1 --- /dev/null +++ b/test_dp_test/type.raw @@ -0,0 +1,6 @@ +0 +1 +1 +0 +1 +1 diff --git a/test_dp_test/type_map.raw b/test_dp_test/type_map.raw new file mode 100644 index 0000000000..e900768b1d --- /dev/null +++ b/test_dp_test/type_map.raw @@ -0,0 +1,2 @@ +O +H diff --git a/test_dp_test_dipole_detail.out b/test_dp_test_dipole_detail.out new file mode 100644 index 0000000000..f6b30525e3 --- /dev/null +++ b/test_dp_test_dipole_detail.out @@ -0,0 +1,2 @@ +# data_x1 data_y1 data_z1 data_x2 data_y2 data_z2 pred_x1 pred_y1 pred_z1 pred_x2 pred_y2 pred_z2 +-9.274180565967479195e-01 2.698028341272042496e+00 2.521268387140979117e-01 2.927260638453461628e+00 -8.571926301526779923e-01 1.667785136187720063e+00 -9.274180565967481416e-01 2.698028341272042052e+00 2.521268387140979672e-01 2.927260638453461183e+00 -8.571926301526777703e-01 1.667785136187720063e+00 diff --git a/test_dp_test_ener_detail.e.out b/test_dp_test_ener_detail.e.out new file mode 100644 index 0000000000..d508cf8665 --- /dev/null +++ b/test_dp_test_ener_detail.e.out @@ -0,0 +1,2 @@ +# test_dp_test: data_e pred_e +0.000000000000000000e+00 -9.309691834787724929e+02 diff --git a/test_dp_test_ener_detail.e_peratom.out b/test_dp_test_ener_detail.e_peratom.out new file mode 100644 index 0000000000..32a043e9dc --- /dev/null +++ b/test_dp_test_ener_detail.e_peratom.out @@ -0,0 +1,2 @@ +# test_dp_test: data_e pred_e +0.000000000000000000e+00 -1.551615305797954250e+02 diff --git a/test_dp_test_ener_detail.f.out b/test_dp_test_ener_detail.f.out new file mode 100644 index 0000000000..4540e0c88f --- /dev/null +++ b/test_dp_test_ener_detail.f.out @@ -0,0 +1,7 @@ +# test_dp_test: data_fx data_fy data_fz pred_fx pred_fy pred_fz +0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 -3.034045420701181883e-01 8.405844663871181455e-01 7.696947487118487030e-02 +0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 7.662001266663508448e-01 -1.880601391333554806e-01 -6.183333871091726275e-01 +0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 -5.036172391059646758e-01 -6.529525836149031592e-01 5.432962643022045679e-01 +0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 6.382357912332117245e-01 -1.748518296794554228e-01 3.457363524891896023e-01 +0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.286482986992017880e-03 3.757251165286917272e-01 -5.972588700887530022e-01 +0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 -5.987006197104719485e-01 -2.004450304880957823e-01 2.495901655353460757e-01 diff --git a/test_dp_test_ener_detail.v.out b/test_dp_test_ener_detail.v.out new file mode 100644 index 0000000000..14ee501a23 --- /dev/null +++ b/test_dp_test_ener_detail.v.out @@ -0,0 +1,2 @@ +# test_dp_test: data_vxx data_vxy data_vxz data_vyx data_vyy data_vyz data_vzx data_vzy data_vzz pred_vxx pred_vxy pred_vxz pred_vyx pred_vyy pred_vyz pred_vzx pred_vzy pred_vzz +0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 -1.179031485226732068e+00 -2.596100474696118043e-01 8.164681548048798865e-01 -2.596100474696119154e-01 -7.825573876862044198e-01 5.679382587188411824e-01 8.164681548048796644e-01 5.679382587188411824e-01 -1.151431907422429735e+00 diff --git a/test_dp_test_ener_detail.v_peratom.out b/test_dp_test_ener_detail.v_peratom.out new file mode 100644 index 0000000000..658c445919 --- /dev/null +++ b/test_dp_test_ener_detail.v_peratom.out @@ -0,0 +1,2 @@ +# test_dp_test: data_vxx data_vxy data_vxz data_vyx data_vyy data_vyz data_vzx data_vzy data_vzz pred_vxx pred_vxy pred_vxz pred_vyx pred_vyy pred_vyz pred_vzx pred_vzy pred_vzz +0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 -1.965052475377886687e-01 -4.326834124493530304e-02 1.360780258008133237e-01 -4.326834124493531691e-02 -1.304262312810340607e-01 9.465637645314019244e-02 1.360780258008132682e-01 9.465637645314019244e-02 -1.919053179037382983e-01 diff --git a/test_dp_test_global_dipole_detail.out b/test_dp_test_global_dipole_detail.out new file mode 100644 index 0000000000..56d5c5ac51 --- /dev/null +++ b/test_dp_test_global_dipole_detail.out @@ -0,0 +1,2 @@ +# data_x data_y data_z pred_x pred_y pred_z +1.999842581856713597e+00 1.840835711119364504e+00 1.919911974901817864e+00 1.999842581856713153e+00 1.840835711119364282e+00 1.919911974901818086e+00 diff --git a/test_dp_test_global_polar_detail.out b/test_dp_test_global_polar_detail.out new file mode 100644 index 0000000000..1c2e44ddf1 --- /dev/null +++ b/test_dp_test_global_polar_detail.out @@ -0,0 +1,2 @@ +# data_pxx data_pxy data_pxz data_pyx data_pyy data_pyz data_pzx data_pzy data_pzz pred_pxx pred_pxy pred_pxz pred_pyx pred_pyy pred_pyz pred_pzx pred_pzy pred_pzz +1.342938622232815238e+00 -7.286320772665506595e-01 7.085304779367757044e-01 -7.286320772665505485e-01 1.417089537086866136e+00 -1.201534051322275254e-01 7.085304779367752603e-01 -1.201534051322276503e-01 4.529260580842931483e-01 1.342938622232815460e+00 -7.286320772665501044e-01 7.085304779367762595e-01 -7.286320772665502155e-01 1.417089537086865025e+00 -1.201534051322279001e-01 7.085304779367757044e-01 -1.201534051322279140e-01 4.529260580842933703e-01 diff --git a/test_dp_test_polar_detail.out b/test_dp_test_polar_detail.out new file mode 100644 index 0000000000..afb53b48b9 --- /dev/null +++ b/test_dp_test_polar_detail.out @@ -0,0 +1,2 @@ +# data_pxx1 data_pxy1 data_pxz1 data_pyx1 data_pyy1 data_pyz1 data_pzx1 data_pzy1 data_pzz1 data_pxx2 data_pxy2 data_pxz2 data_pyx2 data_pyy2 data_pyz2 data_pzx2 data_pzy2 data_pzz2 pred_pxx1 pred_pxy1 pred_pxz1 pred_pyx1 pred_pyy1 pred_pyz1 pred_pzx1 pred_pzy1 pred_pzz1 pred_pxx2 pred_pxy2 pred_pxz2 pred_pyx2 pred_pyy2 pred_pyz2 pred_pzx2 pred_pzy2 pred_pzz2 +1.061407927405987051e-01 -3.569013342133873778e-01 -2.862108976089940138e-02 -3.569013342133875444e-01 1.304367268874677244e+00 1.037647501453442256e-01 -2.862108976089940138e-02 1.037647501453441284e-01 8.100521520762453409e-03 1.236797829492216616e+00 -3.717307430531632262e-01 7.371515676976750919e-01 -3.717307430531630041e-01 1.127222682121889058e-01 -2.239181552775717510e-01 7.371515676976746478e-01 -2.239181552775717787e-01 4.448255365635306879e-01 1.061407927405984830e-01 -3.569013342133869893e-01 -2.862108976089929382e-02 -3.569013342133871003e-01 1.304367268874676133e+00 1.037647501453439619e-01 -2.862108976089929036e-02 1.037647501453438925e-01 8.100521520762411776e-03 1.236797829492217060e+00 -3.717307430531631152e-01 7.371515676976755360e-01 -3.717307430531631152e-01 1.127222682121889197e-01 -2.239181552775718620e-01 7.371515676976749809e-01 -2.239181552775718065e-01 4.448255365635309655e-01 From 4e9642b38715703a0cc247ab803f22aa058125ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 24 Aug 2025 14:25:24 +0000 Subject: [PATCH 3/8] Create comprehensive GitHub Copilot instructions for DeePMD-kit Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> --- .github/copilot-instructions.md | 157 ++++++++++++++++++ examples/water/se_e2_a/se_e2_a.hdf5 | Bin 0 -> 5640 bytes .../set.000/atomic_polarizability.npy | Bin 272 -> 0 bytes test_dp_test/set.000/polarizability.npy | Bin 200 -> 0 bytes test_dp_test_ener_detail.v.out | 2 +- test_dp_test_ener_detail.v_peratom.out | 2 +- 6 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 .github/copilot-instructions.md create mode 100644 examples/water/se_e2_a/se_e2_a.hdf5 delete mode 100644 test_dp_test/set.000/atomic_polarizability.npy delete mode 100644 test_dp_test/set.000/polarizability.npy diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000000..d6ac4c029f --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,157 @@ +# DeePMD-kit +DeePMD-kit is a deep learning package for many-body potential energy representation and molecular dynamics. It supports multiple backends (TensorFlow, PyTorch, JAX, Paddle) and integrates with MD packages like LAMMPS, GROMACS, and i-PI. + +**Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.** + +## Working Effectively + +### Bootstrap and Build Repository +- Create virtual environment: `uv venv venv && source venv/bin/activate` +- Install base dependencies: `uv pip install tensorflow-cpu` (takes ~8 seconds) +- Install PyTorch: `uv pip install torch --index-url https://download.pytorch.org/whl/cpu` (takes ~5 seconds) +- Build Python package: `uv pip install -e .[cpu,test]` -- takes 67 seconds. **NEVER CANCEL. Set timeout to 120+ seconds.** +- Build C++ components: `export TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')` then `export PYTORCH_ROOT=$(python -c 'import torch;print(torch.__path__[0])')` then `./source/install/build_cc.sh` -- takes 164 seconds. **NEVER CANCEL. Set timeout to 300+ seconds.** + +### Test Repository +- Run single test: `pytest source/tests/tf/test_dp_test.py::TestDPTestEner::test_1frame -v` -- takes 8-13 seconds +- Run test subset: `pytest source/tests/tf/test_dp_test.py -v` -- takes 15 seconds. **NEVER CANCEL. Set timeout to 60+ seconds.** +- Full test suite has 314 test files across backends. **NEVER CANCEL: Full test suite takes 60+ minutes. Set timeout to 120+ minutes.** + +### Lint and Format Code +- Install linter: `uv pip install ruff` +- Run linting: `ruff check .` -- takes <1 second +- Format code: `ruff format .` -- takes <1 second +- **Always run `ruff check .` and `ruff format .` before committing changes or the CI will fail.** + +### Training and Validation +- Test TensorFlow training: `cd examples/water/se_e2_a && dp train input.json --skip-neighbor-stat` -- training proceeds but is slow on CPU +- Test PyTorch training: `cd examples/water/se_e2_a && dp --pt train input_torch.json --skip-neighbor-stat` -- training proceeds but is slow on CPU +- **Training examples are for validation only. Real training takes hours/days. Timeout training tests after 60 seconds for validation.** + +## Validation Scenarios + +**ALWAYS manually validate any new code through at least one complete scenario:** + +### Basic Functionality Validation +1. **CLI Interface**: Run `dp --version` and `dp -h` to verify installation +2. **Python Interface**: Run `python -c "import deepmd; import deepmd.tf; print('Both interfaces work')"` +3. **Backend Selection**: Test `dp --tf -h`, `dp --pt -h`, `dp --jax -h`, `dp --pd -h` + +### Training Workflow Validation +1. **TensorFlow Training**: `cd examples/water/se_e2_a && timeout 60 dp train input.json --skip-neighbor-stat` -- should start training and show decreasing loss +2. **PyTorch Training**: `cd examples/water/se_e2_a && timeout 60 dp --pt train input_torch.json --skip-neighbor-stat` -- should start training and show decreasing loss +3. **Verify training output**: Look for "batch X: trn: rmse" messages showing decreasing error values + +### Test-Based Validation +1. **Core Tests**: `pytest source/tests/tf/test_dp_test.py::TestDPTestEner::test_1frame -v` -- should pass in ~10 seconds +2. **Multi-backend**: Test both TensorFlow and PyTorch components work + +## Common Commands and Timing + +### Repository Structure +``` +ls -la [repo-root] +.github/ # GitHub workflows and templates +CONTRIBUTING.md # Contributing guide +README.md # Project overview +deepmd/ # Python package source +doc/ # Documentation +examples/ # Training examples and configurations +pyproject.toml # Python build configuration +source/ # C++ source code and tests +``` + +### Key Directories and Files +- `deepmd/` - Main Python package with backend implementations +- `source/lib/` - Core C++ library +- `source/op/` - Backend-specific operators (TF, PyTorch, etc.) +- `source/api_cc/` - C++ API +- `source/api_c/` - C API +- `source/tests/` - Test suite (314 test files) +- `examples/water/se_e2_a/` - Basic water training example +- `examples/` - Various model examples for different scenarios + +### Common CLI Commands +- `dp --version` - Show version information +- `dp -h` - Show help and available commands +- `dp train input.json` - Train a model (TensorFlow backend) +- `dp --pt train input.json` - Train with PyTorch backend +- `dp --jax train input.json` - Train with JAX backend +- `dp --pd train input.json` - Train with Paddle backend +- `dp test -m model.pb -s system/` - Test a trained model +- `dp freeze -o model.pb` - Freeze/save a model + +### Build Dependencies and Setup +- **Python 3.9+** required +- **Virtual environment** strongly recommended: `uv venv venv && source venv/bin/activate` +- **Backend dependencies**: TensorFlow, PyTorch, JAX, or Paddle (install before building) +- **Build tools**: CMake, C++ compiler, scikit-build-core +- **C++ build requires**: Both TensorFlow and PyTorch installed, set TENSORFLOW_ROOT and PYTORCH_ROOT environment variables + +### Key Configuration Files +- `pyproject.toml` - Python build configuration and dependencies +- `source/CMakeLists.txt` - C++ build configuration +- `examples/water/se_e2_a/input.json` - Basic TensorFlow training config +- `examples/water/se_e2_a/input_torch.json` - Basic PyTorch training config + +## Frequent Patterns and Time Expectations + +### Installation and Build Times +- **Virtual environment setup**: ~5 seconds +- **TensorFlow CPU install**: ~8 seconds +- **PyTorch CPU install**: ~5 seconds +- **Python package build**: ~67 seconds. **NEVER CANCEL.** +- **C++ components build**: ~164 seconds. **NEVER CANCEL.** +- **Full fresh setup**: ~3-4 minutes total + +### Testing Times +- **Single test**: 8-13 seconds +- **Test file (~5 tests)**: ~15 seconds +- **Backend-specific test suite**: 15-30 minutes. **NEVER CANCEL.** +- **Full test suite (314 files)**: 60+ minutes. **NEVER CANCEL.** + +### Linting and Formatting +- **Ruff check**: <1 second +- **Ruff format**: <1 second +- **Pre-commit hooks**: May have network issues, use individual tools + +### Training and Model Operations +- **Training initialization**: 10-30 seconds +- **Training per batch**: 0.1-1 second (CPU), much faster on GPU +- **Model freezing**: 5-15 seconds +- **Model testing**: 10-30 seconds + +## Backend-Specific Notes + +### TensorFlow Backend +- **Default backend** when no flag specified +- **Configuration**: Use `input.json` format +- **Training**: `dp train input.json` +- **Requirements**: `tensorflow` or `tensorflow-cpu` package + +### PyTorch Backend +- **Activation**: Use `--pt` flag or `export DP_BACKEND=pytorch` +- **Configuration**: Use `input_torch.json` format typically +- **Training**: `dp --pt train input_torch.json` +- **Requirements**: `torch` package + +### JAX Backend +- **Activation**: Use `--jax` flag +- **Training**: `dp --jax train input.json` +- **Requirements**: `jax` and related packages +- **Note**: Experimental backend, may have limitations + +### Paddle Backend +- **Activation**: Use `--pd` flag +- **Training**: `dp --pd train input.json` +- **Requirements**: `paddlepaddle` package +- **Note**: Less commonly used + +## Critical Warnings + +- **NEVER CANCEL BUILD OPERATIONS**: Python build takes 67 seconds, C++ build takes 164 seconds +- **NEVER CANCEL FULL TEST SUITE**: Takes 60+ minutes, always set appropriate timeouts +- **ALWAYS activate virtual environment**: Build and runtime failures occur without proper environment +- **ALWAYS install backend dependencies first**: TensorFlow/PyTorch required before building C++ components +- **ALWAYS run linting before commits**: `ruff check . && ruff format .` or CI will fail +- **ALWAYS test both Python and C++ components**: Some features require both to be built \ No newline at end of file diff --git a/examples/water/se_e2_a/se_e2_a.hdf5 b/examples/water/se_e2_a/se_e2_a.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..56ad60fcfeb54a470f8daa9117188d3437b88df4 GIT binary patch literal 5640 zcmeD5aB<`1lHy_j0S*oZ76t(@6Gr@p0uC{V2#gPtPk=HQp>zk7Ucm%mFfxE31A_!q zTo7tLy1I}cS62q0N|^aD8mf)q0V{;X0TURdM^p%SxH<-aJRAY_H7u2$fTlB8VE8L| zfSIuL2;sqGNvCn8Uk_%8SsBoDNhtlk;Do3LdxCUljOrNTAplFi8=(G3fYJ{HQ9YJy zXlP_^oMxP4YG9UXZkTFfkdk7Nm||(3W}0GYmTHuoXapq9Q(?Mb>0ALOfJO)V`MZG9 zFs$5EfTmlRKJ;{qrhSwP4FO!`Kma>LK>;*>6DkKBcp&Ow_2Fm$kE{@Yl>@MPOatou z3DEQd3yq?9128iYN*Bc&LirFHmVY6tV7hSAkaB>T!2+t}f&gx{AQ@PBp#e?bF#FKc zdjQm!2}1bI8!obp46NYxEQA2HSRpx?kr5I?(BhQ=K}&#@3M$w`!_(TObMvBUp&SLTqrQH~NLgj?wS{ zCILiwbYX~whXyzyGeU}223U6yR-d8snStdmNRIUK`UNz6&@0voSVkI9n$&(pQf6Xt zd}2v{ZhUH9YEgP6%<;t~DJa6QaD=r3VCu-FG4nUQ;_t_xjz4n4b5!3j2mvPx$1Fp? zbF2p&;OzpiuXGF?``*peDtz|B;pewq{jc0EIe^8TJRD;n>JPxgUu2gFz)LWl NegLeF;e$Pl1^|}7(XIdh literal 0 HcmV?d00001 diff --git a/test_dp_test/set.000/atomic_polarizability.npy b/test_dp_test/set.000/atomic_polarizability.npy deleted file mode 100644 index 59ce6c7b5b4b5884f9727ea89ce1a6cd0cf6dd60..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 272 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-7CM?b3bhL41FmVyrZaNu?6$usF>PbT^=tcCUjMsz!*A~XD^R}7qB&+8 z?tQU8CmgjPc)~7wnEY`l--b-(?H$$PYK+H?C~ mP`=@`hU>An_t>9!{b@nu$}{^fLgi0F`R14Zwy{>+u?GO2Wp4HW diff --git a/test_dp_test/set.000/polarizability.npy b/test_dp_test/set.000/polarizability.npy deleted file mode 100644 index be089c3103e98debea641c55dfb15c67174ad249..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 200 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-ItrGWItsN4WCO0G^a9hhHDB#tEV*j_CE)q~+NJlTJ=Q$4e-7o>uNDzW fTl3BS(BbZd@rU;9uY}5MfT diff --git a/test_dp_test_ener_detail.v.out b/test_dp_test_ener_detail.v.out index 14ee501a23..a0b38821c0 100644 --- a/test_dp_test_ener_detail.v.out +++ b/test_dp_test_ener_detail.v.out @@ -1,2 +1,2 @@ # test_dp_test: data_vxx data_vxy data_vxz data_vyx data_vyy data_vyz data_vzx data_vzy data_vzz pred_vxx pred_vxy pred_vxz pred_vyx pred_vyy pred_vyz pred_vzx pred_vzy pred_vzz -0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 -1.179031485226732068e+00 -2.596100474696118043e-01 8.164681548048798865e-01 -2.596100474696119154e-01 -7.825573876862044198e-01 5.679382587188411824e-01 8.164681548048796644e-01 5.679382587188411824e-01 -1.151431907422429735e+00 +0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 -1.179031485226731624e+00 -2.596100474696118598e-01 8.164681548048798865e-01 -2.596100474696118598e-01 -7.825573876862043088e-01 5.679382587188411824e-01 8.164681548048795534e-01 5.679382587188412934e-01 -1.151431907422429513e+00 diff --git a/test_dp_test_ener_detail.v_peratom.out b/test_dp_test_ener_detail.v_peratom.out index 658c445919..009a68718a 100644 --- a/test_dp_test_ener_detail.v_peratom.out +++ b/test_dp_test_ener_detail.v_peratom.out @@ -1,2 +1,2 @@ # test_dp_test: data_vxx data_vxy data_vxz data_vyx data_vyy data_vyz data_vzx data_vzy data_vzz pred_vxx pred_vxy pred_vxz pred_vyx pred_vyy pred_vyz pred_vzx pred_vzy pred_vzz -0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 -1.965052475377886687e-01 -4.326834124493530304e-02 1.360780258008133237e-01 -4.326834124493531691e-02 -1.304262312810340607e-01 9.465637645314019244e-02 1.360780258008132682e-01 9.465637645314019244e-02 -1.919053179037382983e-01 +0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 -1.965052475377886132e-01 -4.326834124493530997e-02 1.360780258008133237e-01 -4.326834124493530997e-02 -1.304262312810340607e-01 9.465637645314019244e-02 1.360780258008132682e-01 9.465637645314022020e-02 -1.919053179037382428e-01 From cb2f67a862b2bf0bafb680a920b24bd742961fdf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 24 Aug 2025 14:37:19 +0000 Subject: [PATCH 4/8] Address feedback: recommend single tests, add workflow setup, clean temp files Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> --- .github/copilot-instructions.md | 8 +- .github/workflows/copilot-setup-steps.yml | 65 +++++++++++++++ .gitignore | 5 ++ examples/water/se_e2_a/input_v2_compat.json | 84 -------------------- examples/water/se_e2_a/se_e2_a.hdf5 | Bin 5640 -> 0 bytes test_dp_test/set.000/box.npy | Bin 200 -> 0 bytes test_dp_test/set.000/coord.npy | Bin 272 -> 0 bytes test_dp_test/type.raw | 6 -- test_dp_test/type_map.raw | 2 - test_dp_test_dipole_detail.out | 2 - test_dp_test_ener_detail.e.out | 2 - test_dp_test_ener_detail.e_peratom.out | 2 - test_dp_test_ener_detail.f.out | 7 -- test_dp_test_ener_detail.v.out | 2 - test_dp_test_ener_detail.v_peratom.out | 2 - test_dp_test_global_dipole_detail.out | 2 - test_dp_test_global_polar_detail.out | 2 - test_dp_test_polar_detail.out | 2 - 18 files changed, 74 insertions(+), 119 deletions(-) create mode 100644 .github/workflows/copilot-setup-steps.yml delete mode 100644 examples/water/se_e2_a/input_v2_compat.json delete mode 100644 examples/water/se_e2_a/se_e2_a.hdf5 delete mode 100644 test_dp_test/set.000/box.npy delete mode 100644 test_dp_test/set.000/coord.npy delete mode 100644 test_dp_test/type.raw delete mode 100644 test_dp_test/type_map.raw delete mode 100644 test_dp_test_dipole_detail.out delete mode 100644 test_dp_test_ener_detail.e.out delete mode 100644 test_dp_test_ener_detail.e_peratom.out delete mode 100644 test_dp_test_ener_detail.f.out delete mode 100644 test_dp_test_ener_detail.v.out delete mode 100644 test_dp_test_ener_detail.v_peratom.out delete mode 100644 test_dp_test_global_dipole_detail.out delete mode 100644 test_dp_test_global_polar_detail.out delete mode 100644 test_dp_test_polar_detail.out diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index d6ac4c029f..ef236f2ccf 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -15,7 +15,7 @@ DeePMD-kit is a deep learning package for many-body potential energy representat ### Test Repository - Run single test: `pytest source/tests/tf/test_dp_test.py::TestDPTestEner::test_1frame -v` -- takes 8-13 seconds - Run test subset: `pytest source/tests/tf/test_dp_test.py -v` -- takes 15 seconds. **NEVER CANCEL. Set timeout to 60+ seconds.** -- Full test suite has 314 test files across backends. **NEVER CANCEL: Full test suite takes 60+ minutes. Set timeout to 120+ minutes.** +- **Recommended: Use single test cases for validation instead of full test suite** -- full suite has 314 test files and takes 60+ minutes ### Lint and Format Code - Install linter: `uv pip install ruff` @@ -107,8 +107,8 @@ source/ # C++ source code and tests ### Testing Times - **Single test**: 8-13 seconds - **Test file (~5 tests)**: ~15 seconds -- **Backend-specific test suite**: 15-30 minutes. **NEVER CANCEL.** -- **Full test suite (314 files)**: 60+ minutes. **NEVER CANCEL.** +- **Backend-specific test subset**: 15-30 minutes. **Use sparingly.** +- **Full test suite (314 files)**: 60+ minutes. **Avoid in development - use single tests instead.** ### Linting and Formatting - **Ruff check**: <1 second @@ -150,7 +150,7 @@ source/ # C++ source code and tests ## Critical Warnings - **NEVER CANCEL BUILD OPERATIONS**: Python build takes 67 seconds, C++ build takes 164 seconds -- **NEVER CANCEL FULL TEST SUITE**: Takes 60+ minutes, always set appropriate timeouts +- **USE SINGLE TESTS FOR VALIDATION**: Run individual tests instead of full test suite for faster feedback - **ALWAYS activate virtual environment**: Build and runtime failures occur without proper environment - **ALWAYS install backend dependencies first**: TensorFlow/PyTorch required before building C++ components - **ALWAYS run linting before commits**: `ruff check . && ruff format .` or CI will fail diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 0000000000..70c4008b21 --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,65 @@ +name: "Copilot Setup Steps" + +# Automatically run the setup steps when they are changed to allow for easy validation, and +# allow manual testing through the repository's "Actions" tab +on: + workflow_dispatch: + push: + paths: + - .github/workflows/copilot-setup-steps.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + +jobs: + # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. + copilot-setup-steps: + runs-on: ubuntu-latest + + # Set the permissions to the lowest permissions possible needed for your steps. + # Copilot will be given its own token for its operations. + permissions: + # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete. + contents: read + + # You can define any steps you want, and they will run before the agent starts. + # If you do not check out your code, Copilot will do this for you. + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + enable-cache: true + + - name: Create virtual environment + run: uv venv venv + + - name: Activate virtual environment + run: echo "VIRTUAL_ENV=$PWD/venv" >> $GITHUB_ENV && echo "$PWD/venv/bin" >> $GITHUB_PATH + + - name: Install base dependencies + run: uv pip install tensorflow-cpu + + - name: Install PyTorch + run: uv pip install torch --index-url https://download.pytorch.org/whl/cpu + + - name: Build Python package + run: uv pip install -e .[cpu,test] + + - name: Install pre-commit tools + run: uv tool install pre-commit + + - name: Install pre-commit hooks + run: pre-commit install --install-hooks + + - name: Verify installation + run: | + dp --version + python -c "import deepmd; import deepmd.tf; print('DeePMD-kit installation verified')" \ No newline at end of file diff --git a/.gitignore b/.gitignore index c574da757a..9f63a65219 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,8 @@ uv.lock buildcxx/ node_modules/ *.bib.original + +# Test output files (temporary) +test_dp_test/ +test_dp_test_*.out +*_detail.out diff --git a/examples/water/se_e2_a/input_v2_compat.json b/examples/water/se_e2_a/input_v2_compat.json deleted file mode 100644 index 2505332cdb..0000000000 --- a/examples/water/se_e2_a/input_v2_compat.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "_comment1": " model parameters", - "model": { - "type_map": [ - "O", - "H" - ], - "descriptor": { - "type": "se_e2_a", - "sel": [ - 46, - 92 - ], - "rcut_smth": 0.5, - "rcut": 6.0, - "neuron": [ - 25, - 50, - 100 - ], - "resnet_dt": false, - "axis_neuron": 16, - "type_one_side": true, - "precision": "float64", - "seed": 1, - "_comment2": " that's all" - }, - "fitting_net": { - "neuron": [ - 240, - 240, - 240 - ], - "resnet_dt": true, - "precision": "float64", - "seed": 1, - "_comment3": " that's all" - }, - "_comment4": " that's all" - }, - "learning_rate": { - "type": "exp", - "decay_steps": 5000, - "start_lr": 0.001, - "stop_lr": 3.51e-08, - "_comment5": "that's all" - }, - "loss": { - "type": "ener", - "start_pref_e": 0.02, - "limit_pref_e": 1, - "start_pref_f": 1000, - "limit_pref_f": 1, - "start_pref_v": 0, - "limit_pref_v": 0, - "_comment6": " that's all" - }, - "training": { - "training_data": { - "systems": [ - "../data/data_0/", - "../data/data_1/", - "../data/data_2/" - ], - "batch_size": "auto", - "_comment7": "that's all" - }, - "validation_data": { - "systems": [ - "../data/data_3" - ], - "batch_size": 1, - "numb_btch": 3, - "_comment8": "that's all" - }, - "numb_steps": 1000000, - "seed": 10, - "disp_file": "lcurve.out", - "disp_freq": 100, - "save_freq": 1000, - "_comment9": "that's all" - }, - "_comment10": "that's all" -} \ No newline at end of file diff --git a/examples/water/se_e2_a/se_e2_a.hdf5 b/examples/water/se_e2_a/se_e2_a.hdf5 deleted file mode 100644 index 56ad60fcfeb54a470f8daa9117188d3437b88df4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5640 zcmeD5aB<`1lHy_j0S*oZ76t(@6Gr@p0uC{V2#gPtPk=HQp>zk7Ucm%mFfxE31A_!q zTo7tLy1I}cS62q0N|^aD8mf)q0V{;X0TURdM^p%SxH<-aJRAY_H7u2$fTlB8VE8L| zfSIuL2;sqGNvCn8Uk_%8SsBoDNhtlk;Do3LdxCUljOrNTAplFi8=(G3fYJ{HQ9YJy zXlP_^oMxP4YG9UXZkTFfkdk7Nm||(3W}0GYmTHuoXapq9Q(?Mb>0ALOfJO)V`MZG9 zFs$5EfTmlRKJ;{qrhSwP4FO!`Kma>LK>;*>6DkKBcp&Ow_2Fm$kE{@Yl>@MPOatou z3DEQd3yq?9128iYN*Bc&LirFHmVY6tV7hSAkaB>T!2+t}f&gx{AQ@PBp#e?bF#FKc zdjQm!2}1bI8!obp46NYxEQA2HSRpx?kr5I?(BhQ=K}&#@3M$w`!_(TObMvBUp&SLTqrQH~NLgj?wS{ zCILiwbYX~whXyzyGeU}223U6yR-d8snStdmNRIUK`UNz6&@0voSVkI9n$&(pQf6Xt zd}2v{ZhUH9YEgP6%<;t~DJa6QaD=r3VCu-FG4nUQ;_t_xjz4n4b5!3j2mvPx$1Fp? zbF2p&;OzpiuXGF?``*peDtz|B;pewq{jc0EIe^8TJRD;n>JPxgUu2gFz)LWl NegLeF;e$Pl1^|}7(XIdh diff --git a/test_dp_test/set.000/box.npy b/test_dp_test/set.000/box.npy deleted file mode 100644 index b7c43fa8e84745f1f2f3de6f56c47ab7d751e51d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 200 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= hXCxM+0{I$-ItrGWItsN4WCJb+Fwk;<(6~s#@&G(89J2rb diff --git a/test_dp_test/set.000/coord.npy b/test_dp_test/set.000/coord.npy deleted file mode 100644 index 65e86d40546f208debd73d5dda8e801b70b1eea9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 272 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$-ItqpsnmP)#3giMV&6xf}Usq^4REw;0e^|xhP-x3_eQ^P!1BfT0r{VBT z1Ehe>;Z5KUxz^XL4h&#$!5%0Gl;Ls!ssbwgWe=gbpz<70eShr1#)|MbKxh_+vu8kn S1 Date: Sun, 24 Aug 2025 14:42:21 +0000 Subject: [PATCH 5/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/copilot-instructions.md | 35 ++++++++++++++++++----- .github/workflows/copilot-setup-steps.yml | 2 +- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index ef236f2ccf..8cdce3329f 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,4 +1,5 @@ # DeePMD-kit + DeePMD-kit is a deep learning package for many-body potential energy representation and molecular dynamics. It supports multiple backends (TensorFlow, PyTorch, JAX, Paddle) and integrates with MD packages like LAMMPS, GROMACS, and i-PI. **Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.** @@ -6,6 +7,7 @@ DeePMD-kit is a deep learning package for many-body potential energy representat ## Working Effectively ### Bootstrap and Build Repository + - Create virtual environment: `uv venv venv && source venv/bin/activate` - Install base dependencies: `uv pip install tensorflow-cpu` (takes ~8 seconds) - Install PyTorch: `uv pip install torch --index-url https://download.pytorch.org/whl/cpu` (takes ~5 seconds) @@ -13,17 +15,20 @@ DeePMD-kit is a deep learning package for many-body potential energy representat - Build C++ components: `export TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')` then `export PYTORCH_ROOT=$(python -c 'import torch;print(torch.__path__[0])')` then `./source/install/build_cc.sh` -- takes 164 seconds. **NEVER CANCEL. Set timeout to 300+ seconds.** ### Test Repository + - Run single test: `pytest source/tests/tf/test_dp_test.py::TestDPTestEner::test_1frame -v` -- takes 8-13 seconds - Run test subset: `pytest source/tests/tf/test_dp_test.py -v` -- takes 15 seconds. **NEVER CANCEL. Set timeout to 60+ seconds.** - **Recommended: Use single test cases for validation instead of full test suite** -- full suite has 314 test files and takes 60+ minutes ### Lint and Format Code + - Install linter: `uv pip install ruff` - Run linting: `ruff check .` -- takes <1 second - Format code: `ruff format .` -- takes <1 second - **Always run `ruff check .` and `ruff format .` before committing changes or the CI will fail.** ### Training and Validation + - Test TensorFlow training: `cd examples/water/se_e2_a && dp train input.json --skip-neighbor-stat` -- training proceeds but is slow on CPU - Test PyTorch training: `cd examples/water/se_e2_a && dp --pt train input_torch.json --skip-neighbor-stat` -- training proceeds but is slow on CPU - **Training examples are for validation only. Real training takes hours/days. Timeout training tests after 60 seconds for validation.** @@ -33,22 +38,26 @@ DeePMD-kit is a deep learning package for many-body potential energy representat **ALWAYS manually validate any new code through at least one complete scenario:** ### Basic Functionality Validation + 1. **CLI Interface**: Run `dp --version` and `dp -h` to verify installation -2. **Python Interface**: Run `python -c "import deepmd; import deepmd.tf; print('Both interfaces work')"` +2. **Python Interface**: Run `python -c "import deepmd; import deepmd.tf; print('Both interfaces work')"` 3. **Backend Selection**: Test `dp --tf -h`, `dp --pt -h`, `dp --jax -h`, `dp --pd -h` ### Training Workflow Validation + 1. **TensorFlow Training**: `cd examples/water/se_e2_a && timeout 60 dp train input.json --skip-neighbor-stat` -- should start training and show decreasing loss 2. **PyTorch Training**: `cd examples/water/se_e2_a && timeout 60 dp --pt train input_torch.json --skip-neighbor-stat` -- should start training and show decreasing loss 3. **Verify training output**: Look for "batch X: trn: rmse" messages showing decreasing error values ### Test-Based Validation + 1. **Core Tests**: `pytest source/tests/tf/test_dp_test.py::TestDPTestEner::test_1frame -v` -- should pass in ~10 seconds 2. **Multi-backend**: Test both TensorFlow and PyTorch components work ## Common Commands and Timing ### Repository Structure + ``` ls -la [repo-root] .github/ # GitHub workflows and templates @@ -57,11 +66,12 @@ README.md # Project overview deepmd/ # Python package source doc/ # Documentation examples/ # Training examples and configurations -pyproject.toml # Python build configuration +pyproject.toml # Python build configuration source/ # C++ source code and tests ``` ### Key Directories and Files + - `deepmd/` - Main Python package with backend implementations - `source/lib/` - Core C++ library - `source/op/` - Backend-specific operators (TF, PyTorch, etc.) @@ -72,16 +82,18 @@ source/ # C++ source code and tests - `examples/` - Various model examples for different scenarios ### Common CLI Commands + - `dp --version` - Show version information - `dp -h` - Show help and available commands - `dp train input.json` - Train a model (TensorFlow backend) - `dp --pt train input.json` - Train with PyTorch backend -- `dp --jax train input.json` - Train with JAX backend +- `dp --jax train input.json` - Train with JAX backend - `dp --pd train input.json` - Train with Paddle backend - `dp test -m model.pb -s system/` - Test a trained model - `dp freeze -o model.pb` - Freeze/save a model ### Build Dependencies and Setup + - **Python 3.9+** required - **Virtual environment** strongly recommended: `uv venv venv && source venv/bin/activate` - **Backend dependencies**: TensorFlow, PyTorch, JAX, or Paddle (install before building) @@ -89,6 +101,7 @@ source/ # C++ source code and tests - **C++ build requires**: Both TensorFlow and PyTorch installed, set TENSORFLOW_ROOT and PYTORCH_ROOT environment variables ### Key Configuration Files + - `pyproject.toml` - Python build configuration and dependencies - `source/CMakeLists.txt` - C++ build configuration - `examples/water/se_e2_a/input.json` - Basic TensorFlow training config @@ -97,25 +110,29 @@ source/ # C++ source code and tests ## Frequent Patterns and Time Expectations ### Installation and Build Times + - **Virtual environment setup**: ~5 seconds -- **TensorFlow CPU install**: ~8 seconds +- **TensorFlow CPU install**: ~8 seconds - **PyTorch CPU install**: ~5 seconds - **Python package build**: ~67 seconds. **NEVER CANCEL.** - **C++ components build**: ~164 seconds. **NEVER CANCEL.** - **Full fresh setup**: ~3-4 minutes total ### Testing Times + - **Single test**: 8-13 seconds - **Test file (~5 tests)**: ~15 seconds - **Backend-specific test subset**: 15-30 minutes. **Use sparingly.** - **Full test suite (314 files)**: 60+ minutes. **Avoid in development - use single tests instead.** ### Linting and Formatting + - **Ruff check**: <1 second - **Ruff format**: <1 second - **Pre-commit hooks**: May have network issues, use individual tools ### Training and Model Operations + - **Training initialization**: 10-30 seconds - **Training per batch**: 0.1-1 second (CPU), much faster on GPU - **Model freezing**: 5-15 seconds @@ -124,25 +141,29 @@ source/ # C++ source code and tests ## Backend-Specific Notes ### TensorFlow Backend + - **Default backend** when no flag specified - **Configuration**: Use `input.json` format - **Training**: `dp train input.json` - **Requirements**: `tensorflow` or `tensorflow-cpu` package -### PyTorch Backend +### PyTorch Backend + - **Activation**: Use `--pt` flag or `export DP_BACKEND=pytorch` - **Configuration**: Use `input_torch.json` format typically - **Training**: `dp --pt train input_torch.json` - **Requirements**: `torch` package ### JAX Backend + - **Activation**: Use `--jax` flag - **Training**: `dp --jax train input.json` - **Requirements**: `jax` and related packages - **Note**: Experimental backend, may have limitations ### Paddle Backend -- **Activation**: Use `--pd` flag + +- **Activation**: Use `--pd` flag - **Training**: `dp --pd train input.json` - **Requirements**: `paddlepaddle` package - **Note**: Less commonly used @@ -154,4 +175,4 @@ source/ # C++ source code and tests - **ALWAYS activate virtual environment**: Build and runtime failures occur without proper environment - **ALWAYS install backend dependencies first**: TensorFlow/PyTorch required before building C++ components - **ALWAYS run linting before commits**: `ruff check . && ruff format .` or CI will fail -- **ALWAYS test both Python and C++ components**: Some features require both to be built \ No newline at end of file +- **ALWAYS test both Python and C++ components**: Some features require both to be built diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 70c4008b21..9307ed3ad9 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -62,4 +62,4 @@ jobs: - name: Verify installation run: | dp --version - python -c "import deepmd; import deepmd.tf; print('DeePMD-kit installation verified')" \ No newline at end of file + python -c "import deepmd; import deepmd.tf; print('DeePMD-kit installation verified')" From 935cbfd6fbf866b38928d29bfbcdeea0339dcc7b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 24 Aug 2025 14:46:14 +0000 Subject: [PATCH 6/8] docs: add conventional commit specification guidance Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> --- .github/copilot-instructions.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 8cdce3329f..4bd61e4789 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -131,6 +131,18 @@ source/ # C++ source code and tests - **Ruff format**: <1 second - **Pre-commit hooks**: May have network issues, use individual tools +### Commit Messages and PR Titles + +**All commit messages and PR titles must follow [conventional commit specification](https://www.conventionalcommits.org/):** + +- **Format**: `type(scope): description` +- **Common types**: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`, `ci` +- **Examples**: + - `feat(core): add new descriptor type` + - `fix(tf): resolve memory leak in training` + - `docs: update installation guide` + - `ci: add workflow for testing` + ### Training and Model Operations - **Training initialization**: 10-30 seconds @@ -176,3 +188,4 @@ source/ # C++ source code and tests - **ALWAYS install backend dependencies first**: TensorFlow/PyTorch required before building C++ components - **ALWAYS run linting before commits**: `ruff check . && ruff format .` or CI will fail - **ALWAYS test both Python and C++ components**: Some features require both to be built +- **ALWAYS follow conventional commit format**: All commit messages and PR titles must use conventional commit specification (`type(scope): description`) From 1cd05588e3f0971380ca486649fc75792e228a74 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 24 Aug 2025 14:49:51 +0000 Subject: [PATCH 7/8] feat(ci): update setup-uv action to v6 Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com> --- .github/workflows/copilot-setup-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 9307ed3ad9..21d6aef040 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -34,7 +34,7 @@ jobs: python-version: "3.10" - name: Install uv - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v6 with: enable-cache: true From 64c2a417ef40ca9d727080d42277749499d91ddf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 24 Aug 2025 14:54:17 +0000 Subject: [PATCH 8/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/copilot-instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 4bd61e4789..9b07cbd9e0 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -137,7 +137,7 @@ source/ # C++ source code and tests - **Format**: `type(scope): description` - **Common types**: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`, `ci` -- **Examples**: +- **Examples**: - `feat(core): add new descriptor type` - `fix(tf): resolve memory leak in training` - `docs: update installation guide`