-
Notifications
You must be signed in to change notification settings - Fork 525
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(pd): add se_atten_v2 #4558
base: devel
Are you sure you want to change the base?
Conversation
Signed-off-by: Jinzhe Zeng <[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.
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
deepmd/pd/model/descriptor/se_atten_v2.py:43
- [nitpick] The parameter name 'sel' is ambiguous. It should be renamed to 'selection' for clarity.
sel: Union[list[int], int],
@@ -248,11 +255,40 @@ def skip_array_api_strict(self) -> bool: | |||
) | |||
) | |||
|
|||
@property | |||
def skip_pd(self) -> bool: |
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.
The 'skip_pd' function is missing a return statement for the 'CommonTest.skip_pt' condition.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
📝 WalkthroughWalkthroughThis pull request introduces a new descriptor class Changes
Sequence DiagramsequenceDiagram
participant Descriptor as DescrptSeAttenV2
participant Serializer as Serialization Methods
Descriptor->>Serializer: serialize()
Serializer-->>Descriptor: Returns state dictionary
Descriptor->>Serializer: deserialize(data)
Serializer-->>Descriptor: Reconstructs object instance
Possibly related PRs
Suggested labels
Finishing Touches
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: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
deepmd/pd/model/descriptor/__init__.py
(2 hunks)deepmd/pd/model/descriptor/se_atten_v2.py
(1 hunks)source/tests/consistent/descriptor/test_se_atten_v2.py
(4 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
deepmd/pd/model/descriptor/se_atten_v2.py
45-45: Do not use mutable data structures for argument defaults
Replace with None
; initialize within function
(B006)
56-56: Do not use mutable data structures for argument defaults
Replace with None
; initialize within function
(B006)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: Test Python (4, 3.12)
- GitHub Check: Test Python (4, 3.9)
- GitHub Check: Test Python (3, 3.12)
- GitHub Check: Test Python (3, 3.9)
- GitHub Check: Test Python (2, 3.12)
- GitHub Check: Test Python (2, 3.9)
- GitHub Check: Test Python (1, 3.12)
- GitHub Check: Build wheels for cp311-manylinux_x86_64
- GitHub Check: Test Python (1, 3.9)
🔇 Additional comments (5)
deepmd/pd/model/descriptor/se_atten_v2.py (1)
195-275
: Implementation ofserialize
anddeserialize
methodsThe
serialize
anddeserialize
methods are well-implemented, handling the conversion of the object's state to and from a dictionary correctly. This ensures that the descriptor can be saved and loaded effectively.deepmd/pd/model/descriptor/__init__.py (2)
25-27
: Correctly added import forDescrptSeAttenV2
The addition of
DescrptSeAttenV2
to the imports ensures that the new descriptor is properly included in the module.
43-43
: Updated__all__
to includeDescrptSeAttenV2
Including
DescrptSeAttenV2
in the__all__
list makes it publicly accessible when the module is imported, which is appropriate for this new descriptor.source/tests/consistent/descriptor/test_se_atten_v2.py (2)
48-53
: Conditional import for Paddle backend is appropriateThe conditional import of
DescrptSeAttenV2
for the Paddle backend (pd
) correctly ensures that the class is only imported when Paddle is installed.
378-387
: Addedeval_pd
method for Paddle backend testingThe
eval_pd
method is correctly implemented to evaluate the descriptor using the Paddle backend, ensuring consistency in testing across different backends.
activation_function: str = "tanh", | ||
precision: str = "float64", | ||
resnet_dt: bool = False, | ||
exclude_types: list[tuple[int, int]] = [], |
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.
Avoid mutable default argument for exclude_types
parameter
Using a mutable default value exclude_types: list[tuple[int, int]] = []
can cause unintended side effects since the default list is shared across all instances. Consider using None
as the default value and initializing the list inside the constructor.
Apply this diff to fix the issue:
exclude_types: list[tuple[int, int]] = [],
+ if exclude_types is None:
+ exclude_types = []
Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 Ruff (0.8.2)
56-56: Do not use mutable data structures for argument defaults
Replace with None
; initialize within function
(B006)
rcut_smth: float, | ||
sel: Union[list[int], int], | ||
ntypes: int, | ||
neuron: list = [25, 50, 100], |
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.
Avoid mutable default argument for neuron
parameter
Using a mutable default value neuron: list = [25, 50, 100]
can lead to unexpected behavior because the same list instance is shared across all instances of the class. It's safer to set the default to None
and initialize the list within the constructor.
Apply this diff to fix the issue:
neuron: list = [25, 50, 100],
+ if neuron is None:
+ neuron = [25, 50, 100]
Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 Ruff (0.8.2)
45-45: Do not use mutable data structures for argument defaults
Replace with None
; initialize within function
(B006)
@property | ||
def skip_pd(self) -> bool: | ||
( | ||
tebd_dim, | ||
resnet_dt, | ||
type_one_side, | ||
attn, | ||
attn_layer, | ||
attn_dotr, | ||
excluded_types, | ||
env_protection, | ||
set_davg_zero, | ||
scaling_factor, | ||
normalize, | ||
temperature, | ||
ln_eps, | ||
concat_output_tebd, | ||
precision, | ||
use_econf_tebd, | ||
use_tebd_bias, | ||
) = self.param | ||
return CommonTest.skip_pt or self.is_meaningless_zero_attention_layer_tests( | ||
attn_layer, | ||
attn_dotr, | ||
normalize, | ||
temperature, | ||
) | ||
|
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.
Method skip_pd
might refer to incorrect attribute
In the skip_pd
property, CommonTest.skip_pt
is used, which may be a typo. Since this property is for the Paddle backend, it should likely use CommonTest.skip_pd
or handle the condition appropriately.
Apply this diff to fix the issue:
@property
def skip_pd(self) -> bool:
(
tebd_dim,
resnet_dt,
type_one_side,
attn,
attn_layer,
attn_dotr,
excluded_types,
env_protection,
set_davg_zero,
scaling_factor,
normalize,
temperature,
ln_eps,
concat_output_tebd,
precision,
use_econf_tebd,
use_tebd_bias,
) = self.param
- return CommonTest.skip_pt or self.is_meaningless_zero_attention_layer_tests(
+ return CommonTest.skip_pd or self.is_meaningless_zero_attention_layer_tests(
attn_layer,
attn_dotr,
normalize,
temperature,
)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
@property | |
def skip_pd(self) -> bool: | |
( | |
tebd_dim, | |
resnet_dt, | |
type_one_side, | |
attn, | |
attn_layer, | |
attn_dotr, | |
excluded_types, | |
env_protection, | |
set_davg_zero, | |
scaling_factor, | |
normalize, | |
temperature, | |
ln_eps, | |
concat_output_tebd, | |
precision, | |
use_econf_tebd, | |
use_tebd_bias, | |
) = self.param | |
return CommonTest.skip_pt or self.is_meaningless_zero_attention_layer_tests( | |
attn_layer, | |
attn_dotr, | |
normalize, | |
temperature, | |
) | |
@property | |
def skip_pd(self) -> bool: | |
( | |
tebd_dim, | |
resnet_dt, | |
type_one_side, | |
attn, | |
attn_layer, | |
attn_dotr, | |
excluded_types, | |
env_protection, | |
set_davg_zero, | |
scaling_factor, | |
normalize, | |
temperature, | |
ln_eps, | |
concat_output_tebd, | |
precision, | |
use_econf_tebd, | |
use_tebd_bias, | |
) = self.param | |
return CommonTest.skip_pd or self.is_meaningless_zero_attention_layer_tests( | |
attn_layer, | |
attn_dotr, | |
normalize, | |
temperature, | |
) |
Has been used for benchmark
Summary by CodeRabbit
Release Notes
New Features
DescrptSeAttenV2
with advanced embedding and attention mechanismsTests
Documentation