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

[IR] Support GC and TraceRun for NewIr InterpreterCore #55772

Merged
merged 33 commits into from
Jul 31, 2023

Conversation

zhangbo9674
Copy link
Contributor

@zhangbo9674 zhangbo9674 commented Jul 28, 2023

PR types

New features

PR changes

Others

Description

基于新 IR InstructionBase 体系,支持 Gc 及 TraceRun,跑通 standalone_executor_new_ir_test 单测。

后续工作:

  • BetaRun 转正,修复所有单测问题,成为 NewIrInterpreter 的默认 Run 接口
  • Fluid 算子体系接入
  • Execution 异步执行逻辑接入

Others

Pcard-67164

@paddle-bot
Copy link

paddle-bot bot commented Jul 28, 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.

@paddle-bot
Copy link

paddle-bot bot commented Jul 28, 2023

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

@zhangbo9674 zhangbo9674 changed the title Dev/support ir gc [IR] Support GC and TraceRun for NewIr InterpreterCore Jul 28, 2023
Copy link
Contributor

@winter-wang winter-wang left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@Aurelius84 Aurelius84 left a comment

Choose a reason for hiding this comment

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

LGTM overall

@@ -37,6 +37,19 @@ InterpreterCoreEventGarbageCollector::InterpreterCoreEventGarbageCollector(
}
}

InterpreterCoreEventGarbageCollector::InterpreterCoreEventGarbageCollector(
const std::vector<std::unique_ptr<InstructionBase>>& vec_instruction) {
Copy link
Contributor

Choose a reason for hiding this comment

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

后续我们讨论下参数命名规范,是否需要以 type 的前缀来标记,比如vec_map_。目前有的采用instructions 这种带 s后缀来表示 list信息的(我个人是倾向于后者的,因为可以跟类型解耦。)

/*allow_spinning*/ true,
/*track_task*/ false);
queue_ = CreateSingleThreadedWorkQueue(options);
for (auto& instruc : vec_instruction) {
Copy link
Contributor

@Aurelius84 Aurelius84 Jul 31, 2023

Choose a reason for hiding this comment

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

对于for-loop的缩写变量命令也可以留意一下,instrinstruc更常见?或者不想起名,直接instruction来用(搭配前面的 instructions)可以很好区别。

}
return -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

这里为什么不直接PADDLE_THROW?caller需要处理这个-1么?


auto op_downstream_map = dependency_builder_.OpDownstreamMap();

VLOG(4) << "1";
Copy link
Contributor

Choose a reason for hiding this comment

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

下个PR可以清理下这里的调试log


std::stringstream ss;
ss << "trace order: ";
for (size_t idx = 0; idx < trace_execute_order_.size(); idx++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这里总会执行的,建议使用 if(VLOG_IS_ON(6)){XXX}

@@ -1725,5 +1686,455 @@ void NewIRInterpreter::BuildInstructionDependences() {
}
}

void NewIRInterpreter::RecordMemcpyD2H(InstructionBase* instr_node) {
// NOTE(zhiqiu): hot fix for jit input var
if (instr_node->Name() == "pd.memcpy_d2h") {
Copy link
Contributor

Choose a reason for hiding this comment

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

后续我们要不要维护一个新IR下的头文件,定义所有这些特殊Op name,这样我们就知道初期我们累计了多少TODO的分支逻辑了,后续也好专项清理

VLOG(4) << "var_ref_count_.size() : " << var_ref_count_.size();
for (size_t i = 0; i < last_live_ops_.size(); ++i) {
std::set<size_t> minumum_last_live_ops;
for (auto val : last_live_ops_[i]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这个是LOG相关的for循环?看起来总会执行?

refs_.emplace_back(std::make_shared<interpreter::VarRefInfo>(
var_ref_count_[i], variable_list_[i]));
}
VLOG(4) << "calculate last_live_ops_ 3";
Copy link
Contributor

Choose a reason for hiding this comment

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

或者优化下LOG 文案,或者考虑删除掉~~

@zhangbo9674 zhangbo9674 merged commit dc96ebc into PaddlePaddle:develop Jul 31, 2023
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.

5 participants