@@ -464,20 +464,28 @@ def _slice_embedding(child, name, conv_linear_layer):
464464
465465 def update_mp_params (child ):
466466 if hasattr (child , 'n_heads' ):
467+ assert child .n_heads % mp_size == 0 , "n_heads ({}) must be divisible by mp_size ({})" .format (child .n_heads , mp_size )
467468 child .n_heads = child .n_heads // mp_size
468469 if hasattr (child , 'inner_dim' ):
470+ assert child .inner_dim % mp_size == 0 , "inner_dim ({}) must be divisible by mp_size ({})" .format (child .inner_dim , mp_size )
469471 child .inner_dim = child .inner_dim // mp_size
470472 if hasattr (child , 'num_heads' ):
473+ assert child .num_heads % mp_size == 0 , "num_heads ({}) must be divisible by mp_size ({})" .format (child .num_heads , mp_size )
471474 child .num_heads = child .num_heads // mp_size
472475 if hasattr (child , 'num_attention_heads' ):
476+ assert child .num_attention_heads % mp_size == 0 , "num_attention_heads ({}) must be divisible by mp_size ({})" .format (child .num_attention_heads , mp_size )
473477 child .num_attention_heads = child .num_attention_heads // mp_size
474478 if hasattr (child , 'num_attn_heads' ):
479+ assert child .num_attn_heads % mp_size == 0 , "num_attn_heads ({}) must be divisible by mp_size ({})" .format (child .num_attn_heads , mp_size )
475480 child .num_attn_heads = child .num_attn_heads // mp_size
476481 if hasattr (child , 'all_head_size' ):
482+ assert child .all_head_size % mp_size == 0 , "all_head_size ({}) must be divisible by mp_size ({})" .format (child .all_head_size , mp_size )
477483 child .all_head_size = child .all_head_size // mp_size
478484 if hasattr (child , 'embed_dim' ):
485+ assert child .embed_dim % mp_size == 0 , "embed_dim must ({}) be divisible by mp_size ({})" .format (child .embed_dim , mp_size )
479486 child .embed_dim = child .embed_dim // mp_size
480487 if hasattr (child , 'hidden_size' ):
488+ assert child .hidden_size % mp_size == 0 , "hidden_size ({}) must be divisible by mp_size ({})" .format (child .hidden_size , mp_size )
481489 child .hidden_size = child .hidden_size // mp_size
482490
483491 conv_linear_layer = False
0 commit comments