Skip to content

Add prompt-learning guard for PEFT with Liger in GRPO#6186

Open
albertvillanova wants to merge 2 commits into
mainfrom
fu-6159
Open

Add prompt-learning guard for PEFT with Liger in GRPO#6186
albertvillanova wants to merge 2 commits into
mainfrom
fu-6159

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Jun 26, 2026

Copy link
Copy Markdown
Member

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 GRPOTrainer when 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:

  • Added a check in the GRPOTrainer initializer to raise a ValueError if a prompt-learning PEFT method is used with use_liger_kernel=True, preventing silent training on corrupted input sequences.
  • Imported PromptLearningConfig to support the compatibility check.

Testing:

  • Added a test (test_liger_kernel_with_peft_prompt_learning_raises) to verify that using prompt-learning PEFT methods with the Liger kernel raises the expected error.
  • Imported PromptTuningConfig and TaskType to support the new test.

Note

Low Risk
Init-time configuration validation only; no change to the training path for supported LoRA + Liger setups.

Overview
GRPOTrainer now fails at init when use_liger_kernel=True is combined with prompt-learning PEFT (Prompt Tuning, Prefix Tuning, P-Tuning). The check uses PromptLearningConfig on the model’s PEFT configs and raises a ValueError that 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_raises asserts that PromptTuningConfig with Liger raises with a prompt-learning message.

Reviewed by Cursor Bugbot for commit ce6f99c. Bugbot is set up for automated code reviews on this repo. Configure here.

@bot-ci-comment

Copy link
Copy Markdown

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.

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

Successfully merging this pull request may close these issues.

1 participant