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

[dy2s] speed up PartialProgram.__call__ #58771

Merged

Conversation

feifei-111
Copy link
Contributor

@feifei-111 feifei-111 commented Nov 7, 2023

PR types

Others

PR changes

Others

Description

  1. remove not needed part for sot
  2. fall create tensor to cpp

PCard-66972

Copy link
Contributor

@2742195759 2742195759 left a comment

Choose a reason for hiding this comment

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

LGTM

autograd_meta->SetStopGradient(var_desc.StopGradient());

if (var_type == paddle::framework::proto::VarType::LOD_TENSOR) {
// TODO(jiabin): Maybe support LOD later
Copy link
Contributor

Choose a reason for hiding this comment

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

这个删了吧。

Comment on lines +1902 to +1905
if (!autograd_meta->GetMutableGradNode()) {
autograd_meta->SetGradNode(
std::make_shared<egr::GradNodeAccumulation>(autograd_meta));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

不需要,删了

if (PyList_Check(var_desc_list)) {
Py_ssize_t len = PyList_Size(var_desc_list);
for (Py_ssize_t i = 0; i < len; i++) {
auto var_desc = PyObjectCast<paddle::framework::VarDesc>(
Copy link
Contributor

Choose a reason for hiding this comment

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

是否可以使用 paddle::framework::VarDesc& ,防止一遍拷贝?

auto var_desc = PyObjectCast<paddle::framework::VarDesc>(
PyList_GetItem(var_desc_list, i));
auto var_name = var_desc.Name();
if (out_tensor_map.find(var_name) == out_tensor_map.end()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这个Map在PIR下是可以删除的。

In sot, inputs and outputs of partial program only contain tensors, so we can skip some step to speed up
"""
out_vars = self._prepare_outputs()
attrs = self._prepare_attributes()
Copy link
Contributor

Choose a reason for hiding this comment

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

如果SOT将AMP+training考虑了guard,不同的AMP状态会触发转写 / PrtialProgramLayer的重新构造,就可以将这部分加个 cache_property 中。

@2742195759 2742195759 merged commit 2a20832 into PaddlePaddle:develop Nov 22, 2023
28 checks passed
SecretXV pushed a commit to SecretXV/Paddle that referenced this pull request Nov 28, 2023
* move Tensor construction to cpp

* mv _remove_no_value to ASTStaticFunction

* update
@feifei-111 feifei-111 deleted the fall_partial_program_to_cpp branch December 15, 2023 04:14
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