Skip to content

FLUX 量化后无法训练lora #220

@JoshonSmith

Description

@JoshonSmith

参考 /examples/image_synthesis/flux_text_to_image_low_vram.py

修改 examples/train/flux/train_flux_lora.py
运行报错:

Traceback (most recent call last):
  File "train_flux_lora.py", line 95, in <module>
    model = LightningModel(
  File "train_flux_lora.py", line 43, in __init__
    self.add_lora_to_model(self.pipe.denoising_model(), lora_rank=lora_rank, lora_alpha=lora_alpha, lora_target_modules=lora_target_modules)
  File "/diffsynth/trainers/text_to_image.py", line 43, in add_lora_to_model
    model = inject_adapter_in_model(lora_config, model)
  File "/python3.8/site-packages/peft/mapping.py", line 215, in inject_adapter_in_model
    peft_model = tuner_cls(model, peft_config, adapter_name=adapter_name)
  File "/python3.8/site-packages/peft/tuners/lora/model.py", line 139, in __init__
    super().__init__(model, config, adapter_name)
  File "/python3.8/site-packages/peft/tuners/tuners_utils.py", line 175, in __init__
    self.inject_adapter(self.model, adapter_name)
  File "/python3.8/site-packages/peft/tuners/tuners_utils.py", line 431, in inject_adapter
    self._create_and_replace(peft_config, adapter_name, target, target_name, parent, current_key=key)
  File "/python3.8/site-packages/peft/tuners/lora/model.py", line 224, in _create_and_replace
    new_module = self._create_new_module(lora_config, adapter_name, target, **kwargs)
  File "/python3.8/site-packages/peft/tuners/lora/model.py", line 346, in _create_new_module
    raise ValueError(
ValueError: Target module Linear(
  (module): Linear(in_features=3072, out_features=18432, bias=True)
) is not supported. Currently, only the following modules are supported: `torch.nn.Linear`, `torch.nn.Embedding`, `torch.nn.Conv2d`, `transformers.pytorch_utils.Conv1D`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions