Skip to content

Commit 21f6bb3

Browse files
committed
chore: merge upstream/master into pr/dpa4
2 parents a9b500a + 799252d commit 21f6bb3

32 files changed

Lines changed: 2245 additions & 1080 deletions

.github/workflows/test_cuda.yml

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,13 @@ jobs:
1919
runs-on: gpu
2020
# The serial Python test suite can take several hours on the GPU runner.
2121
timeout-minutes: 480
22-
# Share ONE AOTInductor on-disk compile cache across the two pytest lanes;
23-
# actions/cache (below) persists it across runs so unchanged models never
24-
# recompile.
25-
env:
26-
TORCHINDUCTOR_CACHE_DIR: ${{ github.workspace }}/.inductor-cache
2722
# https://github.com/deepmodeling/deepmd-kit/pull/2884#issuecomment-1744216845
2823
# container:
2924
# image: nvidia/cuda:12.9.1-cudnn-devel-ubuntu22.04
3025
# options: --gpus all
3126
if: github.repository_owner == 'deepmodeling' && (github.event_name == 'pull_request' && github.event.label && github.event.label.name == 'Test CUDA' || github.event_name == 'workflow_dispatch' || github.event_name == 'merge_group')
3227
steps:
3328
- uses: actions/checkout@v7
34-
- name: Cache AOTInductor compile artifacts
35-
# Restored AFTER checkout so checkout's git-clean can't wipe it. The repo
36-
# Actions cache is capped at 10 GB; if the inductor cache outgrows it the
37-
# oldest entries are evicted -- correctness is unaffected (inductor
38-
# re-validates each graph; a miss just recompiles).
39-
uses: actions/cache@v6
40-
with:
41-
path: ${{ github.workspace }}/.inductor-cache
42-
key: inductor-cuda-${{ github.sha }}
43-
restore-keys: |
44-
inductor-cuda-
4529
- uses: actions/setup-python@v7
4630
with:
4731
python-version: "3.11"
@@ -78,84 +62,23 @@ jobs:
7862
DP_ENABLE_NATIVE_OPTIMIZATION: 1
7963
DP_ENABLE_PYTORCH: 1
8064
- run: dp --version
81-
- name: Run Python tests (overlap CPU-bound aoti compiles with the GPU lane)
82-
# Two pytest lanes on one GPU box:
83-
# Lane 1 (CPU stream): the .pt2-freezing tests (-m aoti_compile) --
84-
# CPU-bound, GPU ~98% idle while inductor/g++/ptxas run.
85-
# Lane 2 (GPU stream): the GPU-bound remainder (-m "not aoti_compile")
86-
# -- the bulk of the suite and the wall-clock bottleneck. It does not
87-
# freeze .pt2, so it only reads the inductor cache, never competing
88-
# to write.
89-
# Wall-clock becomes max(lane 1, lane 2) instead of their sum; the whole
90-
# compile stream is hidden behind the GPU lane. (The C++ build + fixture
91-
# generation runs in the separate test_cc job.)
92-
run: |
93-
# Cap the compile lane's inductor threads to ~half the cores so lane 2
94-
# keeps CPU for its host-side GPU dispatch; nice the compile work too.
95-
nc=$(( $(nproc) / 2 )); [ "$nc" -lt 1 ] && nc=1
96-
# rc=0 + `|| rc=$?` so a lane's failure does not let the step's default
97-
# `set -e` skip the wall-clock echo (the timing we most want on failure).
98-
( ta=$(date +%s); rc=0
99-
TORCHINDUCTOR_COMPILE_THREADS=$nc nice -n 15 \
100-
python -m pytest source/tests -m "aoti_compile" \
101-
-p no:cacheprovider --junit-xml=junit-aoti.xml || rc=$?
102-
# pytest exit 5 == "no tests collected"; harmless for the compile lane.
103-
[ "$rc" = 5 ] && rc=0
104-
echo "[lane aoti_compile] wall=$(( $(date +%s) - ta ))s exit=$rc"
105-
exit $rc ) &
106-
pid_a=$!
107-
( tb=$(date +%s); rc=0
108-
python -m pytest source/tests -m "not aoti_compile" \
109-
-p no:cacheprovider --junit-xml=junit-gpu.xml || rc=$?
110-
echo "[lane gpu] wall=$(( $(date +%s) - tb ))s exit=$rc"
111-
exit $rc ) &
112-
pid_b=$!
113-
rc_a=0; wait $pid_a || rc_a=$?
114-
rc_b=0; wait $pid_b || rc_b=$?
115-
echo "lane exit codes: aoti_compile=$rc_a gpu=$rc_b"
116-
exit $(( rc_a != 0 || rc_b != 0 ))
65+
- run: python -m pytest source/tests
11766
env:
11867
NUM_WORKERS: 0
11968
CUDA_VISIBLE_DEVICES: 0
12069
# See https://jax.readthedocs.io/en/latest/gpu_memory_allocation.html
12170
XLA_PYTHON_CLIENT_PREALLOCATE: false
12271
XLA_PYTHON_CLIENT_ALLOCATOR: platform
12372
FLAGS_use_stride_compute_kernel: 0
124-
- name: Upload per-lane JUnit reports
125-
# junit-aoti.xml = compile lane (T_A), junit-gpu.xml = GPU lane (T_B);
126-
# used to compare the two lanes against the pre-split serial baseline.
127-
if: always()
128-
uses: actions/upload-artifact@v7
129-
with:
130-
name: cuda-pytest-junit
131-
path: |
132-
junit-aoti.xml
133-
junit-gpu.xml
134-
if-no-files-found: warn
13573

13674
test_cc:
13775
name: Test C++ on CUDA
13876
runs-on: gpu
139-
# The gen_*.py fixture builds drive the same AOTInductor backend on the same
140-
# architectures as the Python lanes, so they reuse the kernels cached by
141-
# test_python / previous runs.
142-
env:
143-
TORCHINDUCTOR_CACHE_DIR: ${{ github.workspace }}/.inductor-cache
14477
if: github.repository_owner == 'deepmodeling' && (github.event_name == 'pull_request' && github.event.label && github.event.label.name == 'Test CUDA' || github.event_name == 'workflow_dispatch' || github.event_name == 'merge_group')
14578
steps:
14679
# Jobs run on separate runners, so the C++ job needs its own complete
14780
# CUDA toolchain and Python dependency installation.
14881
- uses: actions/checkout@v7
149-
- name: Cache AOTInductor compile artifacts
150-
# Restored AFTER checkout so checkout's git-clean can't wipe it. Both
151-
# CUDA jobs share the same key; if both try to save it, the second save
152-
# is skipped with a warning (caches are immutable), which is harmless.
153-
uses: actions/cache@v6
154-
with:
155-
path: ${{ github.workspace }}/.inductor-cache
156-
key: inductor-cuda-${{ github.sha }}
157-
restore-keys: |
158-
inductor-cuda-
15982
- uses: actions/setup-python@v7
16083
with:
16184
python-version: "3.11"

deepmd/dpmodel/model/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,36 @@
1212
Models generated by `make_model` have already done it.
1313
"""
1414

15+
from .dipole_model import (
16+
DipoleModel,
17+
)
18+
from .dos_model import (
19+
DOSModel,
20+
)
21+
from .dp_linear_model import (
22+
LinearEnergyModel,
23+
)
1524
from .dp_model import (
1625
DPModelCommon,
1726
)
27+
from .dp_zbl_model import (
28+
DPZBLModel,
29+
)
30+
from .dpa4_model import (
31+
DPA4EnergyModel,
32+
)
1833
from .ener_model import (
1934
EnergyModel,
2035
)
2136
from .make_model import (
2237
make_model,
2338
)
39+
from .native_spin_model import (
40+
NativeSpinEnergyModel,
41+
)
42+
from .polar_model import (
43+
PolarModel,
44+
)
2445
from .property_model import (
2546
PropertyModel,
2647
)
@@ -29,8 +50,15 @@
2950
)
3051

3152
__all__ = [
53+
"DOSModel",
54+
"DPA4EnergyModel",
3255
"DPModelCommon",
56+
"DPZBLModel",
57+
"DipoleModel",
3358
"EnergyModel",
59+
"LinearEnergyModel",
60+
"NativeSpinEnergyModel",
61+
"PolarModel",
3462
"PropertyModel",
3563
"SpinModel",
3664
"make_model",

0 commit comments

Comments
 (0)