Skip to content

FIX Mixed: honor bias='<prefix>_only' for all compatible tuners (not just lora_only)#3366

Merged
BenjaminBossan merged 1 commit into
huggingface:mainfrom
DaoyuanLi2816:fix/mixed-bias-endswith-only
Jun 29, 2026
Merged

FIX Mixed: honor bias='<prefix>_only' for all compatible tuners (not just lora_only)#3366
BenjaminBossan merged 1 commit into
huggingface:mainfrom
DaoyuanLi2816:fix/mixed-bias-endswith-only

Conversation

@DaoyuanLi2816

Copy link
Copy Markdown
Contributor

What does this PR do?

PeftMixedModel's _mark_only_adapters_as_trainable hardcodes bias == "lora_only":

elif bias == "lora_only":
    ...
else:
    raise ValueError(f"Requested bias: {bias}, is not implemented.")

But MixedModel.COMPATIBLE_TUNER_TYPES includes OFT, and OFTConfig accepts bias="oft_only" (a valid Literal["none", "all", "oft_only"]). So a mixed model with an OFT adapter and bias="oft_only" raises ValueError: 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 Layers instance trainable, not just LoRA — so only the guard was too narrow. This aligns it with BaseTuner._mark_only_adapters_as_trainable, which uses bias.endswith("_only") (and removes the now-resolved # TODO: check if this is needed for other supported types).

How it was verified

  • Repro (CPU): a SimpleNet mixed model with OFTConfig(target_modules=["lin1"], oft_block_size=8, bias="oft_only") raises the ValueError on main and trains its bias after the fix; standalone OFT with the same config already works.
  • Added test_bias_only_honored_for_non_lora_tuner — it fails on main with the ValueError above and passes with this change.
  • tests/test_mixed.py passes (33 passed); ruff check / ruff format --check clean.

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.

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').
@HuggingFaceDocBuilderDev

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.

@BenjaminBossan BenjaminBossan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. LGTM.

@BenjaminBossan BenjaminBossan merged commit c9335b7 into huggingface:main Jun 29, 2026
9 of 10 checks passed
@DaoyuanLi2816 DaoyuanLi2816 deleted the fix/mixed-bias-endswith-only branch July 1, 2026 21:37
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.

3 participants