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

Merge the final LoRA finetuned checkpoint #1081

Merged
merged 12 commits into from
Mar 13, 2024
Merged

Conversation

awaelchli
Copy link
Contributor

Merges the final checkpoint saved by the lora.py finetuning script.

@awaelchli awaelchli added the enhancement New feature or request label Mar 11, 2024
@rasbt
Copy link
Collaborator

rasbt commented Mar 12, 2024

Nice! In this case, we can now also simplify the docs right? I.e., at https://github.com/Lightning-AI/litgpt/blob/wip/tutorials/finetune_lora.md#merging-lora-weights

@awaelchli
Copy link
Contributor Author

@rasbt Yes it's a nice improvement. But I need to be a bit careful here. Right now, merging a model requires it to fit into CPU RAM. For the 70B models, that could potentially be a problem on consumer hardware. I think it would be smarter to first implement sequential merging + sequential write (the latter we have already in LitGPT). That's why the PR is still in DRAFT.

Copy link
Contributor Author

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed my mind. I think it would be good and safe to do this because the manual merging logic is the same. I also used this branch in my finetuning Studio.

litgpt/chat/base.py Outdated Show resolved Hide resolved
litgpt/scripts/merge_lora.py Show resolved Hide resolved
@awaelchli awaelchli marked this pull request as ready for review March 13, 2024 16:12
@awaelchli
Copy link
Contributor Author

Nice! In this case, we can now also simplify the docs right? I.e., at wip/tutorials/finetune_lora.md#merging-lora-weights

@rasbt Yes. It would simplify in the sense that we could immediately suggest the user to run generate or chat.

litgpt/finetune/lora.py Outdated Show resolved Hide resolved
litgpt/chat/base.py Outdated Show resolved Hide resolved
@carmocca
Copy link
Contributor

It would simplify in the sense that we could immediately suggest the user to run generate or chat.

Do you want to do this in this PR?

@carmocca carmocca added this to the Configurability milestone Mar 13, 2024
@awaelchli
Copy link
Contributor Author

@rasbt I simplified the merging section based on the changes in this PR. Would you like to review it and edit if necessary?

litgpt/finetune/lora.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@rasbt rasbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice! Just a few minor suggestions below.

tutorials/finetune_lora.md Outdated Show resolved Hide resolved
tutorials/finetune_lora.md Show resolved Hide resolved
tutorials/finetune_lora.md Outdated Show resolved Hide resolved
tutorials/finetune_lora.md Outdated Show resolved Hide resolved
tutorials/finetune_lora.md Outdated Show resolved Hide resolved
@carmocca carmocca merged commit 1108eb5 into wip Mar 13, 2024
8 checks passed
@carmocca carmocca deleted the merge-finened-checkpoint branch March 13, 2024 23:25
@awaelchli awaelchli mentioned this pull request Mar 14, 2024
awaelchli added a commit that referenced this pull request Mar 15, 2024
Co-authored-by: Sebastian Raschka <[email protected]>
Co-authored-by: Carlos Mocholí <[email protected]>
awaelchli added a commit that referenced this pull request Mar 15, 2024
Co-authored-by: Sebastian Raschka <[email protected]>
Co-authored-by: Carlos Mocholí <[email protected]>
awaelchli added a commit that referenced this pull request Mar 15, 2024
Co-authored-by: Sebastian Raschka <[email protected]>
Co-authored-by: Carlos Mocholí <[email protected]>
rasbt added a commit that referenced this pull request Mar 18, 2024
Co-authored-by: Sebastian Raschka <[email protected]>
Co-authored-by: Carlos Mocholí <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants