Skip to content
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

【pir】update If_grad and while_grad op' stop gradient by yield_op #70545

Merged

Conversation

xiaoguoguo626807
Copy link
Contributor

PR Category

Execute Infrastructure

PR Types

Bug fixes

Description

pcard-67164

对于控制流高阶微分,其一阶反向是先创建空op, 再单独向block 中添加子op, 添加之后需要根据里面op 输出的stop_gradient 进行更新

Copy link

paddle-bot bot commented Dec 30, 2024

你的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
Contributor

@changeyoung98 changeyoung98 left a comment

Choose a reason for hiding this comment

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

LGTM

@xiaoguoguo626807 xiaoguoguo626807 merged commit 27ca016 into PaddlePaddle:develop Jan 2, 2025
30 checks passed
@xiaoguoguo626807 xiaoguoguo626807 deleted the if_while_stop_gradient branch January 6, 2025 01:46
github-merge-queue bot pushed a commit to deepmodeling/deepmd-kit that referenced this pull request Jan 13, 2025
1. support LAMMPS inference with Paddle backend on cuda and dcu device
2. Fix `deepmd/pd/utils/serialization.py` and paddle inference files can
be deserialized using `dp convert-backend deeppot_sea.yaml
deeppot_sea.json`

related PR:
1. PaddlePaddle/Paddle#70545
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

Based on the comprehensive changes, here are the updated release notes:

- **New Features**
	- Added support for PaddlePaddle deep learning framework.
	- Introduced new Paddle-based deep potential model computations.
	- Expanded backend support for model inference with Paddle.

- **Configuration**
	- New CMake option `ENABLE_PADDLE` to toggle Paddle support.
- Added configuration parameters for Paddle version and inference
directory.

- **Testing**
	- Comprehensive test suites added for Paddle backend.
	- Enhanced LAMMPS integration tests with Paddle support.

- **Documentation**
- Updated version header and configuration files to reflect Paddle
integration.

- **Performance**
	- Added JIT compilation for Paddle model methods.
	- Optimized model serialization and deserialization.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: HydrogenSulfate <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Co-authored-by: Jinzhe Zeng <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit to deepmodeling/deepmd-kit that referenced this pull request Feb 8, 2025
We verified paddle CINN compiler in DPA-2 example(single A100-SXM (40G),
cada11.8, Intel(R) Xeon(R) Gold 6248 CPU @ 2.50GHz x 160).

To enable CINN compiler in training, add one flag: `CINN=1` before
training command, e.g. `CINN=1 dp --pd train input_torch_medium.json`.

### Curves:
#### dpa2

![e9eb3013dc154b03172a0c1881507c8e](https://github.com/user-attachments/assets/3cfe2c1f-badd-414e-bb51-f59791f641e1)

##### Performance 

We tested with torch==2.6.0.dev20241219+cu118
| Pytorch(eager) | Pytorch(compile) | Paddle(eager) | Paddle(CINN
compile) |
| -- | -- | -- | -- |
| 0.1078s/step | compile do not support double-backward | 0.1130s/step |
0.0638s/step |

#### se_atten

![image](https://github.com/user-attachments/assets/c4c2cdaa-6cbb-4a67-8639-598a094472bc)

##### Performance 

We tested with torch==2.6.0.dev20241219+cu118
| Pytorch(eager) | Pytorch(compile) | Paddle(eager) | Paddle(CINN
compile) |
| -- | -- | -- | -- |
| 0.0342s/step | compile do not support double-backward | 0.0444s/step |
0.0244s/step |

### Accuracy details:

#### dpa2
- Pytorch:

![image](https://github.com/user-attachments/assets/d74528e9-11eb-432b-b7cc-bf568b224dcb)

- Paddle(eager mode):

![image](https://github.com/user-attachments/assets/dc17b5d2-7f13-498c-9398-9d4c1a9a1e22)

- Paddle(CINN compiler)

![1da419d9d8b27981cfd3a1067e30ce6f](https://github.com/user-attachments/assets/f20286a1-6088-4f6f-b667-2b4763a438b5)

#### se_atten
- Pytorch

![image](https://github.com/user-attachments/assets/be46fd72-2db9-451b-9c2c-d5c382b75c6f)

- Paddle(eager_mode)

![image](https://github.com/user-attachments/assets/cffeedf8-26dd-4142-830b-af5106805e52)

- Paddle(CINN compliler)

![image](https://github.com/user-attachments/assets/971a9476-703f-4765-81b9-c45311cc803f)


### TODO:
- [x] Fix high order backward of control flow in
Paddle(PaddlePaddle/Paddle#70545)
- [ ] Fix shape64
issue(PaddlePaddle/Paddle#70947)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced training performance through optimization techniques that
leverage compilation and profiling for better execution monitoring.
- Introduced a new function for converting various input types to
boolean values, improving environment variable handling.

- **Refactor**
- Improved precision management for training parameters and updated
environment configuration handling to ensure robust optimization
support.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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