KTO changes to return aux outputs#589
Merged
Merged
Conversation
5 tasks
Collaborator
Author
|
@shivam15s @hebiao064 @kashif this PR contains the changes needed for trl integration. PTAL, thanks! |
Contributor
|
Can you run a benchmark to see if the memory/speed still performs at certain level? |
Collaborator
Author
Sure, will add it. |
shivam15s
reviewed
Feb 28, 2025
Comment on lines
+342
to
+343
| chosen_logits_sum = chosen_logits.nansum() | ||
| rejected_logits_sum = rejected_logits.nansum() |
Collaborator
There was a problem hiding this comment.
do you expect these to have nans?
Collaborator
Author
There was a problem hiding this comment.
I was a bit unsure about this as TRL is using nansum() for this: https://github.com/huggingface/trl/blob/491921c1a4167e7c84429382470b0bb3158e66b0/trl/trainer/kto_trainer.py#L1271. Thus kept the nansum() to deal with the worst case.
shivam15s
approved these changes
Feb 28, 2025
shivam15s
left a comment
Collaborator
There was a problem hiding this comment.
lgtm, lets figure out the speed drop in the next PR
hebiao064
approved these changes
Mar 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces the following changes to enable integration with huggingface TRL:
Details
Benchmark results with the new implementation:


Testing Done
make testto ensure correctnessmake checkstyleto ensure code stylemake test-convergenceto ensure convergence