Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompute DPO logprobs #213

Open
natolambert opened this issue Jul 30, 2024 · 2 comments
Open

Precompute DPO logprobs #213

natolambert opened this issue Jul 30, 2024 · 2 comments

Comments

@natolambert
Copy link
Collaborator

To save compute.
Another hard issue :)

@natolambert
Copy link
Collaborator Author

natolambert commented Aug 1, 2024

A sketch of how this could work.

Add an option in dpo_tune where instead of using concatenated_forward, we run just forward for each with an optional save of the logprobs.

for epoch in range(starting_epoch, args.num_train_epochs):

Then, you iterate over batches and compute loss and update the model.

Optional: logic to move one model into cuda at a time. Shouldn't be too hard.

@hamishivi
Copy link
Collaborator

Yeah, sounds about right. It's very easy to implement, I did it in EasyLM (although sharding issues mean its broken), but the logic should be right: https://github.com/hamishivi/EasyLM/blob/main/EasyLM/models/llama/llama_train_dpo.py#L372-L400

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants