# TODO it might make sense to support non-moe with tp on but moe with tp off
raiseValueError(
f"if ddp is used, dp_group and moe_dp_group are expected to be the same since DDP can only reduce grad across a single group, but found dp_group {dist.get_process_group_ranks(self.dp_group)} and moe_dp_group {dist.get_process_group_ranks(self.moe_dp_group)}, you might want to set ep_size=1 or zero_stage > 0"
f"if ddp is used, dp_group and moe_dp_group are expected to be the same since DDP can only reduce grad across a single group, but found dp_group {dist.get_process_group_ranks(self.dp_group)} and moe_dp_group {dist.get_process_group_ranks(self.moe_dp_group)}, you might want to use HybridParallelPlugin or set zero_stage > 0"
)
# set ep_group after super().__init__()
# TODO do it in a better way
# set param group in shard config
self.shard_config.ep_group=self.ep_group
self.shard_config.moe_dp_group=self.moe_dp_group
self.shard_config.moe_tp_group=self.moe_tp_group
@ -149,9 +152,10 @@ class MoeHybridParallelPlugin(HybridParallelPlugin):
# when sequence parallelism is enabled, ep_group reuses sp_group
ifself.ep_size!=self.sp_size:
raiseValueError(
f"ep_size={self.ep_size} should be equal to sp_size={self.sp_size} when sequence parallelism is enabled"
f"ep_size={self.ep_size} should be equal to sp_size={self.sp_size}or turned off when sequence parallelism is enabled"
)
# since we are reusing sp_group, moe_dp_group will be derived as dp_group
self.moe_dp_size=self.dp_size
self.moe_dp_group=self.dp_group# NOTE: sequence of value assignment matters
f"world_size={world_size} is not divisible by pp_size={self.pp_size} * moe_dp_size={self.moe_dp_size} * ep_size={self.ep_size} * moe_tp_size={self.moe_tp_size}"
)
@ -214,8 +218,8 @@ class MoeHybridParallelPlugin(HybridParallelPlugin):
# NOTE: different tp settings between moe and non moe param require complex comm logic, where all_to_all might not be suitable
# this assertion implies that dp_size == moe_dp_size * ep_size
# NOTE: different tp settings between moe and non moe param are complex to handle
# we simply reuse tp_group as moe_tp_group, this implies that dp_size == moe_dp_size * ep_size
raiseNotImplementedError(
f"Only support shared tp group between moe and non moe params, but found non-moe tp {dist.get_process_group_ranks(self.tp_group)}, moe tp {dist.get_process_group_ranks(self.moe_tp_group)}, please make sure tp_size == moe_tp_size"