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

赛题八:paddleviz能力扩展——Tensor信息展示 #56837

Merged
merged 28 commits into from
Sep 20, 2023

Conversation

qiuwenbogdut
Copy link
Contributor

@qiuwenbogdut qiuwenbogdut commented Aug 31, 2023

PR types

New features

PR changes

Others

Description

赛题简介:
飞桨深度学习框架提供了动态图编程的模式来开发深度学习模型(方便开发与调试),但动态图的反向图调试能力仍存在不足。@qiuwenbogdut 和 @Tomoko-hjf 两位社区开发者为Paddle开发了反向图可视化工具 paddleviz,很大程度上提升了反向图的调试能力。但我们还希望,在现有 paddleviz 基础上,扩展 paddleviz 的能力,进一步提升反向图的调试能力。

赛题要求:
深入学习Paddle动态图机制,掌握动态图反向图的基础数据结构之间的关系
学习了解 paddleviz 的原理
探索如何在 paddleviz 基础上,扩展反向图边(Tensor)的调试信息,包括不限于Tensor name、shape、dtype、place、stop_gradient 等。
探索以上数据可以通过框架的哪些数据结构中获得,何时、如何获得
探索如何将这些数据在 paddleviz 中展示

赛题八 任务描述
赛题八 tracking issue

当前这个PR计划完成的工作:

  1. 将反向节点的指针值作为一个grad_node的属性暴露给python端, 在python能获取到反向节点的指针值
  2. 打印反向节点的输入和输出值, 用于后面构建反向图中的边的信息 (反向图和边的信息可视化 可用工具来构建显示: paddleviz) 打印的信息示例如下:
image

@paddle-bot
Copy link

paddle-bot bot commented Aug 31, 2023

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

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

third_party/flashattn的修改不要提交

Comment on lines 175 to 138
std::stringstream ss;
ss << this;
std::string this_pointer = ss.str();
Copy link
Contributor

Choose a reason for hiding this comment

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

这段代码是没有使用的吧。删掉吧

VLOG(3) << "Finish AD API Grad: GradNodeAccumulation";
if (VLOG_IS_ON(4)) {
VLOG(6) << "gradnode_ptr = " << this;
if (VLOG_IS_ON(6)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这个VLog的级别是不能改的。必须是4

const char* TENSOR_X_GRAD_TEMPLATE = "(grad_out, [%s]), ";
std::string output_x_grad_str = paddle::string::Sprintf(
TENSOR_X_GRAD_TEMPLATE, egr::EagerUtils::TensorStr(grad_out));
output_str += output_x_grad_str;
VLOG(4) << paddle::string::Sprintf(
VLOG(6) << paddle::string::Sprintf(
Copy link
Contributor

Choose a reason for hiding this comment

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

这个VLog的级别是不能改的。必须是4

@@ -72,6 +72,30 @@ AddNGradNodeFinal::operator()(
egr::CheckTensorHasNanOrInf("add_n_grad", returns);
}

VLOG(6) << "gradnode_ptr = " << this;
if (VLOG_IS_ON(6)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这个VLog的级别是不能改的。必须是4

@@ -162,6 +163,41 @@ Conv2dGradNodeFinal::operator()(
// Set TensorWrappers for Forward Outputs if needed
}

VLOG(6) << "gradnode_ptr = " << this;
if (VLOG_IS_ON(6)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这个VLog的级别是不能改的。必须是4

@@ -457,7 +458,7 @@ SyncBatchNormGradNode::operator()(
std::string output_bias_grad_str = paddle::string::Sprintf(
TENSOR_BIAS_GRAD_TEMPLATE, egr::EagerUtils::TensorStr(bias_grad));
output_str += output_bias_grad_str;
VLOG(4) << paddle::string::Sprintf(
VLOG(6) << paddle::string::Sprintf(
Copy link
Contributor

Choose a reason for hiding this comment

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

这个VLog的级别是不能改的。必须是4

//std::cout << "The pointer to the current object: " << this << std::endl;
//std::stringstream ss;
//ss << this;
//std::string this_pointer = ss.str();

Copy link
Contributor

Choose a reason for hiding this comment

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

这段代码删掉吧

@@ -259,10 +266,10 @@ class {} : public egr::GradNodeBase {{
"""

AFTER_LOG_PRINT_TEMPLATE = """
if(VLOG_IS_ON(4)){{
if(VLOG_IS_ON(6)){{
Copy link
Contributor

Choose a reason for hiding this comment

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

这个VLog的级别是不能改的。必须是4

const char* INPUT_PRINT_TEMPLATE = \"{{ Input: [%s], \\n Output: [%s] }} \";
{}
VLOG(4) << paddle::string::Sprintf(INPUT_PRINT_TEMPLATE, input_str, output_str);
VLOG(6) << paddle::string::Sprintf(INPUT_PRINT_TEMPLATE, input_str, output_str);
Copy link
Contributor

Choose a reason for hiding this comment

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

这个VLog的级别是不能改的。必须是4

Comment on lines 597 to 598
//打印一下 next_node 对象的指针值
std::cout << "next_node: " << next_node << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

这个日志是要保留的吗?如果要保留的话需要是英文注释,而且不能用std::cout,要用Vlog。如果不需要保留就删掉吧

wanghuancoder
wanghuancoder previously approved these changes Sep 15, 2023
Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

LGTM

@luotao1
Copy link
Contributor

luotao1 commented Sep 15, 2023

PR-CI-Codestyle-Check 需要解决格式问题

@qiuwenbogdut
Copy link
Contributor Author

PR-CI-Codestyle-Check 需要解决格式问题

好的 这边处理一下

wanghuancoder
wanghuancoder previously approved these changes Sep 19, 2023
Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 295 to 296
VLOG(4) << paddle::string::Sprintf(INPUT_PRINT_TEMPLATE, input_str, output_str);
VLOG(6) << paddle::string::Sprintf(INPUT_PRINT_TEMPLATE, input_str, output_str);
Copy link
Contributor

Choose a reason for hiding this comment

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

这两行看上去一样,新加一个VLOG(6)的作用是什么呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

原始的日志等级是4 等级不够高 有些需要的信息没有打印出来,所以就增加了一个等级为6的日志打印
image

Copy link
Contributor

@zyfncg zyfncg Sep 19, 2023

Choose a reason for hiding this comment

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

image 这里的信息打印重复了吧?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的, 确实存在重复打印的问题, 这边修改一下

@zyfncg
Copy link
Contributor

zyfncg commented Sep 19, 2023

image 可以在描述里再补充下这个PR具体做的工作,以及这些LOG的运行截图吗?

@qiuwenbogdut
Copy link
Contributor Author

image 可以在描述里再补充下这个PR具体做的工作,以及这些LOG的运行截图吗?

已经增加了 这个PR的具体工作 和 日志打印图
image

Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -870,6 +870,8 @@ PYBIND11_MODULE(libpaddle, m) {
[](const std::shared_ptr<egr::GradNodeBase> &self) {
return self->NextFunctions();
})

.def("node_this_ptr", &egr::GradNodeBase::GetThisPtr)
Copy link
Contributor

Choose a reason for hiding this comment

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

node_this_ptr这么命名感觉有些奇怪,可以再想想有没有更好的命名

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wanghuancoder 欢哥 命名这块有没有什么建议?

Copy link
Contributor

Choose a reason for hiding this comment

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

要不改成.def("node_ptr", &egr::GradNodeBase::GetPtr)吧
这个PR不要改了。新提一个PR修改。这个PR先合入。

@wanghuancoder wanghuancoder merged commit d132cec into PaddlePaddle:develop Sep 20, 2023
27 checks passed
iosmers pushed a commit to iosmers/Paddle that referenced this pull request Sep 21, 2023
Frida-a pushed a commit to Frida-a/Paddle that referenced this pull request Oct 14, 2023
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants