@@ -242,124 +242,123 @@ def test_pretrain_with_independent_eval_batch_size(self, tmp_path):
242242
243243 torch .distributed .barrier ()
244244
245- try :
246- global_batch_size = 8
247- micro_batch_size = 1
248- eval_global_batch_size = 4
249- eval_micro_batch_size = 2
250- seq_length = 512
251- total_iters = 10
252-
253- model_cfg = GPTModelProvider (
254- normalization = "RMSNorm" ,
255- activation_func = F .silu ,
256- gated_linear_unit = True ,
257- position_embedding_type = "rope" ,
258- add_bias_linear = False ,
259- attention_dropout = 0.0 ,
260- hidden_dropout = 0.0 ,
261- bias_activation_fusion = True ,
262- masked_softmax_fusion = True ,
263- persist_layer_norm = True ,
264- bias_dropout_fusion = True ,
265- apply_rope_fusion = True ,
266- num_query_groups = 8 ,
267- init_method_std = 0.02 ,
268- layernorm_epsilon = 1e-05 ,
269- rotary_percent = 1.0 ,
270- rope_scaling = True ,
271- rope_scaling_factor = 32.0 ,
272- share_embeddings_and_output_weights = True ,
273- rotary_base = 500_000 ,
274- hidden_size = 2048 ,
275- ffn_hidden_size = 8192 ,
276- num_attention_heads = 32 ,
277- tensor_model_parallel_size = 1 ,
278- pipeline_model_parallel_size = 1 ,
279- context_parallel_size = 1 ,
280- sequence_parallel = False ,
281- attention_softmax_in_fp32 = True ,
282- pipeline_dtype = torch .bfloat16 ,
245+ global_batch_size = 8
246+ micro_batch_size = 1
247+ eval_global_batch_size = 4
248+ eval_micro_batch_size = 2
249+ seq_length = 512
250+ total_iters = 10
251+
252+ model_cfg = GPTModelProvider (
253+ normalization = "RMSNorm" ,
254+ activation_func = F .silu ,
255+ gated_linear_unit = True ,
256+ position_embedding_type = "rope" ,
257+ add_bias_linear = False ,
258+ attention_dropout = 0.0 ,
259+ hidden_dropout = 0.0 ,
260+ bias_activation_fusion = True ,
261+ masked_softmax_fusion = True ,
262+ persist_layer_norm = True ,
263+ bias_dropout_fusion = True ,
264+ apply_rope_fusion = True ,
265+ num_query_groups = 8 ,
266+ init_method_std = 0.02 ,
267+ layernorm_epsilon = 1e-05 ,
268+ rotary_percent = 1.0 ,
269+ rope_scaling = True ,
270+ rope_scaling_factor = 32.0 ,
271+ share_embeddings_and_output_weights = True ,
272+ rotary_base = 500_000 ,
273+ hidden_size = 2048 ,
274+ ffn_hidden_size = 8192 ,
275+ num_attention_heads = 32 ,
276+ tensor_model_parallel_size = 1 ,
277+ pipeline_model_parallel_size = 1 ,
278+ context_parallel_size = 1 ,
279+ sequence_parallel = False ,
280+ attention_softmax_in_fp32 = True ,
281+ pipeline_dtype = torch .bfloat16 ,
282+ bf16 = True ,
283+ seq_length = seq_length ,
284+ make_vocab_size_divisible_by = 128 ,
285+ vocab_size = None ,
286+ num_layers = 1 ,
287+ )
288+
289+ cfg = ConfigContainer (
290+ model = model_cfg ,
291+ train = TrainingConfig (
292+ train_iters = total_iters ,
293+ global_batch_size = global_batch_size ,
294+ micro_batch_size = micro_batch_size ,
295+ exit_signal_handler = True ,
296+ ),
297+ validation = ValidationConfig (
298+ eval_interval = 5 ,
299+ eval_iters = 2 ,
300+ eval_global_batch_size = eval_global_batch_size ,
301+ eval_micro_batch_size = eval_micro_batch_size ,
302+ ),
303+ optimizer = OptimizerConfig (
304+ optimizer = "adam" ,
283305 bf16 = True ,
306+ fp16 = False ,
307+ adam_beta1 = 0.9 ,
308+ adam_beta2 = 0.95 ,
309+ adam_eps = 1e-8 ,
310+ use_distributed_optimizer = True ,
311+ clip_grad = 1.0 ,
312+ lr = 3e-3 ,
313+ weight_decay = 0.01 ,
314+ min_lr = 1e-6 ,
315+ ),
316+ scheduler = SchedulerConfig (
317+ start_weight_decay = 0.033 ,
318+ end_weight_decay = 0.033 ,
319+ weight_decay_incr_style = "constant" ,
320+ lr_decay_style = "cosine" ,
321+ lr_warmup_iters = 2 ,
322+ lr_warmup_init = 0.0 ,
323+ lr_decay_iters = total_iters ,
324+ override_opt_param_scheduler = True ,
325+ ),
326+ ddp = DistributedDataParallelConfig (
327+ check_for_nan_in_grad = True ,
328+ grad_reduce_in_fp32 = True ,
329+ overlap_grad_reduce = True ,
330+ overlap_param_gather = True ,
331+ average_in_collective = True ,
332+ use_distributed_optimizer = True ,
333+ ),
334+ dataset = MockGPTDatasetConfig (
335+ random_seed = 1234 ,
336+ reset_attention_mask = False ,
337+ reset_position_ids = False ,
338+ eod_mask_loss = False ,
284339 seq_length = seq_length ,
285- make_vocab_size_divisible_by = 128 ,
286- vocab_size = None ,
287- num_layers = 1 ,
288- )
289-
290- cfg = ConfigContainer (
291- model = model_cfg ,
292- train = TrainingConfig (
293- train_iters = total_iters ,
294- global_batch_size = global_batch_size ,
295- micro_batch_size = micro_batch_size ,
296- exit_signal_handler = True ,
297- ),
298- validation = ValidationConfig (
299- eval_interval = 5 ,
300- eval_iters = 2 ,
301- eval_global_batch_size = eval_global_batch_size ,
302- eval_micro_batch_size = eval_micro_batch_size ,
303- ),
304- optimizer = OptimizerConfig (
305- optimizer = "adam" ,
306- bf16 = True ,
307- fp16 = False ,
308- adam_beta1 = 0.9 ,
309- adam_beta2 = 0.95 ,
310- adam_eps = 1e-8 ,
311- use_distributed_optimizer = True ,
312- clip_grad = 1.0 ,
313- lr = 3e-3 ,
314- weight_decay = 0.01 ,
315- min_lr = 1e-6 ,
316- ),
317- scheduler = SchedulerConfig (
318- start_weight_decay = 0.033 ,
319- end_weight_decay = 0.033 ,
320- weight_decay_incr_style = "constant" ,
321- lr_decay_style = "cosine" ,
322- lr_warmup_iters = 2 ,
323- lr_warmup_init = 0.0 ,
324- lr_decay_iters = total_iters ,
325- override_opt_param_scheduler = True ,
326- ),
327- ddp = DistributedDataParallelConfig (
328- check_for_nan_in_grad = True ,
329- grad_reduce_in_fp32 = True ,
330- overlap_grad_reduce = True ,
331- overlap_param_gather = True ,
332- average_in_collective = True ,
333- use_distributed_optimizer = True ,
334- ),
335- dataset = MockGPTDatasetConfig (
336- random_seed = 1234 ,
337- reset_attention_mask = False ,
338- reset_position_ids = False ,
339- eod_mask_loss = False ,
340- seq_length = seq_length ,
341- num_dataset_builder_threads = 1 ,
342- data_sharding = True ,
343- dataloader_type = "single" ,
344- num_workers = 1 ,
345- ),
346- logger = LoggerConfig (
347- log_interval = 5 ,
348- tensorboard_dir = tensorboard_dir ,
349- ),
350- tokenizer = TokenizerConfig (
351- tokenizer_type = "NullTokenizer" ,
352- vocab_size = 10000 ,
353- ),
354- checkpoint = CheckpointConfig (
355- ckpt_format = "torch_dist" ,
356- ),
357- rng = RNGConfig (seed = 1234 ),
358- )
359-
360- # Run training — eval runs at iter 5 and 10 with independent batch sizes
340+ num_dataset_builder_threads = 1 ,
341+ data_sharding = True ,
342+ dataloader_type = "single" ,
343+ num_workers = 1 ,
344+ ),
345+ logger = LoggerConfig (
346+ log_interval = 5 ,
347+ tensorboard_dir = tensorboard_dir ,
348+ ),
349+ tokenizer = TokenizerConfig (
350+ tokenizer_type = "NullTokenizer" ,
351+ vocab_size = 10000 ,
352+ ),
353+ checkpoint = CheckpointConfig (
354+ ckpt_format = "torch_dist" ,
355+ ),
356+ rng = RNGConfig (seed = 1234 ),
357+ )
358+
359+ # Run training — eval runs at iter 5 and 10 with independent batch sizes
360+ try :
361361 pretrain (cfg , forward_step )
362-
363362 finally :
364363 clear_directories (tmp_path )
365364
0 commit comments