Skip to content

fix: add support for init_lora_weights="corda" in get_peft_model#3794

Merged
danielhanchen merged 1 commit into
unslothai:mainfrom
majiayu000:fix/corda-support
Dec 29, 2025
Merged

fix: add support for init_lora_weights="corda" in get_peft_model#3794
danielhanchen merged 1 commit into
unslothai:mainfrom
majiayu000:fix/corda-support

Conversation

@majiayu000
Copy link
Copy Markdown
Contributor

Summary

Add "corda" as an allowed value for the init_lora_weights parameter in FastLanguageModel.get_peft_model() and FastBaseModel.get_peft_model().

This enables users to use CorDA (Correlation-aware Decomposed Adaptation) initialization from PEFT, which provides an alternative LoRA initialization strategy for improved finetuning performance.

Reference: https://github.com/huggingface/peft/tree/main/examples/corda_finetuning

Changes

  • Updated unsloth/models/llama.py to accept init_lora_weights="corda"
  • Updated unsloth/models/_utils.py to accept init_lora_weights="corda"

Usage

After this fix, users can use CorDA initialization like this:

from peft import CordaConfig

corda_config = CordaConfig(corda_method="kpm")

model = FastLanguageModel.get_peft_model(
    model,
    init_lora_weights="corda",
    corda_config=corda_config,
    # other params...
)

Test Plan

  • Python syntax check passes for all modified files

Fixes #3693

Add "corda" as an allowed value for the init_lora_weights parameter
in FastLanguageModel.get_peft_model() and FastBaseModel.get_peft_model().

This enables users to use CorDA (Correlation-aware Decomposed Adaptation)
initialization from PEFT, which provides an alternative LoRA initialization
strategy for improved finetuning performance.

Fixes unslothai#3693

Signed-off-by: majiayu000 <1835304752@qq.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @majiayu000, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates support for CorDA initialization within the Unsloth framework's PEFT model acquisition functions. By allowing 'corda' as an init_lora_weights option, users can now leverage an advanced initialization technique designed to enhance the finetuning process of large language models, potentially leading to more efficient and effective model adaptation.

Highlights

  • CorDA Initialization Support: Added 'corda' as an allowed value for the init_lora_weights parameter in FastLanguageModel.get_peft_model() and FastBaseModel.get_peft_model().
  • Improved Finetuning: This change enables users to utilize CorDA (Correlation-aware Decomposed Adaptation) initialization from the PEFT library, offering an alternative LoRA initialization strategy for potentially improved finetuning performance.
  • Validation Update: The validation logic in unsloth/models/llama.py and unsloth/models/_utils.py has been updated to recognize and accept 'corda' as a valid initialization option.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces support for a new init_lora_weights option, "corda", by updating the validation logic and corresponding error messages in unsloth/models/_utils.py and unsloth/models/llama.py. This change expands the accepted values for the init_lora_weights parameter to include "corda" alongside existing options like True, False, "gaussian", and "loftq".

@danielhanchen
Copy link
Copy Markdown
Member

Oh this works thanks!

@danielhanchen danielhanchen merged commit 8ea5338 into unslothai:main Dec 29, 2025
1 check passed
@majiayu000
Copy link
Copy Markdown
Contributor Author

Happy to help!

@majiayu000 majiayu000 deleted the fix/corda-support branch December 29, 2025 07:32
abiswas-realadvice pushed a commit to abiswas-realadvice/unsloth that referenced this pull request May 14, 2026
…lothai#3794)

Add "corda" as an allowed value for the init_lora_weights parameter
in FastLanguageModel.get_peft_model() and FastBaseModel.get_peft_model().

This enables users to use CorDA (Correlation-aware Decomposed Adaptation)
initialization from PEFT, which provides an alternative LoRA initialization
strategy for improved finetuning performance.

Fixes unslothai#3693

Signed-off-by: majiayu000 <1835304752@qq.com>
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.

[Bug] init_lora_weights="corda" not supported in FastLanguageModel.get_peft_model()

2 participants