--- library_name: diffusers license: other license_name: flux-1-dev-non-commercial-license license_link: https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md --- # How to cast fp8 1. Install quanto-optinum. ```bash pip install optimum-quanto ``` 2. Run the script: ```python import torch from safetensors.torch import save_file from diffusers import FluxTransformer2DModel, FluxPipeline from optimum.quanto import freeze, qfloat8, quantize transformer = FluxTransformer2DModel.from_single_file("modern-anime.safetensors", torch_dtype=torch.bfloat16) quantize(transformer, weights=qfloat8) freeze(transformer) transformer.save_pretrained("transformer") ```