---
title: "Fast LoRA inference for Flux with Diffusers and PEFT"
description: "Combining Flash Attention 3, torch.compile and TorchAO FP8 quantization with PEFT's LoRA hotswapping speeds up Flux.1-Dev LoRA inference by 2.23x on an H100, and swapping adapters does not trigger recompilation."
url: "https://swe.quest/articles/fast-lora-inference-for-flux-with-diffusers-and-peft-adf61d95e12cb0a4"
canonical: "https://huggingface.co/blog/lora-fast"
source: "Hugging Face"
published: "2025-07-23"
difficulty: "hard"
kind: "How-to"
reading_minutes: 9
tags: ["inference","performance","computer-vision","python"]
---

# Fast LoRA inference for Flux with Diffusers and PEFT

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2025-07-23, 9 min read, How-to. Original: [https://huggingface.co/blog/lora-fast](https://huggingface.co/blog/lora-fast)

## Summary

Combining Flash Attention 3, torch.compile and TorchAO FP8 quantization with PEFT's LoRA hotswapping speeds up Flux.1-Dev LoRA inference by 2.23x on an H100, and swapping adapters does not trigger recompilation. Hotswapping avoids recompiles by turning LoRA scaling factors into tensors and zero-padding adapter weights to a declared max rank. The limits are that later LoRAs must target the same layers as the first one, or a subset of them, and text encoder LoRAs are not supported. On a 24GB RTX 4090, FA3 is unavailable, so the recipe adds NF4 quantization of the T5 text encoder to fit FP8 without CPU offloading, which gives a 2.04x speedup.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Computer vision](https://swe.quest/tags/computer-vision.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- LoRA fine-tuning ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))
- PyTorch torch.compile
- diffusion models
- model quantization ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))

## Keywords

Flux.1-Dev, LoRA, Diffusers, PEFT, torch.compile, Flash Attention 3, TorchAO, bitsandbytes

## Related posts

- [(LoRA) Fine-Tuning FLUX.1-dev on Consumer Hardware](https://swe.quest/articles/lora-fine-tuning-flux-1-dev-on-consumer-hardware-310a6094e7391e33.md): Hugging Face · 2025-06-19 · Hard · 11 min read · Model training, Computer vision, Python
  FLUX.1-dev can be LoRA fine-tuned on a single consumer GPU by combining QLoRA (4-bit NF4 base transformer via bitsandbytes), 8-bit AdamW, gradient checkpointing, cached VAE latents and precomputed CLIP/T5 text embeddings, so that only the quantized transformer plus adapters sit in GPU memory.
- [Goodbye cold boot - how we made LoRA Inference 300% faster](https://swe.quest/articles/goodbye-cold-boot-how-we-made-lora-inference-300-faster-d8d4cf4c16c22df2.md): Hugging Face · 2023-12-05 · Medium · 9 min read · Inference & serving, ML platforms, Computer vision, Python
  Hugging Face's Inference API now keeps Stable Diffusion base models warm and swaps LoRA adapters per request, so hundreds of distinct LoRAs share a few GPUs instead of each getting a dedicated deployment.
- [Exploring Quantization Backends in Diffusers](https://swe.quest/articles/exploring-quantization-backends-in-diffusers-11e0d1ba0cf15851.md): Hugging Face · 2025-05-21 · Medium · 11 min read · Inference & serving, Computer vision, Python, Performance engineering
  Hugging Face Diffusers supports several quantization backends (bitsandbytes, torchao, Quanto, GGUF and native FP8 layerwise casting) that shrink large diffusion models such as Flux-dev, whose full BF16 pipeline needs about 31 GB.
- [Run FLUX.1-dev three times faster](https://swe.quest/articles/run-flux-1-dev-three-times-faster-ae60b80e0a362206.md): Modal · 2025-06-18 · Medium · 9 min read · Inference & serving, Performance engineering, Python, Computer vision, Serverless
  FLUX.1-dev image generation on Modal drops from ~6.75s to under three seconds per 1024x1024 image.
- [Optimizing your LLM in production](https://swe.quest/articles/optimizing-your-llm-in-production-aa5bbb901928fa57.md): Hugging Face · 2023-09-15 · Medium · 31 min read · Inference & serving, LLMs, Performance engineering, Python
  Serving billion-parameter LLMs efficiently comes down to three levers: lower precision, Flash Attention, and inference-friendly architectures such as ALiBi, rotary embeddings, Multi-Query Attention and Grouped-Query Attention.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
