fbcache.rst 819 Bytes
Newer Older
Muyang Li's avatar
Muyang Li committed
1
2
.. _usage-fbcache:

3
4
5
6
7
8
9
First-Block Cache
=================

Nunchaku supports `First-Block Cache (FB Cache) <fbcache>`_ for faster long-step denoising. Example usage:

.. literalinclude:: ../../../examples/flux.1-dev-cache.py
   :language: python
Muyang Li's avatar
Muyang Li committed
10
   :caption: Running FLUX.1-dev with FB Cache (`examples/flux.1-dev-cache.py <https://github.com/nunchaku-tech/nunchaku/blob/main/examples/flux.1-dev-cache.py>`__)
11
12
13
14
15
16
17
18
19
20
21
   :linenos:
   :emphasize-lines: 15-17

Enable it with :func:`~nunchaku.caching.diffusers_adapters.flux.apply_cache_on_pipe`:

.. code-block:: python

    apply_cache_on_pipe(pipeline, residual_diff_threshold=0.12)

Adjust ``residual_diff_threshold`` to trade speed for quality - higher values are faster but lower quality.
Recommended value 0.12 gives 2× speedup for 50-step and 1.4× for 30-step denoising.