Skip to content

Commit 669e0f3

Browse files
committed
need mopdify dataiterator_wrapper UT
Signed-off-by: tailaim <tailaim@nvidia.com>
1 parent fdcd250 commit 669e0f3

File tree

4 files changed

+291
-100
lines changed

4 files changed

+291
-100
lines changed

megatron/core/datasets/data_schedule.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,8 @@ def check_require_sample_keys(self, batch: List[Dict]):
11081108
# we only fetch it once, rather than iterating num_micro_batches times.
11091109
for key in required_keys:
11101110
if key not in batch[0]:
1111+
#debugmtl
1112+
print(f"key {key} not in batch[0]: {batch[0]}")
11111113
return False
11121114
return True
11131115

megatron/core/pipeline_parallel/schedules.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@ def wrap_iterator_helper(
520520
):
521521
"""Warp data iterator for sequence packing if needed."""
522522
if config.sequence_packing:
523-
num_total_tokens_this_global_batch, sequence_square_sum_this_global_batch = None, None
524523
scheduler_type_map = {
525524
'default_hybrid_cp': PackingScheduler.DEFAULT_HYBRID_CP,
526525
'empty_scheduler_with_packing': PackingScheduler.EMPTY_PACKING,
@@ -707,7 +706,7 @@ def forward_backward_no_pipelining(
707706
):
708707
create_cudagraphs()
709708

710-
if config.sequence_packing:
709+
if config.sequence_packing and not forward_only:
711710
forward_data_store.append(
712711
[num_total_tokens_this_global_batch, sequence_square_sum_this_global_batch]
713712
)
@@ -2091,7 +2090,7 @@ def pp_post_backward(input_tensor_grad, vp_stage=None):
20912090
create_cudagraphs()
20922091
nvtx_range_pop(suffix="misc")
20932092

2094-
if config.sequence_packing:
2093+
if config.sequence_packing and not forward_only:
20952094
forward_data_store.append(
20962095
[num_total_tokens_this_global_batch, sequence_square_sum_this_global_batch]
20972096
)
@@ -2489,7 +2488,7 @@ def enable_grad_sync():
24892488
):
24902489
create_cudagraphs()
24912490

2492-
if config.sequence_packing:
2491+
if config.sequence_packing and not forward_only:
24932492
forward_data_store.append(
24942493
[num_total_tokens_this_global_batch, sequence_square_sum_this_global_batch]
24952494
)

megatron/training/training.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,10 +2839,6 @@ def evaluate(
28392839
decoder_seq_length=args.decoder_seq_length,
28402840
forward_only=True,
28412841
)
2842-
if args.sequence_packing:
2843-
# need to drop first two elements which are total_num_tokens and
2844-
# total_sequence_square_sum
2845-
loss_dicts = loss_dicts[2:]
28462842
ft_integration.on_eval_step_end()
28472843
config.timers = get_timers()
28482844

0 commit comments

Comments
 (0)