Repository navigation
fix(peft): keep adapter input gradient under sequence parallelism - #6491
Open
adityavavreNVDA wants to merge 1 commit into
Open
adityavavreNVDA wants to merge 1 commit into
adityavavreNVDA wants to merge 1 commit into
Conversation
Signed-off-by: adityavavreNVDA <avavre@nvidia.com>
3 of 4 tasks
This branch has not been deployed
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 ?
Fixes #6453: under sequence parallelism, adapters on
TELayerNormColumnParallelLinear(LoRA, DoRA, CanonicalLoRA) lost their part of the input gradient. This PR stops using TE's gathered LayerNorm output so the gradient is kept.Changelog
peft/utils.py:get_adapter_attributes_from_linearnow always setsreturn_layernorm_output_gathered = False. TE'sLayerNormLinearbackward drops the gradient of a gathered LayerNorm output, so the adapter's input-gradient term was never added.peft/utils.py: removed the block that setdisable_sequence_parallel_comm = True. The adapter now gets only its local slice of the sequence and does its own all-gather. In the backward pass, that gather sends the adapter's gradient back into the input gradient.peft/utils.py: removed thepackagingandimportlib.metadata.versionimports, which only that block used.peft/utils.py: added a docstring note thatsequence_parallel_input_regatherno longer changes this function's output. The argument is kept so existing callers don't break.peft/utils.py: added a TODO to bring back the gathered-output path once TE adds the missing gradient.tests/unit_tests/peft/test_utils.py: the default path now expectsreturn_layernorm_output_gathered=Falseanddisable_sequence_parallel_comm=False. Removed the TE version patch the test no longer needs.🤖 Generated with Claude Code