fix: merge LoRA into refit weights under activation checkpointing - #3953
Open
anubhutivyas wants to merge 1 commit into
Open
fix: merge LoRA into refit weights under activation checkpointing#3953anubhutivyas wants to merge 1 commit into
anubhutivyas wants to merge 1 commit into
Conversation
Signed-off-by: anubhutiv <anubhutiv@nvidia.com>
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.
What does this PR do ?
Explained in very simple terms:
Context:
There are two copies of the model during training:
After every training step, the student's improvements get copied over to the writer, so the next batch of answers comes from a slightly better model. That copy step is called a refit.
LoRA means we don't change the original model at all. We freeze it and attach small adjustments on top. The real model = original + small adjustments.
So the refit has to do a bit of assembly: for each layer, find that layer's adjustments, add them onto the original weights, and send the sum to the writer. It finds those adjustments by the layer's name.
Bug:
Activation checkpointing is a memory-saving trick, it throws away intermediate results and recomputes them later. To do that it wraps each layer in a box. And that box changes the layer's name:
layers.0.up_projbecomeslayers.0._checkpoint_wrapped_module.up_projBut only in one of the two places the code looks. The list of weights still used the short name; the list of layers now used the long name. So the code searched for
layers.0.up_proj, found nothing and just shipped the original weights, with no adjustments.Issues
List issues that this PR closes (syntax):
Usage
# Add a code snippet demonstrating how to use thisBefore your PR is "Ready for review"
Pre checks:
Additional Information