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

static support mp_layers #33700

Merged

Conversation

wangxicoding
Copy link
Contributor

@wangxicoding wangxicoding commented Jun 21, 2021

PR types

New features

PR changes

APIs

Describe

c_softmax_with_cross_entropy API support static graph.
mp_layers接口支持静态图,mp_layers实现动静统一。

import paddle
import paddle.distributed.fleet as fleet

paddle.enable_static()

class ColumnLinearNet(paddle.nn.Layer):
    def __init__(self, input_size, output_size):
        super(ColumnLinearNet, self).__init__()
        self.parallel_linear = fleet.meta_parallel.ColumnParallelLinear(
            in_features=input_size,
            out_features=output_size,
            weight_attr=None,
            has_bias=True,
            gather_output=True,
            name="test_column_linear")

    def forward(self, x):
        output = self.parallel_linear(x)
        return output

strategy = fleet.DistributedStrategy()
strategy.sharding = True
strategy.sharding_configs = {
    "mp_degree": 2,
    "sharding_degree": 2,
}
fleet.init(is_collective=True, strategy=strategy)

input_size, output_size = 28, 64
model_a = ColumnLinearNet(input_size, output_size)

x = paddle.static.data(name='x', shape=[None, input_size])
y = model_a(x)

python -m paddle.distributed.launch --gpus 0,1,2,3 test.py

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@wangxicoding wangxicoding changed the title static support c_softmax_with_cross_entropy static support mp_layers Jun 22, 2021
Copy link
Member

@kuizhiqing kuizhiqing left a comment

Choose a reason for hiding this comment

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

lgtm for new group part

Copy link
Contributor

@JZ-LIANG JZ-LIANG left a comment

Choose a reason for hiding this comment

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

LGTM

# global group
global_rank = self.worker_index()
global_world_size = self.worker_num()
# NOTE(wangxi): see sharding_optimizer
Copy link
Contributor

Choose a reason for hiding this comment

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

or we could explain the parallel2id mapping here again?

Copy link
Contributor

Choose a reason for hiding this comment

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

    pre-assign ring ids
        mp: 0
        sharding: 1
        pure-dp: 2
        global: 3
        pp: >= 20
    if one parallelism is not enable: -1
    and only support parallelism hierarchy: mp --> sharding --> pp --> dp      

done

Copy link
Member

@ForFishes ForFishes left a comment

Choose a reason for hiding this comment

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

LGTM

@wangxicoding wangxicoding merged commit 91a0acd into PaddlePaddle:develop Jun 25, 2021
@wangxicoding wangxicoding deleted the static_c_cross_entorpy branch June 25, 2021 08:17
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