DeepCache icon indicating copy to clipboard operation
DeepCache copied to clipboard

[issue] Compatibility with torch.compile() if torch >= 2.0

Open jyoung105 opened this issue 1 year ago • 5 comments

Thanks for great work once again.

I would like to ask you, whether it can work with torch.compile().

If it is, maybe it can work so faster. I got an error below when I combine with together.

Unsupported: class property UNet2DConditionModel getset_descriptor

from user code:
   File "/usr/local/lib/python3.10/dist-packages/diffusers/models/modeling_utils.py", line 211, in __getattr__
    is_in_config = "_internal_dict" in self.__dict__ and hasattr(self.__dict__["_internal_dict"], name)

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information

jyoung105 avatar Feb 28 '24 12:02 jyoung105

Hi @jyoung105,

DeepCache is a dynamic model inference algorithm, which makes it incompatible with torch.compile(). One possible solution (though I'm not certain) is to split the entire pipeline into two models: one for the whole network inference and the other for partial network inference (the shallow on). This way, both of these models can be converted into static models, thus supporting torch.compile().

horseee avatar Mar 04 '24 07:03 horseee

I think the one you say is on the project 'onediff'. They enable both torch.compile() and your awesome project. And they ask you to set their way to deal with memory named oneflow, too. Thanks for your kindness!

jyoung105 avatar Mar 04 '24 14:03 jyoung105

Hello, do you have any solution now?

HuiZhang0812 avatar Mar 12 '24 09:03 HuiZhang0812

Hi, I think you should check it on onediff. (https://github.com/siliconflow/onediff[https://github.com/siliconflow/onediff]) They split the code for compiler and deepcache and make them compatible with each other. I didn't read the code in detail due to busy works in recentrly, but if you need, I will check it and share how codes are working.

jyoung105 avatar Mar 13 '24 08:03 jyoung105

Hi, I have tried onediff, but it seems onediff cannot run on windows.

xduzhangjiayu avatar Aug 02 '24 01:08 xduzhangjiayu