FIX Mixed: honor bias='<prefix>_only' for all compatible tuners (not just lora_only)#3366
Merged
BenjaminBossan merged 1 commit intoJun 29, 2026
Conversation
PeftMixedModel._mark_only_adapters_as_trainable hardcoded bias == 'lora_only'
and raised 'Requested bias: <x>, is not implemented.' for any other value. But
MixedModel.COMPATIBLE_TUNER_TYPES includes OFT, and OFTConfig accepts
bias='oft_only', so a mixed OFT adapter with bias='oft_only' crashed even though
standalone OFT supports it. The branch body is already generic (marks the bias of
every compatible Layers instance), so only the guard was wrong; align it with
BaseTuner._mark_only_adapters_as_trainable which uses bias.endswith('_only').
|
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.
What does this PR do?
PeftMixedModel's_mark_only_adapters_as_trainablehardcodesbias == "lora_only":But
MixedModel.COMPATIBLE_TUNER_TYPESincludes OFT, andOFTConfigacceptsbias="oft_only"(a validLiteral["none", "all", "oft_only"]). So a mixed model with an OFT adapter andbias="oft_only"raisesValueError: Requested bias: oft_only, is not implemented., even though the identical config trains fine in a standalone OFT model.The body of that branch is already generic — it marks the bias of every compatible
Layersinstance trainable, not just LoRA — so only the guard was too narrow. This aligns it withBaseTuner._mark_only_adapters_as_trainable, which usesbias.endswith("_only")(and removes the now-resolved# TODO: check if this is needed for other supported types).How it was verified
SimpleNetmixed model withOFTConfig(target_modules=["lin1"], oft_block_size=8, bias="oft_only")raises theValueErroronmainand trains its bias after the fix; standalone OFT with the same config already works.test_bias_only_honored_for_non_lora_tuner— it fails onmainwith theValueErrorabove and passes with this change.tests/test_mixed.pypasses (33 passed);ruff check/ruff format --checkclean.AI assistance
AI assistance was used to prepare this change. I reviewed every changed line, verified the behavior as described above, and take responsibility for the patch.