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

[Fea] Support detach_keys argument for all PDE #889

Merged
merged 6 commits into from
May 13, 2024

Conversation

HydrogenSulfate
Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate commented May 11, 2024

PR types

Others

PR changes

APIs

Describe

  1. 支持方程初始化时指定detach_keys,使得梯度不会通过这些key对应的变量反向传播,并添加对应单测。

    graph TD;
        x & y-->u & v;
        x & u-->u__x;
        y & v-->v__y;
        u__x & u --> o1;
        v__y & v --> o2;
        o1 & o2 --> z;
    
    Loading

    detach_keys("u", "v__y")时,计算关系会变为下图(新增两条detach路径)。

    graph TD;
        x & y-->u & v;
        x & u-->u__x;
        y & v-->v__y;
        u --> |detach| u_detach([u_detach]);
        u__x & u_detach --> o1;
        v__y --> |detach| v__y_detach([v__y_detach]);
        v__y_detach & v --> o2;
        o1 & o2 --> z;
    
    Loading

Copy link

paddle-bot bot commented May 11, 2024

Thanks for your contribution!

Copy link
Collaborator

@zhiminzhang0830 zhiminzhang0830 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhiminzhang0830 zhiminzhang0830 merged commit 48a91f9 into PaddlePaddle:develop May 13, 2024
3 of 4 checks passed
@HydrogenSulfate HydrogenSulfate deleted the support_detach branch May 25, 2024 17:53
huohuohuohuohuo123 pushed a commit to huohuohuohuohuo123/PaddleScience that referenced this pull request Aug 12, 2024
* fully support detach_keys argument for all PDE

* add unitest for detach option

* fix access for 'name' when exp do not have 'name' attribute

* fix unitest

* add example code for _apply_detach

* fix test_pde_base
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