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

[AutoParallel] Support shard parameter #57278

Merged
merged 4 commits into from
Sep 15, 2023

Conversation

chenwhql
Copy link
Contributor

@chenwhql chenwhql commented Sep 13, 2023

PR types

New features

PR changes

APIs

Description

Pcard-73145

[AutoParallel] Support shard parameter

paddle.distributed.shard_tensor需要支持对Parameter的切分,以满足当时设计的写法需求

class LinearNet(nn.Layer):
    def __init__(self):
        super(LinearNet, self).__init__()
        self.w0 = dist.shard_tensor(
                    self.create_parameter(shape=[IMAGE_SIZE, IMAGE_SIZE]), 
                    dist.DistAttr(mesh=mesh0, sharding_specs=['x', None]))
        self.w1 = dist.shard_tensor(
                    self.create_parameter(shape=[IMAGE_SIZE, IMAGE_SIZE]), 
                    dist.DistAttr(mesh=mesh1)) 
                    
    def forward(self, x):
        y = paddle.matmul(x, self.w0)
        y = dist.reshard(y, dist.DistAttr(mesh=mesh1))
        z = paddle.matmul(y, self.w1)
        return z

此处Layer的Parameter被shard之后,仍然赋值给Layer的Parameter,因此shard_tensor不能改变Parameter的属性,仍然需要是Parameter

@paddle-bot
Copy link

paddle-bot bot commented Sep 13, 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.

@@ -276,6 +276,7 @@ void InitDistTensorWithTensor(TensorObject* self,
paddle::platform::errors::InvalidArgument(
"DistTensor can only initialize by DenseTensor"));
self->tensor.set_name(name);
VLOG(4) << "Do TensorCopy from DenseTensor to DistTensor.";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

这条日志应该可以移除,后续PR再移除

Copy link
Contributor

@zhiqiu zhiqiu 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

@LiYuRio LiYuRio 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

@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

@chenwhql chenwhql merged commit 67f4ac7 into PaddlePaddle:develop Sep 15, 2023
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
* support shard parameter

* add deep copy impl

* dix adamax test failed
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.

4 participants