Skip to content

Fix OSF merge applying the delta twice on repeated merge - #3886

Merged
githubnemo merged 1 commit into
huggingface:mainfrom
adi-IL:bot/peft-3825
Oct 12, 2026
Merged

githubnemo merged 1 commit into
huggingface:mainfrom
adi-IL:bot/peft-3825

Conversation

@adi-IL

@adi-IL adi-IL commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #3825.

OSFLayer.merge() did not call check_adapters_to_merge(). Calling merge() twice applied the OSF delta a second time and listed the adapter twice in merged_adapters.

This change runs merge() through check_adapters_to_merge(), so an adapter that is already merged is skipped.

Testing:

  • New merge-twice test in tests/test_osf.py. Without the layer.py change the weight moves by 0.50 on the second merge and merged_adapters is ['default', 'default']. With the change the weight is unchanged and merged_adapters is ['default'].
  • All 5 tests in tests/test_osf.py and the 91 OSF cases in tests/test_custom_models.py pass locally. Ruff is clean.

@githubnemo githubnemo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR.

LGTM, let's see what the CI says.

@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.

@githubnemo
githubnemo merged commit 8314d7c into huggingface:main Oct 12, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OSFLayer.merge() skips check_adapters_to_merge(), double-applies the delta on re-merge

3 participants