Fix PEFT ensure_weight_tying warning in liger + PEFT GRPO tests#6188
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 402bfcf. Configure here.
|
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.

This PR fixes two UserWarnings emitted by PEFT in CI when running the liger + PEFT tests in test_grpo_trainer.py.
Motivation
PEFT ≥ 0.18.0 warns when a model with tie_word_embeddings=True has a tied layer (e.g. lm_head) included in the adapter via modules_to_save or target_modules, but ensure_weight_tying is not set to True on the LoraConfig. Both affected tests deliberately include lm_head in the adapter config on a model with tied embeddings, so the warning fires as a side effect.
Solution
For PEFT ≥ 0.18.0 (modules_to_save case) and ≥ 0.19.0 (target_modules case), pass ensure_weight_tying=True to LoraConfig to suppress the warning at the source. For older PEFT versions that predate the flag, fall back to pytest.warns to explicitly acknowledge the expected warning.
Changes
Updated tests to handle PEFT version differences by conditionally setting
ensure_weight_tyingand usingcontextlib.nullcontext()orpytest.warnsas appropriate, ensuring correct handling of warnings and errors across PEFT versions:Note
Low Risk
Test-only changes to LoRA config setup; no production trainer or library logic is modified.
Overview
Silences PEFT weight-tying
UserWarnings in CI for two existing Liger + PEFT GRPO tests that intentionally putlm_headin the adapter on tied-embedding models.Adds
import peft(behindis_peft_available()) and buildsLoraConfigwithensure_weight_tying=Truewhenpeft >= 0.19.0intest_liger_kernel_with_peft_lm_head_raisesandtest_liger_kernel_with_peft_modules_to_save_lm_head_allowed. Test behavior (expectedValueErrorvs successful construction) is unchanged.Reviewed by Cursor Bugbot for commit 80ac694. Bugbot is set up for automated code reviews on this repo. Configure here.