-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Fix Deepseek OCR Lora Model Load #3738
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
Conversation
check for import error in autoconfig/peftconfig from_pretrained error handle import
Summary of ChangesHello @mmathew23, 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 addresses a critical issue preventing the proper loading of Deepseek OCR LoRA models by ensuring that the Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively addresses the model loading failure for Deepseek OCR by correctly propagating the trust_remote_code parameter. The addition of explicit ImportError handling is also a valuable improvement, preventing these errors from being swallowed and providing clearer feedback to the user.
My review includes suggestions to simplify the new except blocks by removing redundant code, which will improve readability and maintainability. Overall, the changes are solid and well-implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| model_types = get_transformers_model_type( | ||
| peft_config if peft_config is not None else model_config | ||
| peft_config if peft_config is not None else model_config, | ||
| trust_remote_code = trust_remote_code, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard new trust_remote_code kwarg with matching unsloth_zoo version
The new call to get_transformers_model_type now forwards trust_remote_code, but the imported helper comes from unsloth_zoo.compiler and the repo still requires unsloth_zoo>=2025.12.5 without bumping to a release that accepts that keyword. With the currently published helper (no trust_remote_code parameter), this line will raise TypeError: get_transformers_model_type() got an unexpected keyword argument 'trust_remote_code' before any model can load, even when trust_remote_code is left at its default. Please gate this call on a dependency bump or add a compatibility fallback.
Useful? React with 👍 / 👎.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Most models types have logic to load the model directly from a peft_config (only saved lora adapters and tokenizer). Deepseek OCR since it requires
trust_remote_code=Truefails inAutoConfig.from_pretrainedsince trust_remote_code isn't passed (unsloth_zoo.hf_utils). This depends on unslothai/unsloth-zoo#386, which creates a trust_remote_code kwarg. Once accepted this PR can successfully passtrust_remote_code=Truewhen specified by user.Additionally, a common failure mode is missing package, but that error get swallowed up. This will explicitly raise if an ImportError happens.
This notebook: https://colab.research.google.com/drive/1rQcpPJzFpTId-7KGSvU2zDIg2-emUJTd?usp=sharing
shows regular deepseek ocr works with new code.
Thie notebook: https://colab.research.google.com/drive/1bADSkRQuLQ7VkAV1XlCOH_38nqPhMPye?usp=sharing
shows that direct loading of a save lora_model now works with new code.