Skip to content

feat(pt_expt): share learned descriptors across bridged energy heads - #6152

Open
bingdongni wants to merge 2 commits into
deepmodeling:masterfrom
bingdongni:feat/pt-expt-share-bridged-descriptor
Open

bingdongni wants to merge 2 commits into
deepmodeling:masterfrom
bingdongni:feat/pt-expt-share-bridged-descriptor

Conversation

@bingdongni

@bingdongni bingdongni commented Nov 23, 2026 •

Copy link
Copy Markdown

A DPA4C bulk head and a short-range ZBL head can now use the same shared_dict descriptor in pt_expt. The multi-task wrapper asks each head for its descriptor. A linear composition used to look for it on the parent atomic model, which has none.

Resolve the descriptor on the unique learned child. This works in either child order and keeps the analytical potential and fitting heads local to their respective tasks. Compositions with multiple learned children have no unambiguous descriptor. This addresses the DPA4C part of #6148. DPA4 still needs its own weight-sharing implementation.

The tests cover both task orders and two bridged heads. They check parameter identity, per-head energy and forces against independently parameterized models, and accumulated gradients against the sum of the two reference gradients. After the upstream change to the contact clamp, the Linux regression suites passed 37 tests (4 skipped). With the contact statistics fixed in evaluation mode, central differences at 0.4, 0.65 and 1.1 Å agreed with eager PyTorch on an RTX 4060 Laptop GPU to within 1.5e-7 for a Cartesian force component and 4.3e-10 for a directional weight derivative across both heads. Linux regression and finite-difference checks

Codex assisted with implementation, testing, and this write-up.

Summary by CodeRabbit

  • New Features
    • Linear bridged models can provide their learned descriptor when exactly one is available.
    • Multitask models support shared descriptors across none and zbl bridging combinations, with consistent energy, force, and gradient results.
  • Bug Fixes
    • Linear bridged models with multiple learned descriptors now report an error rather than selecting an ambiguous descriptor.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

LinearEnergyModel now returns the descriptor of its unique DPAtomicModel child and raises AttributeError when the child is not unique. Tests cover descriptor sharing across bridged heads, compare energies, forces, and shared-parameter gradients with independent references, and check descriptor selection across child orderings.

Changes: Linear Bridging Descriptor

Layer / File(s) Summary
Select the unique learned descriptor
deepmd/pt_expt/model/dp_linear_model.py
Adds get_descriptor(). It returns the descriptor of the sole DPAtomicModel child in atomic_model.models, or raises AttributeError when the child is not unique.
Validate descriptor sharing across bridged heads
source/tests/pt_expt/model/test_dpa4c_zbl_bridging.py
Adds tests for three none/zbl bridging combinations. The tests compare head energies and forces with independent references and check shared-parameter gradients. They also test descriptor selection across child orderings and the non-unique case.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Possibly related issues

  • deepmodeling/deepmd-kit issue 6148: The changes address the unique-descriptor lookup failure for DPA4C bridging. The issue also notes that DPA4 descriptor sharing remains unimplemented.

Suggested reviewers: outisli, wanghan-iapcm

Merge Risk: Minimal · up to 21a92

This adds descriptor lookup for linear-composed energy models, so a DPA4C head and a ZBL head can share a descriptor. No concrete merge-blocking risk was identified in the supplied change.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: sharing learned descriptors across bridged energy heads in pt_expt. The raw summary shows a new get_descriptor() method that selects the unique learned descriptor chil…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: sharing learned descriptors across bridged energy heads in pt_expt. The raw summary shows a new get_descriptor() method that selects the unique learned descriptor child of a linear model, and tests for shared descriptor identity across none/zbl bridging combinations. The title is specific and matches the changeset. It uses a conventional type(scope) prefix and is 68 characters long.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 84cc9fe9-ef08-4dd3-be17-8e4e056510b9
Commits

Reviewing files that changed from the base of the PR and between 97a2f31 and 21a9286.

Files selected for processing: 2

  • deepmd/pt_expt/model/dp_linear_model.py
  • source/tests/pt_expt/model/test_dpa4c_zbl_bridging.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant