Skip to content

Commit 5104949

Browse files
committed
up
1 parent 1c788a9 commit 5104949

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

docs/source/en/quantization/gguf.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,40 @@ Once installed, set `DIFFUSERS_GGUF_CUDA_KERNELS=true` to use optimized kernels
7777
- Q5_K
7878
- Q6_K
7979

80+
## Using Diffusers checkpoints
81+
82+
You can convert a Diffusers checkpoint to GGUF and use it to perform inference. Use the Space below to
83+
run conversion:
84+
85+
<script
86+
type="module"
87+
src="https://gradio.s3-us-west-2.amazonaws.com/5.41.1/gradio.js"
88+
></script>
89+
90+
<gradio-app src="https://diffusers-internal-dev-diffusers-to-gguf.hf.space"></gradio-app>
91+
92+
Once it is obtained, you can run inference:
93+
94+
```py
95+
import torch
96+
97+
from diffusers import FluxPipeline, FluxTransformer2DModel, GGUFQuantizationConfig
98+
99+
ckpt_path = (
100+
"https://huggingface.co/sayakpaul/different-lora-from-civitai/blob/main/flux_dev_diffusers-q4_0.gguf"
101+
)
102+
transformer = FluxTransformer2DModel.from_single_file(
103+
ckpt_path,
104+
quantization_config=GGUFQuantizationConfig(compute_dtype=torch.bfloat16),
105+
torch_dtype=torch.bfloat16,
106+
)
107+
pipe = FluxPipeline.from_pretrained(
108+
"black-forest-labs/FLUX.1-dev",
109+
transformer=transformer,
110+
torch_dtype=torch.bfloat16,
111+
)
112+
pipe.enable_model_cpu_offload()
113+
prompt = "A cat holding a sign that says hello world"
114+
image = pipe(prompt, generator=torch.manual_seed(0)).images[0]
115+
image.save("flux-gguf.png")
116+
```

0 commit comments

Comments
 (0)