Fix: prevent load_in_fp8 kwarg from reaching Qwen3MoeForCausalLM constructor (Fix #3649)#3654
Conversation
Summary of ChangesHello @bhuvanprakash, 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 bug where an internal Unsloth flag, Highlights
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.
Code Review
This pull request correctly addresses a TypeError that occurs when using the load_in_fp8 argument. The issue was that this internal Unsloth flag was being passed down to the Hugging Face model constructor, which does not recognize it. The fix involves popping the load_in_fp8 argument from the keyword arguments before calling the Hugging Face from_pretrained method. This is a clean and effective solution that prevents the unexpected keyword argument from causing a crash. The change is consistent with similar fixes in the codebase for other internal flags. I've reviewed the change and it looks good to me.
|
Oh thank you!! |
PR Description
This PR fixes the issue reported in #3649 where calling:
TypeError: Qwen3MoeForCausalLM.init() got an unexpected keyword argument 'load_in_fp8'
The problem was that load_in_fp8 was an internal flag for Unsloth, but it was still being passed to the Hugging Face model constructor and models like Qwen3MoeForCausalLM do not accept that argument -->which caused the crash.
What I changed
The parameter is now removed from the location where the model is passed to the HF loader:
load_in_fp8 = kwargs.pop("load_in_fp8", None)I kept the value around if it's needed later, but it no longer gets to the HF constructor.
Notes
I don’t have FP8 hardware to perform a full training run, so the fix is based on the reading the execution path and matching it with the similar logic that’s already implemented in the codebase fixes (like the change in PR #3621).
if additional adjustments are needed, I’m happy to update the PR.
Fixes #3649