Skip to content

Commit

Permalink
dpo pad fix if none
Browse files Browse the repository at this point in the history
Signed-off-by: Terry Kong <[email protected]>
  • Loading branch information
terrykong committed Nov 7, 2024
1 parent b9cf184 commit e3c9c88
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nemo_aligner/algorithms/dpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def dpo_custom_collate(
This collate happens outside of the torch data loader and is not compatible with the multiprocessing
logic due to requiring communication collectives.
"""
assert pad_length_to_multiple_of >= 0, f"{pad_length_to_multiple_of=} must be >=0"
if pad_length_to_multiple_of is not None and pad_length_to_multiple_of < 0:
raise ValueError(f"{pad_length_to_multiple_of=} must be >= 0")
chosen_tokens = [item["chosen"] for item in batch]
rejected_tokens = [item["rejected"] for item in batch]
chosen_lengths = torch.LongTensor([item["chosen_length"] for item in batch])
Expand Down

0 comments on commit e3c9c88

Please sign in to comment.