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

[Fluid] Move distributed_fused_lamb_init to phi #55993

Merged
merged 20 commits into from
Aug 31, 2023

Conversation

zeroRains
Copy link
Contributor

PR types

Others

PR changes

Others

Description

将distributed_fused_lamb_init 迁移到phi下

@paddle-bot
Copy link

paddle-bot bot commented Aug 5, 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 paddle-bot bot added contributor External developers status: proposed labels Aug 5, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Aug 7, 2023
@luotao1 luotao1 added HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 and removed HappyOpenSource 快乐开源活动issue与PR labels Aug 7, 2023
@zeroRains
Copy link
Contributor Author

zeroRains commented Aug 8, 2023

@GhostScreaming 老师可以帮我看一下,这个enforce应该怎么改吗?
3565865152c76bb25c3742ee3da7b53

std::vector<DenseTensor *> master_param_out,
std::vector<DenseTensor *> grad_out,
DenseTensor *global_scale,
DenseTensor *step) {
Copy link

Choose a reason for hiding this comment

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

这里代码风格建议,&和*都写在靠近类型的地方吧

Copy link
Contributor

Choose a reason for hiding this comment

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

@zeroRains 辛苦改一下~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

额,这个应该是我的代码格式工具自动把我改好的风格又改回去了,等enforce的那个问题修好后我再一起push上来吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@GhostScreaming 老师,这个我修改成靠近类型之后,用pre-commit时他又自动改回靠变量那边了。。。。这咋整

Copy link
Contributor

Choose a reason for hiding this comment

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

先这样吧,问题不大


PADDLE_ENFORCE_EQ(
param.size(),
param_out.size(),
Copy link

Choose a reason for hiding this comment

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

这里param_out需要申请空间,否则size是0,可以参考fluid下MultiOutput的内部实现

@zeroRains
Copy link
Contributor Author

@GhostScreaming 老师,pr可以review了

kernel->OutputAt(7).SetDataType(phi::DataType::FLOAT32);
kernel->OutputAt(8).SetDataType(phi::DataType::INT32);
kernel->OutputAt(9).SetDataType(phi::DataType::INT32);
kernel->OutputAt(10).SetDataType(phi::DataType::INT32);
Copy link
Contributor

Choose a reason for hiding this comment

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

param_out, grad_out的类型应该与Input的param一致,(可能为phi::DataType::FLOAT32或者phi::DataType::FLOAT16master_param_out的类型应该为phi::DataType::FLOAT32

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

paddle/fluid/operators/optimizers/cast_with_ptr.h可以删掉了,只有distributed_fused_lamb_init依赖这个文件

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


CopyAndShareBufferForInitedTensor(
dev_ctx, info.param_t, fp16_p_t, info.numel_offset);
// PADDLE_ENFORCE_EQ(
Copy link
Contributor

Choose a reason for hiding this comment

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

为啥删掉这个检查?

Copy link
Contributor Author

@zeroRains zeroRains Aug 22, 2023

Choose a reason for hiding this comment

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

@GhostScreaming 老师可以帮我看一下,这个enforce应该怎么改吗? 3565865152c76bb25c3742ee3da7b53

额之前我是试着改了一下,但是发生了编译错误,也问了一下老师您。您可能没看到,后面我尝试用一个指针变量接收分配结果,再进行检查也不行,所以就先注释了先改别的。老师麻烦您帮我看看这个应该怎么改呢? @GhostScreaming

Copy link
Contributor

Choose a reason for hiding this comment

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

master_param_out已经和sliced_tensor share buffer了,再给它分配空间是不是有点问题?直接调master_param_out[info.idx]->data<float>()试试?

Copy link
Contributor Author

@zeroRains zeroRains Aug 24, 2023

Choose a reason for hiding this comment

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

好像还是不行
@GhostScreaming

image

Copy link

Choose a reason for hiding this comment

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

好像还是不行 @GhostScreaming

image

可以按下面的用法试下:
float* master_param_tmp = dev_ctx.template Alloc(master_param_out[info.idx]);
float* sliced_tensor_tmp = reinterpret_cast<float*>(sliced_tensor.data());
PADDLE_ENFORCE_EQ( master_param_tmp, sliced_tensor_tmp,
errors::InvalidArgument("Invalid master weight tensor pointer."));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好像还是不行 @GhostScreaming
image

可以按下面的用法试下: float* master_param_tmp = dev_ctx.template Alloc(master_param_out[info.idx]); float* sliced_tensor_tmp = reinterpret_cast<float*>(sliced_tensor.data()); PADDLE_ENFORCE_EQ( master_param_tmp, sliced_tensor_tmp, errors::InvalidArgument("Invalid master weight tensor pointer."));

解决了,谢谢老师!

kernel->OutputAt(7).SetDataType(phi::DataType::FLOAT32);
kernel->OutputAt(8).SetDataType(phi::DataType::INT32);
kernel->OutputAt(9).SetDataType(phi::DataType::INT32);
kernel->OutputAt(10).SetDataType(phi::DataType::INT32);
Copy link
Contributor

Choose a reason for hiding this comment

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

param_out, grad_out的类型应该与Input的param一致,(可能为phi::DataType::FLOAT32或者phi::DataType::FLOAT16master_param_out的类型应该为phi::DataType::FLOAT32

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@GhostScreaming GhostScreaming left a comment

Choose a reason for hiding this comment

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

LGTM

std::vector<DenseTensor *> master_param_out,
std::vector<DenseTensor *> grad_out,
DenseTensor *global_scale,
DenseTensor *step) {
Copy link
Contributor

Choose a reason for hiding this comment

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

先这样吧,问题不大

@luotao1 luotao1 merged commit 0bc369e into PaddlePaddle:develop Aug 31, 2023
BeingGod pushed a commit to BeingGod/Paddle that referenced this pull request Sep 9, 2023
@zeroRains zeroRains deleted the distributed branch September 25, 2023 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants