alfredplpl
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: diffusers
|
3 |
+
license: other
|
4 |
+
license_name: flux-1-dev-non-commercial-license
|
5 |
+
license_link: https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md
|
6 |
+
---
|
7 |
+
|
8 |
+
# How to cast fp8
|
9 |
+
1. Install quanto-optinum.
|
10 |
+
```bash
|
11 |
+
pip install optimum-quanto
|
12 |
+
```
|
13 |
+
2. Run the script:
|
14 |
+
```python
|
15 |
+
import torch
|
16 |
+
from safetensors.torch import save_file
|
17 |
+
|
18 |
+
from diffusers import FluxTransformer2DModel, FluxPipeline
|
19 |
+
from optimum.quanto import freeze, qfloat8, quantize
|
20 |
+
|
21 |
+
transformer = FluxTransformer2DModel.from_single_file("modern-anime.safetensors", torch_dtype=torch.bfloat16)
|
22 |
+
quantize(transformer, weights=qfloat8)
|
23 |
+
freeze(transformer)
|
24 |
+
|
25 |
+
transformer.save_pretrained("transformer")
|
26 |
+
```
|