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

support uneven split (#881) #884

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ppfleetx/models/language_model/gpt/dygraph/hybrid_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,12 +1066,16 @@ def _logits_helper(embedding, output):
"pp recompute interval should smaller than num layers of each pp chunk"
recompute_interval = pp_recompute_interval

seg_method = "layer:TransformerDecoderLayer"
if num_layers % fleet.get_hybrid_communicate_group().topology().get_dim_size("pipe") != 0:
seg_method = "uniform"

super().__init__(
layers=self.descs,
loss_fn=GPTPretrainingCriterionPipe(
sequence_parallel=sequence_parallel),
topology=fleet.get_hybrid_communicate_group().topology(),
seg_method="layer:TransformerDecoderLayer",
seg_method=seg_method,
recompute_interval=recompute_interval,
recompute_ctx={
"mp_group": fleet.fleet._hcg.get_model_parallel_group(),
Expand Down
16 changes: 11 additions & 5 deletions ppfleetx/models/language_model/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,17 @@ def process_model_configs(config):
virtual_pp_degree = configs['virtual_pp_degree']
num_layers = configs.num_layers

assert (num_layers %
(virtual_pp_degree * pp_degree)) == 0, \
"The num_layers of the model should be divisible of pp_degree * virtual_pp_degree." \
"Receive num_layers: {}, pp_degree: {}, virtual_pp_degree: {}.".format(
num_layers, pp_degree, virtual_pp_degree)
if not (num_layers % (virtual_pp_degree * pp_degree)) == 0:
assert virtual_pp_degree == 1, "virtual pp doesn't support uneven layer split."
logger.warning(
"The num_layers of the model is not divisible by pp_degree." \
"Receive num_layers: {}, pp_degree: {}.".format(num_layers, pp_degree))
else:
assert (num_layers %
(virtual_pp_degree * pp_degree)) == 0, \
"The num_layers of the model should be divisible of pp_degree * virtual_pp_degree." \
"Receive num_layers: {}, pp_degree: {}, virtual_pp_degree: {}.".format(
num_layers, pp_degree, virtual_pp_degree)

if virtual_pp_degree > 1:
local_batch_size = config.Global.local_batch_size
Expand Down