-
Notifications
You must be signed in to change notification settings - Fork 516
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
feat: Support stripped type embedding in DPA1 of PT/DP #3712
Conversation
WalkthroughWalkthroughThe recent changes focus on updating the Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (4)
Files skipped from review as they are similar to previous changes (2)
Additional comments not posted (7)
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
stripped_type_embedding
in PT/DPThere 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: 10
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Duo <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #3712 +/- ##
==========================================
+ Coverage 82.19% 82.23% +0.03%
==========================================
Files 513 513
Lines 47642 47745 +103
Branches 2979 2979
==========================================
+ Hits 39159 39261 +102
- Misses 7572 7573 +1
Partials 911 911 ☔ View full report in Codecov by Sentry. |
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
Signed-off-by: Duo <[email protected]>
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: 7
Out of diff range and nitpick comments (4)
doc/model/train-se-atten.md (3)
Line range hint
91-101
: Replace hard tabs with spaces for consistency in JSON formatting.- "descriptor" :{ - "type": "se_atten", - "rcut_smth": 0.50, - "rcut": 6.00, - "sel": 120, - "neuron": [25, 50, 100], - "axis_neuron": 16, - "resnet_dt": false, - "attn": 128, - "attn_layer": 2, - "attn_mask": false, - "attn_dotr": true, - "seed": 1 + "descriptor" :{ + "type": "se_atten", + "rcut_smth": 0.50, + "rcut": 6.00, + "sel": 120, + "neuron": [25, 50, 100], + "axis_neuron": 16, + "resnet_dt": false, + "attn": 128, + "attn_layer": 2, + "attn_mask": false, + "attn_dotr": true, + "seed": 1
Line range hint
124-136
: Replace hard tabs with spaces for consistency in JSON formatting.- "descriptor" :{ - "type": "dpa1", - "rcut_smth": 0.50, - "rcut": 6.00, - "sel": 120, - "neuron": [25, 50, 100], - "tebd_dim": 8, - "axis_neuron": 16, - "attn": 128, - "attn_layer": 2, - "attn_mask": false, - "attn_dotr": true, + "descriptor" :{ + "type": "dpa1", + "rcut_smth": 0.50, + "rcut": 6.00, + "sel": 120, + "neuron": [25, 50, 100], + "tebd_dim": 8, + "axis_neuron": 16, + "attn": 128, + "attn_layer": 2, + "attn_mask": false, + "attn_dotr": true,
Line range hint
224-224
: Correct the spelling of "placeholder".- Atom type indexes (place holder) + Atom type indexes (placeholder)deepmd/pt/model/descriptor/dpa1.py (1)
Line range hint
371-416
: Ensure serialization handles all configurations.The serialization method currently handles the 'strip' mode specifically. Ensure that all configurations, especially new or modified ones, are correctly serialized and deserialized to maintain state consistency across sessions.
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: 3
Out of diff range and nitpick comments (3)
deepmd/dpmodel/descriptor/dpa1.py (1)
297-301
: Clarify the logic for settingembd_input_dim
based ontebd_input_mode
. The current implementation might be confusing.Consider adding comments or refactoring for clarity.
deepmd/utils/argcheck.py (2)
Line range hint
427-509
: The documentation fordoc_attn_layer
in thedescrpt_se_atten_common_args
function is misleading. It suggests that model compression is only enabled whenattn_layer
is 0 andtebd_input_mode
is 'strip', which might not be accurate or might require further clarification to ensure it aligns with the actual functionality.
507-509
: The parameterstripped_type_embedding
is marked as deprecated. It's good practice to provide a timeline or conditions for its removal to avoid maintaining outdated code. Consider adding a deprecation warning in the code if it's still being used.
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
Out of diff range and nitpick comments (3)
deepmd/dpmodel/descriptor/dpa1.py (1)
[!TIP]
Codebase VerificationThe review comment's concern about ensuring the serialization format's compatibility with existing systems, particularly with the handling of
tebd_input_mode
, is justified based on the findings from the executed script. The script output reveals several instances across the codebase where serialization is explicitly unsupported or restricted whentebd_input_mode
is set to "strip". This indicates a potential compatibility issue that needs to be addressed to ensure robust serialization and deserialization processes.Action Points:
- The development team should review the restrictions and unsupported scenarios related to
tebd_input_mode
being "strip" to ensure broader compatibility or provide clear documentation on these limitations.- It may be beneficial to implement a more flexible or compatible serialization method for cases where
tebd_input_mode
is "strip".Locations to review:
deepmd/tf/descriptor/se_a.py
deepmd/tf/descriptor/se_atten.py
deepmd/pt/model/descriptor/dpa1.py
deepmd/dpmodel/descriptor/dpa1.py
Analysis chain
Line range hint
583-628
: The serialization method correctly handles the newtebd_input_mode
and conditionally includesembeddings_strip
. Ensure that the serialization format is compatible with existing systems and that deserialization is properly handled.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the serialization format compatibility. # Test: Search for the usage of serialization related to `tebd_input_mode`. Expect: Compatibility with existing systems. rg --type py 'serialize' -C 10 | rg 'tebd_input_mode'Length of output: 2103
deepmd/tf/descriptor/se_atten.py (2)
Line range hint
193-202
: Consider refactoring the constructor to simplify parameter handling.The constructor of
DescrptSeAtten
is quite complex with many parameters and conditional logic. Simplifying this by breaking down into smaller methods or using a configuration object might improve readability and maintainability.
1945-1965
: Review the extended serialization logic forDescrptDPA1Compat
.The method
serialize
inDescrptDPA1Compat
extends the serialization logic specifically for the 'strip' mode. While this is functional, the method is quite complex and could benefit from further comments or refactoring to improve clarity.
…3712) This PR supports stripped type embedding in DPA1 of PT/DP: - Remove `stripped_type_embedding` params in all classes and use `tebd_input_mode` == "strip" instead. - Add stripped type embedding inplementation for DPA1 of PT/DP. - Add serialize and deserialize for stripped type embedding. Note: - Old TF inplementation has not consistent behaivior when `type_one_side`==True and `tebd_input_mode` == "strip", it always uses two_side type stripped embeddings input, which is also inconsistent with `DescrptSeAEbdV2` in TF (but the training still works and only raise `NotImplementedError` when doing serialization now) may need support from @nahso . - Old TF inplementation `init_variables` will not init `idt` weights from graph for `two_side_embeeding_net_variables` (fixed), I'm surprised that no ut failed before (maybe all tests use `resnet_dt` == False). - The TF implementation of `DescrptSeAtten` does not support serialization when `tebd_input_mode` == "strip". This limitation arises because the shape of `type_embedding` cannot be determined after init, as it is decided at runtime. While the consistent version `DescrptDPA1Compat` is compatible with this configuration. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced model flexibility with new type embedding input modes: `concat` and `strip`. - **Bug Fixes** - Improved model compression logic alignment with new type embedding modes for more efficient operations. - **Documentation** - Updated documentation to explain the impact of new type embedding input modes on model descriptors. - **Tests** - Adjusted test cases to reflect changes in type embedding input modes for robust testing. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Duo <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This PR supports stripped type embedding in DPA1 of PT/DP:
stripped_type_embedding
params in all classes and usetebd_input_mode
== "strip" instead.Note:
type_one_side
==True andtebd_input_mode
== "strip", it always uses two_side type stripped embeddings input, which is also inconsistent withDescrptSeAEbdV2
in TF (but the training still works and only raiseNotImplementedError
when doing serialization now) may need support from @nahso .init_variables
will not initidt
weights from graph fortwo_side_embeeding_net_variables
(fixed), I'm surprised that no ut failed before (maybe all tests useresnet_dt
== False).DescrptSeAtten
does not support serialization whentebd_input_mode
== "strip". This limitation arises because the shape oftype_embedding
cannot be determined after init, as it is decided at runtime. While the consistent versionDescrptDPA1Compat
is compatible with this configuration.Summary by CodeRabbit
concat
andstrip
.