Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions nemo_rl/models/megatron/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def _pack_sequences_for_megatron(

# Round up the pad_packed_seq_to to the nearest multiple of pad_packed_seq_to_multiple_of
if pad_packed_seq_to is not None:
pad_packed_seq_to = _round_up_to_multiple(
pad_packed_seq_to, pad_packed_seq_to_multiple_of
assert pad_packed_seq_to % pad_packed_seq_to_multiple_of == 0, (
f"pad_packed_seq_to ({pad_packed_seq_to}) is not a multiple of pad_packed_seq_to_multiple_of ({pad_packed_seq_to_multiple_of})."
)

pad_factor = pad_individual_seqs_to_multiple_of
Expand Down Expand Up @@ -275,6 +275,12 @@ def _get_pack_sequence_parameters_for_megatron(
else:
pad_packed_seq_to = None

# make sure the pad_packed_seq_to is a multiple of the pad_packed_seq_to_multiple_of
if pad_packed_seq_to is not None:
pad_packed_seq_to = _round_up_to_multiple(
pad_packed_seq_to, pad_packed_seq_to_multiple_of
)

return (
pad_individual_seqs_to_multiple_of,
pad_packed_seq_to_multiple_of,
Expand Down
2 changes: 2 additions & 0 deletions nemo_rl/models/policy/megatron_policy_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,8 @@ def train(
self.cfg["megatron_cfg"],
seq_dim_size,
)
# if pad_full_seq_to is not None, we need to use it as the sequence length
seq_dim_size = pad_full_seq_to or seq_dim_size
else:
data_iterator = batch.make_microbatch_iterator(mbs)
data_iterator_len = local_gbs // mbs
Expand Down
Loading