horseee / DeepCache

[CVPR 2024] DeepCache: Accelerating Diffusion Models for Free
https://horseee.github.io/Diffusion_DeepCache/
Apache License 2.0
687 stars 32 forks source link

Caching Mechanism for choosing skip branch #39

Open Kyuseok-nam opened 2 months ago

Kyuseok-nam commented 2 months ago

Hi, I was going over the code for DeepCache and was quite confused with a particular part of the code where you choose the skip branch in the unet model.

from unet_2d_condition.py file, line 1102~1108, Why did you implment this if condition? it seems to limit access of other skip branch or layers.

Also if I'm understanding correctly, Cache_layer_id : indicates which big block to choose from ex) CrossAttn2Dblock, DownBlock2D,... Cache_block_id: indicates which block (small blocks inside the big block) to choose from ex) transformer2dmodel, resnet

is this correct?

스크린샷 2024-04-23 172624

horseee commented 1 month ago

Hi, it's because of the mismatch of the down block and the up block.

The cache_block_id/cache_layer_id we use here is used in the downsampling block/layer. However, the downsampling block and upsampling block that are connected by the skip branch didn't share the same layer_id/block_id. Thus, this part of code functions like a layer/block mapping, and the goal is to find the corresponding layer/block id for this skip branch in the upsampling process