Buckets:

Mercity/FluxDistill / build_nunchaku /src /examples /v1 /flux.1-dev-cache-dit.py
Pranav2748's picture
download
raw
1.15 kB
# Please install cache-dit with `pip install cache-dit`.
import cache_dit
import torch
from cache_dit import DBCacheConfig
from diffusers import FluxPipeline
from nunchaku.models.transformers.transformer_flux_v2 import NunchakuFluxTransformer2DModelV2
from nunchaku.utils import get_precision
precision = get_precision() # auto-detect your precision is 'int4' or 'fp4' based on your GPU
transformer = NunchakuFluxTransformer2DModelV2.from_pretrained(
f"nunchaku-tech/nunchaku-flux.1-dev/svdq-{precision}_r32-flux.1-dev.safetensors"
)
pipeline = FluxPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev", transformer=transformer, torch_dtype=torch.bfloat16
).to("cuda")
# Please check https://github.com/vipshop/cache-dit for more details about the parameters.
cache_dit.enable_cache(
pipeline,
cache_config=DBCacheConfig(
Fn_compute_blocks=1,
Bn_compute_blocks=0,
residual_diff_threshold=0.12,
),
)
image = pipeline("A cat holding a sign that says hello world", num_inference_steps=50, guidance_scale=3.5).images[0]
image.save(f"flux.1-dev-cache-dit-{precision}.png")
cache_dit.summary(pipeline)

Xet Storage Details

Size:
1.15 kB
·
Xet hash:
f751f1900885eeb8651c68ae0f2f54aa28527dd4b24e1e31a9aea32b83d290c2

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.