Run FLUX.1-dev three times faster
Jun 18, 2025

Summary
This post details optimizations applied to the FLUX.1-dev diffusion model for faster image generation. It introduces standard optimizations including Torch compiler integration (`torch.compile` with `max-autotune`), fused QKV projections, and channels-last memory layout, resulting in a 1.5x speedup. Additionally, it implements an approximate caching technique, First Block Caching (adapted from ParaAttention and TeaCache), to achieve a further 2x speedup by skipping steps where image changes are minimal. The post also discusses reducing compile-time for TorchInductor by using a fixed set of configurations and optimizing the `torch.compile` process for faster cold starts.
More from the Inference Performance Optimization trail
- TypeSafe AI scales Jev to trillions of tokens in three days on Modal | Modal Blog
- Modal Clusters are generally available
- Hitting a billion tokens per minute on one GPU by combining a query planner and an inference engine | Modal Blog
- How to serve trillions of tokens for trillion-parameter coding agents | Modal Blog
- Kimi K3 by Moonshot now available on Modal | Modal Blog