FLUX.1-dev

Black Forest Labs

FLUX.1 [dev] is a 12 billion parameter rectified flow transformer that generates images from text descriptions. Use this model for the fastest inference with the TheStage AI framework "Elastic Models."

Perfomance

Latency Benchmarks

We have measured the latency of different sizes of FLUX.1-dev model (S, M, L, XL, original) on various GPUs. The measurements were taken for generating images of size 1024x1024 pixels.

Latency Benchmarking

Latency Benchmark Results

Latency (in seconds) for generating a 1024x1024 image using different model sizes on various hardware setups.

GPU/Model SizeSMLXLOriginal
H1002.883.063.254.186.46
L40s9.2210.0710.6714.3916
B2001.932.042.152.774.52
GeForce RTX 50905.79N/AN/AN/AN/A

LoRA Latency Benchmark Results

Time in seconds to generate one 1024x1024 image (average over 3 LoRAs — rank 32, 32, 256).

GPU/Model SizeSMLXLOriginal (unfused)
H1004.454.564.695.387.64
L40s11.3611.9912.5915.6319.02
B2003.163.233.292.795.2
GeForce RTX 50907.54N/AN/AN/AN/A

Benchmarking Methodology

The benchmarking was performed on a single GPU with a batch size of 1. Each model was run for 10 iterations, and the average latency was calculated.

Algorithm summary:
Load the FLUX.1-dev model with the specified size (S, M, L, XL, original).
Move the model to the GPU.
Prepare a sample prompt for image generation.
Run the model for a number of iterations (e.g., 10) and measure the time taken for each iteration. On each iteration:
Synchronize the GPU to flush any previous operations.
Record the start time.
Generate the image using the model.
Synchronize the GPU again.
Record the end time and calculate the latency for that iteration.
Calculate the average latency over all iterations.

Reproduce benchmarking

import torch
from elastic_models.diffusers import FluxPipeline

mode_name = 'black-forest-labs/FLUX.1-dev'
hf_token = ''
device = torch.device("cuda")

pipeline = FluxPipeline.from_pretrained(
    mode_name,
    torch_dtype=torch.bfloat16,
    token=hf_token,
    # 'original' for original model
    # 'S', 'M', 'L', 'XL' for accelerated models
    mode='S'
)
pipeline.to(device)

prompt = ["Kitten eating a banana"]
generate_kwargs={
    "height": 1024,
    "width": 1024,
    "num_inference_steps": 28,
    "cfg_scale": 0.0
}

import time

def evaluate_pipeline():
    torch.cuda.synchronize()
    start_time = time.time()
    output = pipeline(
        prompt=prompt,
        **generate_kwargs
    )
    torch.cuda.synchronize()
    end_time = time.time()

    return end_time - start_time

# Warm-up
for _ in range(5):
    evaluate_pipeline()

# Benchmarking
num_runs = 10
total_time = 0.0

for _ in range(num_runs):
    latency = evaluate_pipeline()
    total_time += latency

average_latency = total_time / num_runs
print(f"Average Latency over {num_runs} runs: {average_latency} seconds")