Skip to content

[API] Support assign Tensor to ParameterList #72190

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

Merged

Conversation

HydrogenSulfate
Copy link
Contributor

@HydrogenSulfate HydrogenSulfate commented Apr 11, 2025

PR Category

User Experience

PR Types

New features

Description

Pcard-75624

  1. 支持将Tensor类型赋值给ParameterList中的元素,行为与pytorch对齐
  2. 修复test/legacy_test/test_imperative_container_parameterlist.py单测中错误的权重列表生成方式,导致所有参数共享同一份数据的问题,将其改为列表解析生成

Copy link

paddle-bot bot commented Apr 11, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

@HydrogenSulfate HydrogenSulfate merged commit d195362 into PaddlePaddle:develop Apr 15, 2025
39 of 40 checks passed
github-merge-queue bot pushed a commit to deepmodeling/deepmd-kit that referenced this pull request Apr 26, 2025
support dpa3 with paddle backend(eager mode)

### 1. training curve


![pt_vs_pd](https://github.com/user-attachments/assets/22f4681e-a464-41cb-9b1b-16ed20112563)

### 2. accuracy

<details>
  <summary>torch</summary>


![image](https://github.com/user-attachments/assets/c737ed30-0108-43f3-9d0e-7ae289db1498)

</details>


<details>
  <summary>paddle(slightly better than torch)</summary>


![image](https://github.com/user-attachments/assets/5e75abb8-f3be-46ce-adc1-eaf453cedcba)

</details>

### 3. The main modifications in this PR include:

1. Added DPA-3 code and related modules based on the Paddle backend.
2. Added the EnergyHessianStdLoss module based on the Paddle backend.
3. Discovered that Paddle’s ParameterList does not support assignment of
Tensors using the equals sign. Therefore, I added support for this
feature at <PaddlePaddle/Paddle#72190>. However,
considering version compatibility, deepmd still uses paddle.assign for
assignments.
4. Fixed an issue in env_mat_stat.py where the return type was Tensor
instead of float.
5. The SiLUT used APIs from the numpy series that do not support
paddle.Tensor, so I replaced them with Paddle’s native APIs.
Additionally, to temporarily bypass issues with dynamic-to-static
control flow, I changed the if-else branch in SiLUT.forward to a single
branch.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new descriptor, DPA3, for advanced molecular simulations,
including its integration and public availability.
- Added support for a new graph-based neural network layer and
descriptor block for RepFlow calculations.
  - Enabled Hessian loss computation for enhanced training capabilities.
  - Added new learning rate utility.

- **Bug Fixes**
- Improved tensor shape handling and assignments for better
compatibility and stability.

- **Tests**
- Added comprehensive tests for the new DPA3 descriptor, including
consistency, JIT, and multitask scenarios.
- Expanded test coverage for model permutation and smoothness with DPA3.
  - Enhanced tests for DPA2 with CINN compiler support.

- **Refactor**
- Standardized tensor shape definitions and updated method signatures
for improved clarity and type safety.

- **Chores**
  - Updated public interfaces to include new features and descriptors.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Duo <[email protected]>
Co-authored-by: Duo <[email protected]>
Co-authored-by: root <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Chenqqian Zhang <[email protected]>
Co-authored-by: Jia-Xin Zhu <[email protected]>
Co-authored-by: Jinzhe Zeng <[email protected]>
Co-authored-by: Han Wang <[email protected]>
Co-authored-by: Han Wang <[email protected]>
YqGe585 pushed a commit to YqGe585/Paddle that referenced this pull request May 7, 2025
* support assign Tensor to ParameterList

* update UT

* fix list comprehension gramma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants