@@ -69,11 +69,13 @@ def _transformer_config_from_args(
6969 args : argparse .Namespace , config_class : type [TransformerConfig ] = TransformerConfig
7070) -> TransformerConfig :
7171 """Build a variant of TransformerConfig based on contents of the MLM argparse args object."""
72- if args .multi_latent_attention :
72+ multi_latent_attention = getattr (args , "multi_latent_attention" , False )
73+ if multi_latent_attention :
7374 config_class = MLATransformerConfig
7475
75- if args .heterogeneous_layers_config_path is not None :
76- assert not args .multi_latent_attention , "Multi latent attention with heterogeneous layers is not supported."
76+ heterogeneous_layers_config_path = getattr (args , "heterogeneous_layers_config_path" , None )
77+ if heterogeneous_layers_config_path is not None :
78+ assert not multi_latent_attention , "Multi latent attention with heterogeneous layers is not supported."
7779 config_class = HeterogeneousTransformerConfig
7880
7981 # Translate args to core transformer configuration
@@ -90,10 +92,13 @@ def _transformer_config_from_args(
9092 kw_args ["pipeline_dtype" ] = args .params_dtype
9193 kw_args ["batch_p2p_comm" ] = not args .overlap_p2p_comm
9294 kw_args ["num_moe_experts" ] = args .num_experts
93- kw_args ["rotary_interleaved" ] = args .rotary_interleaved
94- kw_args ["num_layers_in_first_pipeline_stage" ] = args .decoder_first_pipeline_num_layers
95- kw_args ["num_layers_in_last_pipeline_stage" ] = args .decoder_last_pipeline_num_layers
96- kw_args ["fp8_param" ] = args .fp8_param_gather
95+ if hasattr (args , "decoder_first_pipeline_num_layers" ):
96+ kw_args ["num_layers_in_first_pipeline_stage" ] = args .decoder_first_pipeline_num_layers
97+ if hasattr (args , "decoder_last_pipeline_num_layers" ):
98+ kw_args ["num_layers_in_last_pipeline_stage" ] = args .decoder_last_pipeline_num_layers
99+ if hasattr (args , "fp8_param_gather" ):
100+ kw_args ["fp8_param" ] = args .fp8_param_gather
101+
97102 if args .swiglu :
98103 kw_args ["activation_func" ] = F .silu
99104 kw_args ["gated_linear_unit" ] = True
@@ -109,12 +114,10 @@ def _transformer_config_from_args(
109114 kw_args ["num_query_groups" ] = args .num_query_groups
110115 else :
111116 kw_args ["num_query_groups" ] = None
112- kw_args ["config_logger_dir" ] = args .config_logger_dir
113117
114- if len (args .cp_comm_type ) == 1 :
115- kw_args ["cp_comm_type" ] = args .cp_comm_type [0 ]
116- if args .is_hybrid_model :
117- kw_args ["is_hybrid_model" ] = args .is_hybrid_model
118+ cp_comm_type = getattr (args , "cp_comm_type" , ["p2p" ])
119+ if len (cp_comm_type ) == 1 :
120+ kw_args ["cp_comm_type" ] = cp_comm_type [0 ]
118121
119122 # handle quantization config
120123 # NOTE: Kitchen arguments are only added to the namespace when
0 commit comments