Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default Lora/ (IA)^3 scaling in forward #770

Merged
merged 9 commits into from
Dec 29, 2024

Conversation

calpt
Copy link
Member

@calpt calpt commented Dec 22, 2024

Resolves issue described in #760.

IMPORTANT: this fix restores weights compatibility with adapter-transformers. Compatibility to previous adapters versions is kept via a compat patch.

Details

The current implementation of LoRA/ (IA)^3 in adapters versions < 1.1.0 does not correctly implement adapter states scaling via the LoRA alpha attribute, effectively ignoring alpha and always applying a scaling of 1.0.
This PR restores the correct original behavior as found in adapter-transformers/ original LoRA implementation.

As this change breaks all adapters pre-trained using adapters versions 0.1.0 - 1.0.1, a backward compatibility patch is introduced that automatically sets alpha = r for LoRAs for adapters that were trained using affected versions. This ensures all previous adapters continue to behave exactly as trained (ie give the exact same output using newer versions).

@calpt calpt linked an issue Dec 22, 2024 that may be closed by this pull request
4 tasks
@calpt calpt marked this pull request as ready for review December 23, 2024 11:18
@calpt calpt mentioned this pull request Dec 23, 2024
julian-fong added a commit to julian-fong/adapters that referenced this pull request Dec 24, 2024
Copy link
Contributor

@TimoImhof TimoImhof left a comment

Choose a reason for hiding this comment

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

Thank you for working on this!
This looks good to me, I only provided some minor suggestions that could be included.

src/adapters/loading.py Outdated Show resolved Hide resolved
src/adapters/loading.py Outdated Show resolved Hide resolved
@calpt calpt merged commit f0ca962 into adapter-hub:main Dec 29, 2024
3 of 4 checks passed
@calpt calpt deleted the fix/lora_scaling branch December 29, 2024 23:12
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.

Different outputs when upgrading from adapter-transformers with LoRA
2 participants