Add prompt-learning guard for PEFT with Liger in GRPO#6186
Open
albertvillanova wants to merge 2 commits into
Open
Add prompt-learning guard for PEFT with Liger in GRPO#6186albertvillanova wants to merge 2 commits into
albertvillanova wants to merge 2 commits into
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
Add prompt-learning guard for PEFT with Liger in GRPO.
Follow-up to:
This PR improves the handling of prompt-learning PEFT methods (like PromptTuning, PrefixTuning, and P-Tuning) in the
GRPOTrainerwhen using the Liger kernel. It adds a check to prevent incompatible configurations that would otherwise silently produce incorrect training behavior, and introduces a corresponding test to ensure this error is raised.Motivation
GRPO unwraps PEFT models and bypasses PeftModel.forward(), so it is silently broken for prompt-learning PEFT with Liger.
Prompt-learning PEFT methods (Prompt/Prefix/P-tuning) rely on PeftModel.forward() to prepend virtual tokens, so with use_liger_kernel=True they would silently compute the loss on the wrong sequence (virtual tokens not injected). This should be rejected at init time to avoid incorrect training.
Changes
Compatibility checks and error handling:
GRPOTrainerinitializer to raise aValueErrorif a prompt-learning PEFT method is used withuse_liger_kernel=True, preventing silent training on corrupted input sequences.PromptLearningConfigto support the compatibility check.Testing:
test_liger_kernel_with_peft_prompt_learning_raises) to verify that using prompt-learning PEFT methods with the Liger kernel raises the expected error.PromptTuningConfigandTaskTypeto support the new test.Note
Low Risk
Init-time configuration validation only; no change to the training path for supported LoRA + Liger setups.
Overview
GRPOTrainernow fails at init whenuse_liger_kernel=Trueis combined with prompt-learning PEFT (Prompt Tuning, Prefix Tuning, P-Tuning). The check usesPromptLearningConfigon the model’s PEFT configs and raises aValueErrorthat points users to LoRA or disabling Liger.This matches the existing lm_head + Liger guard: the fused Liger GRPO path calls the backbone directly and skips
PeftModel.forward(), so virtual tokens never get prepended and training would silently use the wrong sequence.A regression test
test_liger_kernel_with_peft_prompt_learning_raisesasserts thatPromptTuningConfigwith Liger raises with aprompt-learningmessage.Reviewed by Cursor Bugbot for commit ce6f99c. Bugbot is set up for automated code reviews on this repo. Configure here.