feat(dpa4): preserve cutoff smoothness in edge feature branches#5772
feat(dpa4): preserve cutoff smoothness in edge feature branches#5772OutisLi wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an edge_norm switch to the DPA4/SeZM descriptor to disable normalization on feature branches whose inputs vanish at the cutoff, preserving the intended cutoff envelope (and avoiding eps-floor amplification artifacts) while keeping the default behavior unchanged (edge_norm=True). The change is implemented in both PyTorch and DPModel codepaths, wired through config/serialization and input validation, and covered by new regression and parity tests; the water DPA4 example is updated to enable the cutoff-smooth mode.
Changes:
- Add
edge_normdescriptor option and propagate it to radial hidden RMSNorm, env-seed FiLM norms, cross-focus competition norm, and post-SO(2) variance floor selection (PyTorch + DPModel). - Extend serialization/config plumbing for the new switches (
edge_norm,radial_norm,focus_norm,so2_post_norm_eps) and exposeedge_normin argument validation. - Add tests for cutoff smoothness regression, serialization round-trips, and PT/DPModel parity across both normalization modes.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
source/tests/pt/model/test_dpa4_dpmodel_parity.py |
Extends parity coverage for eps handling and adds edge_norm parity assertions. |
source/tests/pt/model/test_descriptor_sezm.py |
Adds cutoff-smoothness regression and structure/serialization checks for edge_norm/radial_norm gating. |
examples/water/dpa4/input.json |
Enables edge_norm: false in the DPA4 water example. |
deepmd/utils/argcheck.py |
Adds edge_norm to the dpa4/SeZM descriptor argument schema and documentation. |
deepmd/pt/model/descriptor/sezm.py |
Adds edge_norm descriptor config, propagates it to submodules, and serializes it. |
deepmd/pt/model/descriptor/sezm_nn/so2.py |
Adds focus_norm option to gate competition-input normalization and serializes it. |
deepmd/pt/model/descriptor/sezm_nn/radial.py |
Adds radial_norm option to drop hidden RMSNorm in RadialMLP and serializes it. |
deepmd/pt/model/descriptor/sezm_nn/block.py |
Adds so2_post_norm_eps and focus_norm plumbing into interaction blocks and serialization. |
deepmd/dpmodel/descriptor/dpa4.py |
DPModel-side edge_norm propagation: FiLM norm gating, radial_norm, focus_norm, post-SO(2) eps selection, and serialization/variable handling. |
deepmd/dpmodel/descriptor/dpa4_nn/so2.py |
DPModel SO2Convolution gains focus_norm gating + serialization updates. |
deepmd/dpmodel/descriptor/dpa4_nn/radial.py |
DPModel RadialMLP gains radial_norm gating + serialization updates. |
deepmd/dpmodel/descriptor/dpa4_nn/block.py |
DPModel interaction blocks gain focus_norm and so2_post_norm_eps plumbing + serialization updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughDPA4 and SeZM now expose an ChangesEdge normalization controls
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Descriptor
participant RadialMLP
participant InteractionBlock
participant SO2Convolution
Descriptor->>RadialMLP: configure radial_norm from edge_norm
Descriptor->>InteractionBlock: configure focus_norm and post-norm epsilon
InteractionBlock->>SO2Convolution: configure focus_norm
Descriptor->>Descriptor: conditionally normalize FiLM logits
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5772 +/- ##
==========================================
- Coverage 79.70% 79.56% -0.14%
==========================================
Files 1020 1020
Lines 116359 116386 +27
Branches 4305 4303 -2
==========================================
- Hits 92742 92602 -140
- Misses 22076 22230 +154
- Partials 1541 1554 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What
edge_normdescriptor option to control normalization on feature branches that vanish at the cutoff, with matching PyTorch and DPModel implementations.Why
DPA4 radial features carry a C3 cutoff envelope and should decay to zero at
rcut. Per-edge RMSNorm divides out that envelope until the feature variance reaches the norm epsilon floor, which can introduce a narrow, non-physical curvature and force feature just inside the cutoff. The same small-signal amplification applies to other normalization sites driven by cutoff-vanishing inputs.The new mode preserves the cutoff envelope: FiLM modulation returns smoothly to identity, cross-focus weights approach uniform, and post-SO(2) residual messages remain linear near zero.
Impact
edge_norm=Trueremains the default, so existing configurations retain their current behavior.edge_norm=Falseopts into the recommended cutoff-smooth behavior.Checks
Summary by CodeRabbit
edge_normfor DPA4 and SeZM descriptors to control edge-dependent normalization behavior.radial_normfor radial embeddings andfocus_normfor SO(2) focus competition normalization.so2_post_norm_epsto tune SO(2 post-normalization stability.edge_normexplicitly.