-
Notifications
You must be signed in to change notification settings - Fork 6.3k
[Doc] Add DeepCache in section optimization/General optimizations
#6390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the very nice doc! @stevhliu, would it make sense to have a dedicated page for the optimization techniques that lie outside of |
--> | ||
|
||
# DeepCache | ||
[DeepCache](https://huggingface.co/papers/2312.00858) accelerates [`StableDiffusionPipeline`] by strategically caching and reusing high-level features, while efficiently updating low-level features, which leverages the unique properties of the U-Net architecture. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it supports StableDiffusionXLPipeline
too, I'd mention it here.
Additionally, out of curiosity: does it support the img2img, and inpainting pipelines from SD and SDXL yet? If not, it might be extremely beneficial for the community to have them supported because they are so widely used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it supports StableDiffusionXLPipeline!
For other tasks, like inpainting, img2img, and video, I listed some of the results here:
In these cases, under the premise of ensuring quality and consistency, the acceleration ratio obtained is not particularly high.
I would later add scripts of these cases in the DeepCache repo😃
The `set_params` method accepts two arguments: `cache_interval` and `cache_branch_id`. `cache_interval` means the frequency of feature caching, specified as the number of steps between each cache operation. `cache_branch_id` identifies which branch of the network (ordered from the shallowest to the deepest layer) is responsible for executing the caching processes. | ||
Opting for a lower `cache_branch_id` or a larger `cache_interval` can lead to faster inference speed; however, this may come at the cost of reduced image quality. Once those arguments are set, use the `enable` or `disable` methods to activate or deactivate the DeepCacheSDHelper respectively. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clear! If there's any ablation already done on these hyperparameters in the original DeepCache paper, I'd mention it here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ablation experiments for cache_interval
are detailed in Tables 13 and 14 of the appendix, using SD1.5 as the base model. Regarding cache_branch_id
, its corresponding ablation experiments are also presented, found in Table 12; however, these experiments were carried out using the DDPM model.
- cache_interval: (N here represents the cache interval)

- cache_branch_id:

Would this be okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Feel free to include this in the doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet!
Thanks @sayakpaul for the wonderful suggestions😃 Following your advice, I have updated the doc, and also the DeepCache package to support inpaint/img2img tasks for SD. Warm welcome for any further advice or feedback |
Thank you! I have requested for another review from @stevhliu. Let's see what Steven has to say :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for adding the docs! 😄
@stevhliu WDYT #6390 (comment) ? |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Oops sorry I missed that Sayak! I assume you mean creating a section for optimization techniques outside of Diffusers and grouping ToMe and DeepCache under it since we're already adding a dedicated page for DeepCache here. I don't think it's necessary at this point since we only have the two (ToMe + DeepCache), and it'll probably make the table of contents more cluttered to add another subsection. I also don't think users really care whether a technique is native or external to Diffusers as long as it works and is clearly documented, so maybe we don't need to organize it so granularly right now 🙂 |
@horseee let's apply the changes suggested by Steven and ship this 🚀 |
Co-authored-by: Steven Liu <[email protected]>
Thanks @sayakpaul and @stevhliu! I have applied the suggested modifications. |
Thank you so much for your contributions and awesome work on DeepCache! Let's continue to make diffusion models more accessible! Also, if you want, feel free to include a link to the doc page (when it appears on the Diffusers site) from your DeepCache GitHub repo. |
Many thanks for your support! I've updated the GitHub repo to include the link, and I would continue to support DeepCache with more pipelines/models in Diffusers. Thanks again for your support! |
Just for folks visiting this PR, the doc is live here: https://huggingface.co/docs/diffusers/main/en/optimization/deepcache. |
…uggingface#6390) * add documentation for DeepCache * fix typo * add wandb url for DeepCache * fix some typos * add item in _toctree.yml * update formats for arguments * Update deepcache.md * Update docs/source/en/optimization/deepcache.md Co-authored-by: Sayak Paul <[email protected]> * add StableDiffusionXLPipeline in doc * Separate SDPipeline and SDXLPipeline * Add the paper link of ablation experiments for hyper-parameters * Apply suggestions from code review Co-authored-by: Steven Liu <[email protected]> --------- Co-authored-by: Sayak Paul <[email protected]> Co-authored-by: Steven Liu <[email protected]>
What does this PR do?
This PR is for the documentation of DeepCache, which is a new training-free method for accelerating diffusion models. DeepCache can be easily used on StableDIffusionPipeline to accelerate the inference speed. The doc contains the installation and usage of DeepCache, and also a quick overview of the quality and speed after applying DeepCache on the Stable Diffusion Pipeline.
Before submitting
[New Pipeline]: DeepCache: Accelerating Diffusion Models for Free #6193
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@sayakpaul