Buckets:

Mercity/FluxDistill / build_nunchaku /src /examples /flux.1-dev-double_cache_offloading.py
Pranav2748's picture
download
raw
849 Bytes
import torch
from diffusers import FluxPipeline
from nunchaku import NunchakuFluxTransformer2dModel
from nunchaku.caching.diffusers_adapters import apply_cache_on_pipe
from nunchaku.utils import get_precision
precision = get_precision()
transformer = NunchakuFluxTransformer2dModel.from_pretrained(
f"nunchaku-tech/nunchaku-flux.1-dev/svdq-{precision}_r32-flux.1-dev.safetensors",
offload=True,
)
pipeline = FluxPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev", transformer=transformer, torch_dtype=torch.bfloat16
).to("cuda")
apply_cache_on_pipe(
pipeline,
use_double_fb_cache=True,
residual_diff_threshold_multi=0.09,
residual_diff_threshold_single=0.12,
)
image = pipeline(["A cat holding a sign that says hello world"], num_inference_steps=50).images[0]
image.save(f"flux.1-dev-cache-{precision}.png")

Xet Storage Details

Size:
849 Bytes
·
Xet hash:
0d13aae2b7b547c1da219dc9dc3954d9c304d680e28bfe7f668f2bc0fde2cc88

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