Skip to content

Commit

Permalink
add check if num layers is divisible by pp size (#9208)
Browse files Browse the repository at this point in the history
* add check if num_layers % pp == 0

Signed-off-by: dimapihtar <[email protected]>

* Apply isort and black reformatting

Signed-off-by: dimapihtar <[email protected]>

* move num_layers / pp check to build_transformer_config

Signed-off-by: dimapihtar <[email protected]>

---------

Signed-off-by: dimapihtar <[email protected]>
Signed-off-by: dimapihtar <[email protected]>
Co-authored-by: dimapihtar <[email protected]>
  • Loading branch information
2 people authored and web-flow committed May 23, 2024
1 parent a589828 commit 397985f
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1987,6 +1987,12 @@ def build_transformer_config(self) -> TransformerConfig:
For attributes in TransformerConfig that are not in the nemo model config, we add custom logic.
"""

if self.cfg.num_layers % self.cfg.get('pipeline_model_parallel_size', 1) != 0:
raise ValueError(
f"num_layers ({self.cfg.num_layers}) should be divisible by "
f"pipeline_model_parallel_size ({self.cfg.get('pipeline_model_parallel_size', 1)})"
)

normalization = self.cfg.get('normalization', 'layernorm').lower()
layernorm_zero_centered_gamma = self.cfg.get('normalization', 'layernorm') == 'layernorm1p'
if normalization == 'layernorm':
Expand Down

0 comments on commit 397985f

Please sign in to comment.