fix(mm): support diffusers FLUX LoRAs on NF4/8-bit quantized base models#9118
Open
Pfannkuchensack wants to merge 3 commits intoinvoke-ai:mainfrom
Open
fix(mm): support diffusers FLUX LoRAs on NF4/8-bit quantized base models#9118Pfannkuchensack wants to merge 3 commits intoinvoke-ai:mainfrom
Pfannkuchensack wants to merge 3 commits intoinvoke-ai:mainfrom
Conversation
CustomInvokeLinearNF4 and CustomInvokeLinear8bitLt were missing the _cast_weight_bias_for_input / _cast_tensor_for_input methods that the sidecar-patches branch in autocast_linear_forward_sidecar_patches calls. This caused an AttributeError whenever a non-LoRALayer/FluxControlLoRALayer patch (e.g. MergedLayerPatch produced by the diffusers FLUX LoRA converter for fused Q/K/V/mlp into linear1) was applied to a quantized FLUX module. The weight is exposed as a meta-device tensor with the correct logical shape (read from quant_state for Params4bit, since .shape reports the packed-byte layout). Shape-only patches (LoRA, LoHA, MergedLayerPatch) work; SetParameterLayer / DoRA on quantized modules remain unsupported.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CustomInvokeLinearNF4 and CustomInvokeLinear8bitLt were missing the _cast_weight_bias_for_input / _cast_tensor_for_input methods that the sidecar-patches branch in autocast_linear_forward_sidecar_patches calls. This caused an AttributeError whenever a non-LoRALayer/FluxControlLoRALayer patch (e.g. MergedLayerPatch produced by the diffusers FLUX LoRA converter for fused Q/K/V/mlp into linear1) was applied to a quantized FLUX module.
The weight is exposed as a meta-device tensor with the correct logical shape (read from quant_state for Params4bit, since .shape reports the packed-byte layout). Shape-only patches (LoRA, LoHA, MergedLayerPatch) work; SetParameterLayer / DoRA on quantized modules remain unsupported.
Related Issues / Discussions
https://discord.com/channels/1020123559063990373/1500616847106506752
QA Instructions
Download the Lora from here and try to run it with a flux dev model
Merge Plan
Standard merge.
Checklist
What's Newcopy (if doing a release after this PR)