Skip to content

Commit

Permalink
add check if num layers is divisible by pp size (NVIDIA#9208) (NVIDIA…
Browse files Browse the repository at this point in the history
…#9298)

* add check if num_layers % pp == 0



* Apply isort and black reformatting



* move num_layers / pp check to build_transformer_config



---------

Signed-off-by: dimapihtar <[email protected]>
Signed-off-by: dimapihtar <[email protected]>
Co-authored-by: Dmytro Pykhtar <[email protected]>
Co-authored-by: dimapihtar <[email protected]>
Co-authored-by: Eric Harper <[email protected]>
  • Loading branch information
4 people authored Jun 6, 2024
1 parent 9e05062 commit bf6c1cc
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1990,6 +1990,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 bf6c1cc

Please sign in to comment.