-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore(pt):rm old pt implementation #4223
Conversation
for more information, see https://pre-commit.ci
📝 WalkthroughWalkthroughThe changes in this pull request involve significant modifications to several classes and files within the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🧹 Outside diff range and nitpick comments (3)
source/tests/pt/model/test_embedding_net.py (1)
Line range hint
178-185
: Consider improving documentation and clarifying framework usageWhile the changes improve the code, consider the following suggestions:
Add a comment explaining the structure of parameter names and why this specific regex pattern is used. This would help future maintainers understand the code more easily.
The test file uses both TensorFlow and PyTorch. While this might be intentional for comparison purposes, it would be helpful to add a comment explaining why both frameworks are necessary for this test.
These additions would further enhance the maintainability and clarity of the code.
deepmd/pt/model/descriptor/repformers.py (1)
247-282
: LGTM! Consider updating the class docstring.The removal of the
old_impl
parameter and related logic simplifies the code and aligns with the PR objective of removing the old implementation. This change improves code maintainability by removing deprecated options.Consider updating the class docstring to remove any mentions of the
old_impl
parameter or the option to use an older implementation, ensuring the documentation accurately reflects the current implementation.deepmd/pt/model/task/fitting.py (1)
477-490
: Simplify complex conditional statements to improve readabilityThe nested condition with multiple negations can be difficult to read and understand:
if not ( len(self.remove_vaccum_contribution) > type_i and not self.remove_vaccum_contribution[type_i] ):Refactor the condition to eliminate double negatives:
if (len(self.remove_vaccum_contribution) <= type_i) or self.remove_vaccum_contribution[type_i]:This version is more straightforward and improves code clarity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (29)
- deepmd/dpmodel/fitting/dipole_fitting.py (0 hunks)
- deepmd/dpmodel/fitting/polarizability_fitting.py (0 hunks)
- deepmd/pt/model/backbone/init.py (0 hunks)
- deepmd/pt/model/backbone/backbone.py (0 hunks)
- deepmd/pt/model/backbone/evoformer2b.py (0 hunks)
- deepmd/pt/model/descriptor/init.py (0 hunks)
- deepmd/pt/model/descriptor/dpa1.py (0 hunks)
- deepmd/pt/model/descriptor/dpa2.py (0 hunks)
- deepmd/pt/model/descriptor/gaussian_lcc.py (0 hunks)
- deepmd/pt/model/descriptor/repformer_layer_old_impl.py (0 hunks)
- deepmd/pt/model/descriptor/repformers.py (1 hunks)
- deepmd/pt/model/descriptor/se_a.py (2 hunks)
- deepmd/pt/model/descriptor/se_atten.py (3 hunks)
- deepmd/pt/model/descriptor/se_atten_v2.py (0 hunks)
- deepmd/pt/model/descriptor/se_r.py (0 hunks)
- deepmd/pt/model/network/network.py (0 hunks)
- deepmd/pt/model/task/init.py (0 hunks)
- deepmd/pt/model/task/atten_lcc.py (0 hunks)
- deepmd/pt/model/task/dipole.py (0 hunks)
- deepmd/pt/model/task/fitting.py (2 hunks)
- deepmd/pt/model/task/polarizability.py (0 hunks)
- source/tests/pt/model/test_descriptor_hybrid.py (0 hunks)
- source/tests/pt/model/test_descriptor_se_r.py (0 hunks)
- source/tests/pt/model/test_dpa1.py (0 hunks)
- source/tests/pt/model/test_dpa2.py (0 hunks)
- source/tests/pt/model/test_embedding_net.py (1 hunks)
- source/tests/pt/model/test_ener_fitting.py (0 hunks)
- source/tests/pt/model/test_se_atten_v2.py (0 hunks)
- source/tests/pt/model/test_se_e2_a.py (0 hunks)
💤 Files with no reviewable changes (24)
- deepmd/dpmodel/fitting/dipole_fitting.py
- deepmd/dpmodel/fitting/polarizability_fitting.py
- deepmd/pt/model/backbone/init.py
- deepmd/pt/model/backbone/backbone.py
- deepmd/pt/model/backbone/evoformer2b.py
- deepmd/pt/model/descriptor/init.py
- deepmd/pt/model/descriptor/dpa1.py
- deepmd/pt/model/descriptor/dpa2.py
- deepmd/pt/model/descriptor/gaussian_lcc.py
- deepmd/pt/model/descriptor/repformer_layer_old_impl.py
- deepmd/pt/model/descriptor/se_atten_v2.py
- deepmd/pt/model/descriptor/se_r.py
- deepmd/pt/model/network/network.py
- deepmd/pt/model/task/init.py
- deepmd/pt/model/task/atten_lcc.py
- deepmd/pt/model/task/dipole.py
- deepmd/pt/model/task/polarizability.py
- source/tests/pt/model/test_descriptor_hybrid.py
- source/tests/pt/model/test_descriptor_se_r.py
- source/tests/pt/model/test_dpa1.py
- source/tests/pt/model/test_dpa2.py
- source/tests/pt/model/test_ener_fitting.py
- source/tests/pt/model/test_se_atten_v2.py
- source/tests/pt/model/test_se_e2_a.py
🧰 Additional context used
🔇 Additional comments (7)
source/tests/pt/model/test_embedding_net.py (2)
Line range hint
178-185
: Improved consistency in parameter name extractionThe changes in this section have simplified the code by removing the
old_impl
parameter and using a consistent regex pattern for parameter name extraction. This aligns well with the PR objective of removing old implementations and improves code clarity.The new regex pattern
r"(\d)\.layers\.(\d)\.([a-z]+)"
appears to correctly capture the structure of parameter names in the current implementation.
Line range hint
1-224
: Changes align with PR objectives and maintain test integrityThe modifications in this file are focused and minimal, primarily involving the removal of the
old_impl
parameter and simplification of the parameter name extraction logic. These changes align well with the PR objective of removing old implementations.Key points:
- The core functionality of the test remains intact, continuing to compare TensorFlow and PyTorch implementations.
- The simplification improves code clarity and maintainability.
- The minimal nature of the changes reduces the risk of introducing new bugs.
The test file continues to serve its purpose of ensuring consistency between implementations while becoming more streamlined.
deepmd/pt/model/descriptor/repformers.py (1)
Line range hint
1-24
: Summary: Removal of old implementation improves code clarityThe changes in this file successfully remove the
old_impl
parameter and related logic from theDescrptBlockRepformers
class. This aligns with the PR objective of removing the old PT implementation and results in cleaner, more maintainable code.Key improvements:
- Simplified
__init__
method signature- Removed conditional logic for different implementations
- Consistent use of the current implementation across the class
These changes should make the code easier to understand and maintain going forward.
Also applies to: 247-282
deepmd/pt/model/task/fitting.py (1)
471-475
: Verify correct indexing and application of atom biases in mixed typesIn the mixed types scenario, you are accessing
self.bias_atom_e[atype]
and adding it to theatom_property
. Ensure thatatype
correctly indexes intoself.bias_atom_e
without causing index out-of-bounds errors.atom_property = self.filter_layers.networks[0](xx) + self.bias_atom_e[atype]Run the following script to confirm that all values in
atype
are within the valid range:This script searches for instances where
self.bias_atom_e[atype]
is used and outputs lines involvingatype
. Verify thatatype
does not contain indices outside the range[0, self.ntypes - 1]
.deepmd/pt/model/descriptor/se_a.py (1)
612-654
: Avoided Performance Degradation by Skipping Mask ApplicationThe decision to set
ti_mask = None
whenself.type_one_side
isTrue
avoids applying a mask that could degrade performance, as mentioned in the comments. This logic enhances the efficiency of the computation.deepmd/pt/model/descriptor/se_atten.py (2)
192-207
: Initialization ofself.dpa1_attention
Simplified and CorrectThe removal of the
old_impl
conditional logic has streamlined the initialization ofself.dpa1_attention
. The parameters passed toNeighborGatedAttention
are appropriate and align with its constructor.
225-237
: Verify the Correct Initialization offilter_layers
The
filter_layers
are initialized and assigned correctly. However, please ensure that theNetworkCollection
andEmbeddingNet
are properly configured to handle the new initialization without theold_impl
logic.To confirm the correct setup, you can review the configuration of
filter_layers
:
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## devel #4223 +/- ##
==========================================
+ Coverage 83.52% 84.55% +1.02%
==========================================
Files 542 536 -6
Lines 52544 51235 -1309
Branches 3043 3047 +4
==========================================
- Hits 43888 43320 -568
+ Misses 7709 6967 -742
- Partials 947 948 +1 ☔ View full report in Codecov by Sentry. |
Fix #3913.
Summary by CodeRabbit
Release Notes
New Features
exclude_types
parameter inDipoleFittingNet
andPolarFittingNet
constructors for improved flexibility.SimpleLinear
class to enhance network functionality.Bug Fixes
old_impl
parameter across various classes, streamlining interfaces and ensuring consistent behavior.Documentation
old_impl
, focusing on new implementations.Chores