Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
221 commits
Select commit Hold shift + click to select a range
8bea38f
feat(dpmodel): segment_max/segment_softmax over trailing feature dims
Jul 12, 2026
ba95854
feat(dpmodel): repformer graph twins for cal_hg/cal_grrg/symmetrizati…
Jul 12, 2026
79dc371
feat(dpmodel): repformer layer graph twins for g1_conv / g2_g1g1
Jul 12, 2026
b513622
refactor(dpmodel): graph-twin naming convention <func_name>_graph
Jul 12, 2026
2c32acc
feat(dpmodel): graph twins for repformer attention ops
Jul 12, 2026
83babe4
feat(dpmodel): RepformerLayer.call_graph
Jul 12, 2026
b75374f
test(dpmodel): cover update_chnnl_2=False and cal_gg1=None in Repform…
Jul 12, 2026
a1e00c3
feat(dpmodel): DescrptBlockRepformers.call_graph + exchange seam
Jul 12, 2026
3b89378
feat(dpmodel): graph-native DPA2 (uses_graph_lower, call_graph, dense…
Jul 12, 2026
21a4ee1
test(dpmodel): pin dpa2 adapter davg-nonzero divergence; exercise rea…
Jul 12, 2026
9fbe20d
docs(dpmodel): correct davg-residual root-cause framing in dpa2 call_…
Jul 12, 2026
69f4c4b
feat(pt_expt): dpa2 graph lower routing tests + border_op graph exchange
Jul 12, 2026
6c7c7f4
test(pt_expt): pin repformer parallel test to the dense route
Jul 12, 2026
b08304d
feat(dpmodel,pt_expt): owned-node (n_local) energy mask in graph outp…
Jul 12, 2026
650b715
feat(pt_expt): with-comm graph .pt2 artifact for message-passing models
Jul 12, 2026
99d714e
test(cc): dpa2 graph .pt2 fixtures + universal gtest row
Jul 12, 2026
c9e91ae
feat(cc): multi-rank message-passing graph route (run_model_graph_wit…
Jul 12, 2026
fef2d53
fix(cc): fail loudly on empty rank in MP graph route; fix stale comment
Jul 12, 2026
83179f1
test(lmp): dpa2 graph LAMMPS single- and multi-rank tests
Jul 12, 2026
b0fe611
fix(cc): put nlocal/nghost comm tensors on model device for graph wit…
Jul 12, 2026
6d7e151
docs: DPA-2 graph-native inference route (pt_expt)
Jul 12, 2026
1e9c15b
test(lmp): scale dpa2 MP virial tolerance; bound empty-rank deadlock …
Jul 13, 2026
966d378
fix(pt_expt): derive graph-trace device from model params, not global…
Jul 13, 2026
9a365e3
test(pt_expt): dpa2 joins KNOWN_GRAPH_DENSE_DIVERGENT in default-fall…
Jul 13, 2026
854d654
test(pt_expt): per-model divergence envelopes in default-fallback test
Jul 13, 2026
2e49936
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 13, 2026
1e5cd13
style: fix ruff C408/B905 in repformer graph-ops test
Jul 13, 2026
bc0d70a
fix(dpmodel): dpa2 dense call must not route through divergent graph …
Jul 13, 2026
778a4bc
test(dpa2): exclude AOTInductor graph .pt2 from LeakSanitizer build
Jul 13, 2026
37863e2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 13, 2026
10a359d
test(dpa2): make LSAN graph-section skip deterministic via explicit e…
Jul 13, 2026
c633186
docs(dpa2): note graph-route attention cutoff smoothness
Jul 13, 2026
2c29ace
feat(dpmodel): fixed-phantom-count smooth attention on the dpa2 graph…
Jul 13, 2026
4b96fdb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 13, 2026
b73302b
docs(dpmodel): numpydoc sections for the phantom-compensated attentio…
Jul 14, 2026
58c23e4
docs(dpmodel,pt_expt): numpydoc sections for all remaining PR-added m…
Jul 14, 2026
34370df
fix(pt_expt): collective empty-rank preflight + extended-axis aparam …
Jul 14, 2026
314a371
test(dpa2): address review nits (pairs=None coverage, dup fixture, No…
Jul 14, 2026
9e33f1c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2026
569dfd7
test(dpa2): tighten graph-vs-dense envelope post-compensation + prove…
Jul 14, 2026
1265c66
test(lammps): DPA2 graph empty-subdomain (nlocal=0, nghost>0) MP==SP …
Jul 14, 2026
a266a3b
docs(dpa2): document pt_expt eager/training default-flip + legacy esc…
Jul 14, 2026
ffbc655
feat(pt_expt): graph-native Hessian + fix fparam graph export/train (…
Jul 14, 2026
b048e23
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2026
2acc142
fix(pt_expt): derive graph trace edge_capacity from real edge count, …
Jul 14, 2026
37ce12d
fix(pt_expt,dpmodel): graph-lower aparam is flat (N, nda) on the node…
Jul 14, 2026
cc29057
fix(pt_expt): gate the graph default-flip to energy-output models
Jul 14, 2026
e95f2ba
fix(cc): graph aparam width + ghost-only-rank synthesis; bound all MP…
Jul 14, 2026
569d40c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2026
acc973d
perf(cc,pt_expt): cache empty-rank preflight on ago==0; split n_local…
Jul 14, 2026
a2496a0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2026
994813b
fix(pt_expt): persist disable_graph_lower across checkpoint restart
Jul 14, 2026
bb4d6c2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2026
ad0a954
fix(dpmodel): signed phantom count -- smooth graph attention for arbi…
Jul 14, 2026
95b3dee
fix(pt_expt): keep the graph-lower routing bool out of traced forward…
Jul 15, 2026
44ebdda
Merge master into feat-graph-dpa2 (integrate #5758 dpa1 graph CUDA re…
Jul 15, 2026
990053c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 15, 2026
41bbd49
fix(dpmodel,pt_expt): gate nonzero-mean dpa2 off the graph default; d…
Jul 15, 2026
bc90a20
style(pt_expt): explicit device on the graph_lower_disabled buffer init
Jul 15, 2026
d33ad3b
docs: use the LAMMPS-native 'ghost' terminology for the extended region
Jul 15, 2026
8248d4d
fix(dpmodel,cc): strictly positive phantom floor; device-edge flat ap…
Jul 15, 2026
643bb15
hardening(cc): assert the flat graph-route aparam contract at the run…
Jul 15, 2026
486b146
hardening: assert three latent invariants surfaced by the merge audit
Jul 15, 2026
3006793
fix(pt_expt): fold extended_virial in the compiled translate; documen…
Jul 15, 2026
5219119
fix(dpmodel): gate the phantom denominator floor to the negative-coun…
Jul 15, 2026
1a01380
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 15, 2026
017f861
fix(pt_expt): scope the Triton exclude_types veto to the graph dispatch
Jul 16, 2026
8011829
fix(dpmodel): soft slot-occupancy phantom denominator (positive AND c…
Jul 16, 2026
7e11d63
Merge branch 'feat-graph-dpa2' of github.com:wanghan-iapcm/deepmd-kit…
Jul 16, 2026
206810e
fix(dpmodel): make _slot_occupancy export-safe on the unbacked pair axis
Jul 16, 2026
04ad574
chore(tests): resolve CodeQL findings (import style, keepalive del)
Jul 16, 2026
8a1ac1f
fix(dpmodel): keep gradients off the water-filling cumsum (inductor u…
Jul 16, 2026
9ed7caf
test(pt_expt): move graph with-comm export tests next to the dense twin
Jul 16, 2026
dfd49ef
fix(dpmodel): C1 slot-occupancy denominator (no force kink at the bel…
Jul 16, 2026
002713d
fix(dpmodel): log-space chi -- no division by a subnormal ph_e in the…
Jul 16, 2026
96604dd
Merge upstream/master into feat-graph-dpa2
Jul 16, 2026
ad6e39f
fix(dpmodel): float64 cut selection in the water-filling; correct the…
Jul 16, 2026
652ace4
Merge branch 'master' into feat-graph-dpa2
OutisLi Jul 18, 2026
48ae340
fix: address CodeRabbit round-3 findings (MPI fence placement, LSAN s…
Jul 18, 2026
13b098b
Merge branch 'feat-graph-dpa2' of github.com:wanghan-iapcm/deepmd-kit…
Jul 18, 2026
3ae87a8
refactor(dpmodel): extract DPA4 flat edge-native core from call_with_…
Jul 18, 2026
95f2375
refactor(dpmodel): descriptor-owned graph type-embedding table at the…
Jul 18, 2026
288cddf
feat(dpmodel): DPA4 graph-native forward (call_graph) and graph-lower…
Jul 18, 2026
adf4027
test(dpmodel): use message-sensitive DPA4 fixture in call_graph parit…
Jul 18, 2026
d0d8883
test(dpmodel): pin dpa4_ener fitting on the flat-N graph seam
Jul 18, 2026
502b794
feat(pt_expt): route DPA4 through the NeighborGraph lower with a pers…
Jul 18, 2026
12fe36c
fix(dpmodel): DPA4 declares no cross-rank exchange; multi-rank now fa…
Jul 18, 2026
2ac2ba5
test(dpmodel): golden pin of DPA4 dense call outputs (Task 7 Step 1.5)
Jul 18, 2026
63f6f2f
refactor(dpmodel): DPA4 dense call is a NeighborGraph adapter; one gr…
Jul 18, 2026
de0b2e9
refactor(dpmodel): delete the retired DPA4 padded dense builder; repo…
Jul 18, 2026
34fe1cc
feat(pt_expt): DPA4 graph .pt2 export (auto lower kind resolves to gr…
Jul 18, 2026
8174ee6
test(pt_expt): de-vacuate DPA4 AOTI freeze parity via jittered weights
Jul 18, 2026
5c85599
test(infer,cc,lmp): DPA4 graph .pt2 inference fixtures, C++ row, LAMM…
Jul 18, 2026
bc9e215
refactor(dpmodel): remove the DPA4 loose-edge-list API in favor of Ne…
Jul 18, 2026
9086af9
chore(pt_expt,cc): deprecate the legacy edge_vec .pt2 lower schema lo…
Jul 18, 2026
fd76e45
docs(dpa4): document graph-native inference route and correct multi-r…
Jul 18, 2026
9b22217
docs(dpa4): final-review fix batch — stale docstrings, dead param, er…
Jul 18, 2026
b6c3c37
test(pt_expt): move DPA4 export-test artifact inputs to the compile d…
Jul 19, 2026
33cf0a4
test(pt_expt): keep the DPA4 dense-branch eager reference on CPU
Jul 19, 2026
0c956cf
test(dpa4): promote jitter_zero_arrays to a shared fixture module
Jul 19, 2026
7a270d1
test(pt_expt): pin do_atomic_virial=False filtering on the DPA4 graph…
Jul 19, 2026
c15a255
refactor(pt_expt): route the canonical-graph tebd table via the descr…
Jul 19, 2026
a9bad15
refactor(dpmodel): DPA4 graph trunk threads comm_dict; dense adapter …
Jul 19, 2026
cb77639
fix(dpmodel): dense comm rejection fires before the graph build
Jul 19, 2026
489bdb0
feat(pt_expt): border_op ghost exchange for the DPA4 graph route
Jul 19, 2026
e1ba8bf
test(pt_expt): pin the DPA4 exchange spin-comm rejection
Jul 19, 2026
e99709a
feat(pt_expt): DPA4 declares graph-route cross-rank exchange; with-co…
Jul 19, 2026
bd17eba
test(pt_expt): DPA4 graph .pt2 embeds the with-comm sidecar; nlist st…
Jul 19, 2026
c3ed314
docs(test): correct test_dpa4_freeze_to_pt2 docstring to the kind-con…
Jul 19, 2026
566050d
test(lmp): DPA4 graph multi-rank MPI tests (MP==SP gate + empty-rank …
Jul 19, 2026
21bffe9
docs(dpa4): multi-rank supported on the graph .pt2 via the with-comm …
Jul 19, 2026
3d802dd
docs(plan): DPA4 native spin on the NeighborGraph route
Jul 19, 2026
d94a1cf
feat(dpmodel): thread native spin through the DPA4 graph lower chain
Jul 20, 2026
dc312c9
refactor(dpmodel): explicit supports_native_spin capability method
Jul 20, 2026
cc07c4a
feat(dpmodel): DPA4NativeSpinModel on the NeighborGraph route
Jul 20, 2026
f9bc474
fix(dpmodel): DPA4NativeSpinModel translated_output_def + builder-gua…
Jul 20, 2026
143a725
feat(pt_expt): force_mag autograd on the DPA4 graph lower
Jul 20, 2026
cb5eeb6
docs(pt_expt): correct pt joint-grad citation line number
Jul 20, 2026
d13a85c
feat(pt_expt): DPA4NativeSpinModel wrapper with graph-route force_mag
Jul 20, 2026
0316072
fix(pt_expt): restore Spin DPA4 rejection message + cover native-spin…
Jul 20, 2026
afa68a1
feat(pt_expt): graph-spin .pt2 exportable ABI (spin at index 10)
Jul 20, 2026
5f23c00
fix(pt_expt): keep the energy graph exportable spin-free (conditional…
Jul 20, 2026
78a5a01
feat(pt_expt): graph-kind .pt2 freeze for native-spin DPA4 (no with-c…
Jul 20, 2026
8a30fb1
feat(pt_expt): DeepEval graph fast path for native-spin .pt2
Jul 20, 2026
7ab9d09
test(infer): native-spin DPA4 graph .pt2 fixture generator
Jul 20, 2026
88a81e3
test(infer): build native-spin fixture from inline config+seed, drop …
Jul 20, 2026
9fb7485
feat(cc): DeepSpinPTExpt NeighborGraph route for native-spin graph .pt2
Jul 20, 2026
f731a19
test(lmp): single-rank LAMMPS deepspin on the DPA4 graph .pt2
Jul 20, 2026
3047dc9
feat(pt_expt): native-spin DPA4 training smoke + docs + fixture-regen…
Jul 20, 2026
2a3c0f9
test(dpmodel): pin the ener_spin flat-label reshape numerically
Jul 20, 2026
cf103d6
chore: stop tracking docs/superpowers working plans
Jul 20, 2026
6f039ab
docs: correct DeepSpinPTExpt guard location in comments (compute, not…
Jul 20, 2026
dcc1a5b
Merge upstream/master (dpa2 graph #5779) into feat-graph-dpa4
Jul 20, 2026
3d0e7ba
feat(dpa4): wire charge-spin FiLM + SFPG bridging onto the graph route
Jul 20, 2026
8db86c1
test(pt_expt): device-conditional tolerance for the spin-less determi…
Jul 20, 2026
5994a5c
test(lmp): source native-spin LAMMPS references from the regenerated …
Jul 20, 2026
ebfc72a
test(lmp): load build-test custom op lib in the native-spin reference…
Jul 20, 2026
9501dcb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 20, 2026
0ee0a4f
refactor(dpa4): merge _call_graph_common into _run_graph; clarify exc…
Jul 21, 2026
f0a3d2b
fix(tf2): unpack the 7-tuple _input_type_cast (spin slot) at all tf2 …
Jul 21, 2026
8ae3e5d
test(dpa4): make the charge_spin routing spy version-stable
Jul 21, 2026
4dea3f2
test(dpa4): fix CodeQL py/modification-of-default-value in jitter_zer…
Jul 21, 2026
144f245
test(dpa4): make jitter_zero_arrays pure to clear CodeQL py/modificat…
Jul 21, 2026
26593a1
chore(dpa4): clear CodeQL notes/warning (cyclic-import, unnecessary-d…
Jul 21, 2026
84f0bf8
test(tf2): update FakeDPModel._input_type_cast mock to the 7-tuple si…
Jul 21, 2026
d445425
docs(dpa4): close an unbalanced inline literal in translated_output_d…
Jul 22, 2026
2027976
refactor(dpmodel): declare supports_native_spin/supports_charge_spin …
Jul 23, 2026
91c7684
docs(dpmodel): keep BaseDescriptor spin-capability docstrings descrip…
Jul 23, 2026
e8d1b8a
refactor(dpmodel,pt_expt): declare the graph-lower capability cluster…
Jul 23, 2026
4d1138d
refactor(dpmodel,pt_expt,jax): declare has_spin on the base model; dr…
Jul 23, 2026
3c108c4
fix(dpa4): restore pt training-time random_gamma semantics on the sha…
Jul 23, 2026
73a851f
fix(dpmodel,pt_expt): normalize use_spin forms and forward allow_miss…
Jul 23, 2026
efb6fb9
refactor(pd): drop the has_spin getattr dances for direct base-model …
Jul 23, 2026
24abf3c
refactor(dpmodel): make_native_spin_model class factory + registered …
Jul 23, 2026
71239f9
refactor(pt_expt): NativeSpinEnergyModel via make_native_spin_model; …
Jul 23, 2026
b037154
test(pt_expt): pin the public-BaseModel native-spin round trip
Jul 23, 2026
91d4837
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 23, 2026
c4ddea3
feat(dpmodel): native spin combined with charge-spin FiLM (review 363…
Jul 23, 2026
57a008e
feat(pt_expt): combined native spin + charge-spin FiLM eager path (re…
Jul 23, 2026
9cf9f36
feat(pt_expt): charge_spin slot in the graph-spin .pt2 ABI (review 36…
Jul 23, 2026
d1dac26
feat(infer,cc): feed the graph-spin charge_spin slot in DeepEval and …
Jul 23, 2026
349ad3b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 23, 2026
0c388be
feat(dpmodel): backend-agnostic InterPotential (analytical ZBL bridgi…
Jul 23, 2026
3251411
feat(dpmodel): inject the ZBL bridging term at the atomic layer (revi…
Jul 24, 2026
412cc21
feat(pt_expt): ZBL bridging eager path + ownership on DPAtomicModel (…
Jul 24, 2026
69a2697
feat(pt_expt): ZBL bridging export/training e2e + argcheck (review 36…
Jul 24, 2026
f51ca5e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 24, 2026
6a2e9de
refactor(dpmodel,pt_expt): ZBL bridging as atomic-model COMPOSITION (…
Jul 24, 2026
eccc7c3
refactor(dpmodel,pt_expt): address review batch on the bridging compo…
Jul 24, 2026
e8ecfd4
refactor(dpmodel,pt_expt): DPA4EnergyModel owns the dpa4-family wire …
Jul 24, 2026
1fcdeeb
test(pt_expt): repoint the pt-checkpoint interop tests at DPA4EnergyM…
Jul 24, 2026
e23f5f7
test(pt_expt): training fakes implement the pinned has_spin interface…
Jul 24, 2026
35dd228
fix(pt_expt): resolve native-spin freeze to the graph lower at the pu…
Jul 24, 2026
2ff9f25
fix(pt_expt): synthesize the real mask_mag in graph-native-spin DeepE…
Jul 24, 2026
62a2bff
test(pt_expt): exercise the native-spin capability gate with a standa…
Jul 24, 2026
27678e6
fix(dpmodel,pt_expt): narrow the native-spin TypeError translation (r…
Jul 24, 2026
0b31256
Merge branch 'master' of https://github.com/deepmodeling/deepmd-kit i…
Jul 24, 2026
ea00029
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 24, 2026
bfa0c4c
test(pt_expt): make the tf32 warn-once test immune to global logging …
Jul 24, 2026
0965e29
refactor(pt_expt): the native-spin model owns mask_mag; DeepEval read…
Jul 24, 2026
06ba579
refactor(native-spin): dedup pt_expt forward against dpmodel's call
Jul 24, 2026
3a13be0
refactor(native-spin): one translation owner for eager and graph paths
Jul 24, 2026
9f2e811
fix(dpmodel): linear model is graph-capable iff ALL children are
Jul 24, 2026
acd68f8
fix(ci): keep the linear wire type shared, count tf32 warns at the so…
Jul 25, 2026
ecfb7a8
fix(api_cc): apply model-level pair exclusion when building the spin …
Jul 25, 2026
fd6fa77
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2026
e48b6e2
fix: refresh the ZBL lookup on change_type_map; allow native spin + b…
Jul 25, 2026
2f4e63d
refactor: the atomic model answers supports_native_spin, not a descri…
Jul 25, 2026
cadd737
refactor(dpmodel): query supports_native_spin through the interface
Jul 25, 2026
804cc57
feat(pt_expt): native spin supports multi-rank on the graph lower
Jul 25, 2026
5f837d5
fix: composition forwards charge_spin capabilities; real multi-rank s…
Jul 25, 2026
648b3db
test(zbl): first C++ coverage for DPA4 + analytical ZBL bridging
Jul 25, 2026
459e0ff
fix(test): include DeepPotPTExpt.h so the ZBL C++ suite actually runs
Jul 25, 2026
2824e14
test(zbl): magnitude-scaled fp32 bound for the ZBL C++ comparison
Jul 25, 2026
f7d3067
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2026
0123bcb
fix(api_cc): extended-region output remap for multi-rank graph spin
Jul 25, 2026
1d560a1
fix(api_cc): keep graph edges extended for multi-rank native-spin
Jul 25, 2026
18b7459
refactor(pt_expt): drop the duplicated graph-eligibility guard
Jul 25, 2026
1e80e0b
fix(dpmodel): draw the DPA4 random-gamma roll with the backend's RNG
Jul 25, 2026
0a77df3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2026
749fd49
fix(dpa4): pair exclusion must reach the ZBL composition
Jul 25, 2026
881e208
fix(pt_expt): freeze a graph-capable model through the graph lower
Jul 25, 2026
ee1026e
feat(api): runtime charge_spin for the DeepSpin inference path
Jul 25, 2026
c3f61a7
feat(api): charge_spin through DeepSpinModelDevi
Jul 25, 2026
fb1f8d6
test(spin): functional coverage for runtime charge_spin
Jul 25, 2026
5f67515
fix(api_cc): give DeepSpinPTExpt the safety machinery DeepPot has
Jul 25, 2026
7537e6a
test(dpa4): cover native-spin+ZBL below Python, and ZBL under LAMMPS
Jul 25, 2026
d7287ef
fix(dpa4): atom exclusion and stat capabilities must reach the compos…
Jul 26, 2026
963b284
style: trim the exclusion and capability comments
Jul 26, 2026
206102d
fix(dpmodel): reject an intensive/extensive composition at construction
Jul 26, 2026
0053e27
test: complete the linear-model test double
Jul 26, 2026
f937b89
fix(dpmodel): a composition default requires agreement among active c…
Jul 26, 2026
c40f018
fix(pt_expt): warn when a requested lower_kind is overridden
Jul 26, 2026
126eec8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 26, 2026
436c46e
docs(cli): --lower-kind no longer advertises a dense default
Jul 26, 2026
c20b4ca
test: drop the dual-import pattern CodeQL flagged
Jul 26, 2026
89a3f65
fix(dpmodel): composition consumers must agree on fparam/aparam dimen…
Jul 26, 2026
37f1ce0
refactor(dpmodel): restore the PT-aligned method order in dpa4
Jul 26, 2026
aa10829
docs(dpa4): correct the freeze and multi-rank capability matrix
Jul 26, 2026
b4afa3c
test(zbl): restore through the pt_expt class so the roundtrip runs on…
Jul 26, 2026
5385950
test(spin): the native-spin graph .pt2 must carry the with-comm artifact
Jul 26, 2026
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
42 changes: 42 additions & 0 deletions deepmd/dpmodel/array_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,48 @@ def xp_setitem_at(x: Array, mask: Array, values: Array) -> Array:
return x


def xp_uniform(like: Array, size: int, low: float = 0.0, high: float = 1.0) -> Array:
"""Draw ``size`` uniform samples in ``[low, high)`` on ``like``'s device.

Each backend uses its own generator: torch draws with ``torch.rand`` (as
pt does, so ``setup_seed`` replays it, with no host copy -- and a host
draw would freeze to a constant under tracing); other backends use
:mod:`deepmd.utils.random`, which ``setup_seed`` also seeds. Draws are
therefore not comparable across backends -- use only for a per-forward
random stream, never where a parity test looks.

Parameters
----------
like : Array
Reference array supplying backend, dtype and device.
size : int
Number of samples to draw.
low : float
Lower bound of the interval.
high : float
Upper bound of the interval, exclusive.

Returns
-------
Array
Samples of shape ``(size,)`` matching ``like``.
"""
if array_api_compat.is_torch_array(like):
import torch

return (
torch.rand(size, dtype=like.dtype, device=like.device) * (high - low) + low
)
from deepmd.utils import random as dp_random

xp = array_api_compat.array_namespace(like)
drawn = np.asarray(dp_random.random(size)) * (high - low) + low
return xp.astype(
xp_asarray_nodetach(xp, drawn, device=array_api_compat.device(like)),
like.dtype,
)


def xp_bincount(x: Array, weights: Array | None = None, minlength: int = 0) -> Array:
"""Counts the number of occurrences of each value in x."""
xp = array_api_compat.array_namespace(x)
Expand Down
35 changes: 33 additions & 2 deletions deepmd/dpmodel/atomic_model/base_atomic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,29 @@ def has_default_fparam(self) -> bool:
"""Check if the model has default frame parameters."""
return False

def uses_graph_lower(self) -> bool:
"""Returns whether this atomic model supports the NeighborGraph lower.

Generic capability (concrete default ``False``): the model layer
consults it for graph-route eligibility without assuming anything
about the atomic model's internal architecture. Implementations
answer from their own structure (e.g. a descriptor+fitting model
delegates to its descriptor; a composition supports it iff ALL its
children do).
"""
return False

def supports_native_spin(self) -> bool:
"""Returns whether this atomic model consumes a per-atom spin input.

Generic capability (concrete default ``False``), the twin of
:meth:`uses_graph_lower`: the model layer asks the atomic model
directly instead of reaching into it for a descriptor, so the answer
stays correct for architectures with no descriptor at all (analytical
terms) and for compositions.
"""
return False

def get_default_fparam(self) -> list[float] | None:
"""Get the default frame parameters."""
return None
Expand Down Expand Up @@ -381,6 +404,7 @@ def forward_common_atomic_graph(
fparam: Array | None = None,
aparam: Array | None = None,
charge_spin: Array | None = None,
spin: Array | None = None,
comm_dict: dict | None = None,
) -> dict:
"""Graph analogue of :meth:`forward_common_atomic` on the flat node axis.
Expand All @@ -405,8 +429,14 @@ def forward_common_atomic_graph(
aparam
atomic parameter. N x nda
charge_spin
charge/spin conditioning. Unused by the dpa1 graph path; accepted so
the interface stays stable for charge/spin-conditioned descriptors.
frame-level charge/spin conditioning, forwarded unchanged to
:meth:`forward_atomic_graph`, which only passes it on to the
descriptor's ``call_graph`` for descriptors that declare
``supports_charge_spin`` (currently DPA4 only).
spin
flat (N, 3) per-node spin, forwarded unchanged to
:meth:`forward_atomic_graph` (and, from there, the descriptor's
``call_graph``); None for spin-less models.
comm_dict
MPI communication metadata forwarded to :meth:`forward_atomic_graph`
(and, from there, the descriptor's ``call_graph``). ``None`` for
Expand All @@ -426,6 +456,7 @@ def forward_common_atomic_graph(
fparam=fparam,
aparam=aparam,
charge_spin=charge_spin,
spin=spin,
comm_dict=comm_dict,
)
return self._finalize_atomic_ret(ret_dict, output_mask, atype)
Expand Down
54 changes: 50 additions & 4 deletions deepmd/dpmodel/atomic_model/dp_atomic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,22 @@ def __init__(
self.add_chg_spin_ebd: bool = getattr(
self.descriptor, "add_chg_spin_ebd", False
)
# Structural capability: only descriptors with a native spin
# conditioning mechanism (currently DPA4) accept a ``spin`` kwarg on
# ``call_graph`` at all -- unlike ``charge_spin``, which every
# descriptor's dense ``call()`` accepts (and ignores) for interface
# stability, the graph-native ``call_graph`` signature is
# per-descriptor, so ``forward_atomic_graph`` must not pass the
# keyword to a descriptor whose ``call_graph`` does not declare it
# (that would be a ``TypeError``, not a no-op). Queried via the
# ``supports_native_spin`` capability method declared on
# ``BaseDescriptor`` (concrete default ``False``; DPA4 overrides).
self._supports_native_spin: bool = self.descriptor.supports_native_spin()
# Same capability method as ``supports_native_spin`` above, for the
# frame-level ``charge_spin`` FiLM kwarg: only DPA4's ``call_graph``
# declares it; other descriptors' ``call_graph`` would ``TypeError``
# on an unconditional ``charge_spin=`` kwarg.
self.supports_charge_spin: bool = self.descriptor.supports_charge_spin()
super().init_out_stat()

def has_chg_spin_ebd(self) -> bool:
Expand All @@ -147,6 +163,14 @@ def get_default_chg_spin(self) -> list[float] | None:
return self.descriptor.get_default_chg_spin()
return None

def uses_graph_lower(self) -> bool:
"""Delegates to this model's own descriptor."""
return bool(self.descriptor.uses_graph_lower())

def supports_native_spin(self) -> bool:
"""Delegates to this model's own descriptor (cached at construction)."""
return self._supports_native_spin

def fitting_output_def(self) -> FittingOutputDef:
"""Get the output def of the fitting net."""
return self.fitting_net.output_def()
Expand Down Expand Up @@ -301,6 +325,7 @@ def forward_atomic_graph(
fparam: Array | None = None,
aparam: Array | None = None,
charge_spin: Array | None = None,
spin: Array | None = None,
comm_dict: dict | None = None,
) -> dict[str, Array]:
"""Graph analogue of :meth:`forward_atomic` on the flat node axis.
Expand All @@ -321,8 +346,14 @@ def forward_atomic_graph(
aparam
atomic parameter. N x nda
charge_spin
charge/spin conditioning. Unused by the dpa1 graph path; accepted so
the interface stays stable for charge/spin-conditioned descriptors.
frame-level charge/spin conditioning, forwarded to the
descriptor's ``call_graph`` only when
``self.supports_charge_spin`` (currently DPA4 only); ignored (not
forwarded, never a ``TypeError``) for descriptors without that
capability, keeping the interface stable for all of them.
spin
flat (N, 3) per-node spin, forwarded to the descriptor's
``call_graph``; None for spin-less models.
comm_dict
MPI communication metadata forwarded to the descriptor's
``call_graph`` (the message-passing part). ``None`` for
Expand All @@ -342,9 +373,24 @@ def forward_atomic_graph(
)

xp = array_api_compat.array_namespace(graph.edge_vec)
type_embedding = self.descriptor.type_embedding.call()
# Descriptor-owned: dpa1/dpa2 hand out their full tebd table; DPA4
# embeds types internally from ``atype`` and returns None.
type_embedding = self.descriptor.graph_type_embedding_table()
# Only forward the ``spin``/``charge_spin`` keyword to descriptors
# whose ``call_graph`` declares it. Queried through the public
# capability -- an override must reach THIS call site too, so the
# cached field stays behind the method.
spin_kwargs = {"spin": spin} if self.supports_native_spin() else {}
charge_spin_kwargs = (
{"charge_spin": charge_spin} if self.supports_charge_spin else {}
)
gg, rot_mat = self.descriptor.call_graph(
graph, atype, type_embedding=type_embedding, comm_dict=comm_dict
graph,
atype,
type_embedding=type_embedding,
comm_dict=comm_dict,
**spin_kwargs,
**charge_spin_kwargs,
)
fparam_node = None
if fparam is not None:
Expand Down
Loading