Xiuyu-Li / q-diffusion

[ICCV 2023] Q-Diffusion: Quantizing Diffusion Models.
https://xiuyuli.com/qdiffusion/
MIT License
301 stars 21 forks source link

load cifar_w8a8_ckpt.pth #11

Closed foreverlove944 closed 1 year ago

foreverlove944 commented 1 year ago

When executing this line of code: resume_cali_model(qnn, args.cali_ckpt, cali_data, args.quant_act, "qdiff", cond=False), the model cannot be loaded properly when running qnn.load_state_dict(ckpt, strict=(act_quant_mode=='qdiff')). Can you tell me how to solve this problem? Thank you.

2023-07-11 104114 2023-07-11 104114
Xiuyu-Li commented 1 year ago

Hi, this seems to be a size mismatch problem due to not enabling shortcut splitting in the ddim model based on your error message. Can you set split_shortcut=True when initializing the model and see if that fixes the issue?

foreverlove944 commented 1 year ago

Thank you for the suggestion, but it did not solve the problem.The command I entered is as shown in the screenshot.

2023-07-11 143001 2023-07-11 143133
Xiuyu-Li commented 1 year ago

I just tested this with python scripts/sample_diffusion_ddim.py --config configs/cifar10.yml --use_pretrained --timesteps 100 --eta 0 --skip_type quad --ptq --weight_bit 8 --quant_mode qdiff --quant_act --act_bit 8 --a_sym --split -l cifar_out --cali_ckpt cifar_w8a8_ckpt.pth using the latest codebase and it works fine. However, It seems like the splitting was not done as expected in your case.

I am not sure what's going on, but my guess is there might be some discrepancies with the dependencies (or codes if you have changed some) that made splitting not get called properly. Could you try doing pip install . and running the previous command using again? Also please try doing this with an unmodified codebase if you have done some modifications and it doesn't work in your current one.

foreverlove944 commented 1 year ago

Thank you for your help. I have resolved the issue after downloading the code again.