thu-nics / MixDQ

[ECCV24] MixDQ: Memory-Efficient Few-Step Text-to-Image Diffusion Models with Metric-Decoupled Mixed Precision Quantization
https://a-suozhang.xyz/mixdq.github.io/
27 stars 3 forks source link

AttributeError: 'Linear' object has no attribute 'act_quant' #5

Closed majiajiong closed 2 months ago

majiajiong commented 3 months ago

When I run the ptq.py script, the following error was prompted. I found that only some modules have act_quant and weight_quant

  python scripts/ptq.py --config ./configs/stable-diffusion/lcm_lora.yaml --outdir ./logs/lcm_dreamshaper8 --seed 42

  File "MixDQ/quant_utils/qdiff/models/quant_block.py", line 589, in __call__
    if is_cross_attn and ((attn.to_k.act_quant or attn.to_k.weight_quant) or (attn.to_v.act_quant or attn.to_v.weight_quant)):
  File "envs/aigc_py310/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1695, in __getattr__
    raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'Linear' object has no attribute 'act_quant'

I changed this conditional statement to: if is_cross_attn and ((getattr(attn.to_k,'act_quant', False) or getattr(attn.to_k, 'weight_quant', False)) or (getattr(attn.to_v, 'act_quant', False) or getattr(attn.to_v, 'weight_quant', False))):

Is this correct?

A-suozhang commented 3 months ago

Thank you for pointing out such issue. We fix it in the newest commit.