-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Flux.1 cannot load standard transformer in nf4 #9996
Comments
I don't think we support loading single-file NF4 checkpoints yet. Loading pre-quantized NF4 (or more generally bnb) checkpoint is only supported via Some reasoning as to why that is the case (from #9165 (comment)):
But maybe there's a way now. @DN6 would you be able to check this? If not, I will find time. |
i'm specifically loading transformer-only. although its the same issue with single-file checkpoint (although they are much less frequent). |
Clearing some confusion. I think what you mean is the following. When trying to load a standard transformer checkpoint (which is the original BFL format) using Issue / feature request is fine and high-prio is fine too. |
yes, that is correct. it works for transformers in fp32/fp16/fp8 safetensors, but fails for nf4. |
Thanks for confirming! Just to give you a reason as to why it fails is because NF4 state dicts have special quantization keys and they also compress some original dimensionality which is why you faced the error you reported. See, for example: https://huggingface.co/hf-internal-testing/flux.1-dev-nf4-pkg/tree/main/transformer?show_file_info=transformer%2Fdiffusion_pytorch_model.safetensors (
Yes, not denying it. This will be supported :) |
@vladmandic do you have a reference for this? Would be quite helpful! |
GGUF? i shared it in #9487 (comment) |
the problem with civitai models is that they are not standard. everything is rather ad-hoc for state dicts for most models released. it's unfortunate that it became the more prevalent/common means of distribution right now, but i'm working directly with civitai to improve this situation down the line and allow model creators to provide configuration details for a given model and even directly support Diffusers to this effect. |
i totally agree with that statement - its a wild west! |
i've used that xkcd many times myself! |
Describe the bug
loading different flux transformer models is fine except for nf4.
it works for 1% of fine-tunes provided on Huggingface, but it doesn't work for 99% standard fine-tunes available on CivitAI.
example of such model: https://civitai.com/models/118111?modelVersionId=1009051
note i'm using
FluxTransformer2DModel
directly as its easiest for reproduction plus majority of flux fine-tunes are provided as transformer-only, not full models. but where full model does exist, its exactly the same problem usingFluxPipeline
Reproduction
Logs
System Info
torch==2.5.1+cu124 diffusers==0.32.0.dev0 bnb==0.44.1
Who can help?
@yiyixuxu @sayakpaul @DN6 @asomoza
The text was updated successfully, but these errors were encountered: