ostris / ai-toolkit

Various AI scripts. Mostly Stable Diffusion stuff.
MIT License
3.03k stars 297 forks source link

Error running job: 'QLinear' object has no attribute 'qweight' #193

Open Joir-Jio opened 2 days ago

Joir-Jio commented 2 days ago

This is for bugs only

Did you already ask in the discord?

YOU RECEIVEDANINVITE,BU. Invalid Invite Askbuffy foranew invite!

You verified that this is a bug and not a feature request or question by asking in the discord?

YOU RECEIVEDANINVITE,BU. Invalid Invite Askbuffy foranew invite!

Describe the bug

(ai-toolkit) C:\LYF\dev\ai-toolkit>python run.py config/train_lora_flux_24gb.yaml
Running 1 job
C:\Users\david\anaconda3\envs\ai-toolkit\Lib\site-packages\controlnet_aux\segment_anything\modeling\tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_5m_224 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_5m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
C:\Users\david\anaconda3\envs\ai-toolkit\Lib\site-packages\controlnet_aux\segment_anything\modeling\tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_11m_224 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_11m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
C:\Users\david\anaconda3\envs\ai-toolkit\Lib\site-packages\controlnet_aux\segment_anything\modeling\tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_21m_224 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_224. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
C:\Users\david\anaconda3\envs\ai-toolkit\Lib\site-packages\controlnet_aux\segment_anything\modeling\tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_21m_384 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_384. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
C:\Users\david\anaconda3\envs\ai-toolkit\Lib\site-packages\controlnet_aux\segment_anything\modeling\tiny_vit_sam.py:654: UserWarning: Overwriting tiny_vit_21m_512 in registry with controlnet_aux.segment_anything.modeling.tiny_vit_sam.tiny_vit_21m_512. This is because the name being registered conflicts with an existing name. Please check if this is not expected.
  return register_model(fn_wrapper)
{
    "type": "sd_trainer",
    "training_folder": "output",
    "device": "cuda:0",
    "trigger_word": "urpants",
    "network": {
        "type": "lora",
        "linear": 32,
        "linear_alpha": 16
    },
    "save": {
        "dtype": "float16",
        "save_every": 500,
        "max_step_saves_to_keep": 10,
        "push_to_hub": false
    },
    "datasets": [
        {
            "folder_path": "C:\\Users\\david\\Desktop\\product(1)\\dabiao",
            "caption_ext": "txt",
            "caption_dropout_rate": 0.05,
            "shuffle_tokens": false,
            "cache_latents_to_disk": true,
            "resolution": [
                1024
            ]
        }
    ],
    "train": {
        "batch_size": 1,
        "steps": 2000,
        "gradient_accumulation_steps": 1,
        "train_unet": true,
        "train_text_encoder": false,
        "gradient_checkpointing": true,
        "noise_scheduler": "flowmatch",
        "optimizer": "adamw8bit",
        "lr": 0.0001,
        "ema_config": {
            "use_ema": true,
            "ema_decay": 0.99
        },
        "dtype": "bf16"
    },
    "model": {
        "name_or_path": "C:\\LYF\\dev\\ai-toolkit\\FLUX",
        "is_flux": true,
        "quantize": true
    },
    "sample": {
        "sampler": "flowmatch",
        "sample_every": 500,
        "width": 1024,
        "height": 1024,
        "prompts": [
            "a woman with red hair, wearing a urpants, playing chess at the park",
            "a woman holding a coffee cup,wearing a urpants, sitting at a cafe"
        ],
        "neg": "",
        "seed": 42,
        "walk_seed": true,
        "guidance_scale": 4,
        "sample_steps": 20
    }
}
Using EMA
C:\LYF\dev\ai-toolkit\extensions_built_in\sd_trainer\SDTrainer.py:61: FutureWarning: `torch.cuda.amp.GradScaler(args...)` is deprecated. Please use `torch.amp.GradScaler('cuda', args...)` instead.
  self.scaler = torch.cuda.amp.GradScaler()

#############################################
# Running job: urpants
#############################################

Running  1 process
Loading Flux model
Loading transformer
Quantizing transformer
C:\Users\david\anaconda3\envs\ai-toolkit\Lib\site-packages\torch\utils\cpp_extension.py:1966: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation.
If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST'].
  warnings.warn(
Error running job: 'QLinear' object has no attribute 'qweight'

========================================
Result:
 - 0 completed jobs
 - 1 failure
========================================
Traceback (most recent call last):
  File "C:\LYF\dev\ai-toolkit\run.py", line 90, in <module>
    main()
  File "C:\LYF\dev\ai-toolkit\run.py", line 86, in main
    raise e
  File "C:\LYF\dev\ai-toolkit\run.py", line 78, in main
    job.run()
  File "C:\LYF\dev\ai-toolkit\jobs\ExtensionJob.py", line 22, in run
    process.run()
  File "C:\LYF\dev\ai-toolkit\jobs\process\BaseSDTrainProcess.py", line 1241, in run
    self.sd.load_model()
  File "C:\LYF\dev\ai-toolkit\toolkit\stable_diffusion_model.py", line 612, in load_model
    freeze(transformer)
  File "C:\Users\david\anaconda3\envs\ai-toolkit\Lib\site-packages\optimum\quanto\quantize.py", line 146, in freeze
    m.freeze()
  File "C:\Users\david\anaconda3\envs\ai-toolkit\Lib\site-packages\optimum\quanto\nn\qmodule.py", line 299, in freeze
    qweight = self.qweight
              ^^^^^^^^^^^^
  File "C:\Users\david\anaconda3\envs\ai-toolkit\Lib\site-packages\torch\nn\modules\module.py", line 1729, in __getattr__
    raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'QLinear' object has no attribute 'qweight'. Did you mean: 'weight'?
Joir-Jio commented 2 days ago

my device is win11 and 4090 24G

Haydn-Mann commented 1 day ago

I am having the same issue

Imranazeb commented 1 day ago

A lot of things broke because optimum-quanto version changed. Try pip uninstall optimum-quanto and then pip install optimum-quanto==0.2.4. A lot of errors were resolved. I have made a suggestion in the discord that dev should list versions in the requirements file.