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."

Python usage

Overview

ElasticModels are the models produced by TheStage AI ANNA: Automated Neural Networks Accelerator. ANNA allows you to control model size, latency and quality with a simple slider movement, routing different compression algorithms to different layers. For each model, we have produced a series of optimized models:

XL: Mathematically equivalent neural network, optimized with our DNN compiler.

L: Near lossless model, with less than 1% degradation obtained on corresponding benchmarks.

M: Faster model, with accuracy degradation less than 1.5%.

S: The fastest model, with accuracy degradation less than 2%.

Models can be accessed via TheStage AI Python SDK: ElasticModels, or deployed as Docker containers with REST API endpoints (see Deploy section).

Installation

System Requirements

PropertyValue
GPUL40s, RTX 5090, H100, B200
Python Version3.10-3.12
CPUIntel/AMD x86_64
CUDA Version12.8+

TheStage AI Access token setup

Install TheStage AI CLI and setup API token:

pip install thestage
thestage config set --access-token <YOUR_ACCESS_TOKEN>

ElasticModels installation

Install TheStage Elastic Models package:

pip install 'thestage-elastic-models[nvidia]' \
    --extra-index-url https://thestage.jfrog.io/artifactory/api/pypi/pypi-thestage-ai-production/simple

Usage example

Elastic Models provides the same interface as HuggingFace Diffusers. Here is an example of how to use the FLUX.1-dev model:

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)

prompts = ["Kitten eating a banana"]
output = pipeline(prompt=prompts)

for prompt, output_image in zip(prompts, output.images):
    output_image.save((prompt.replace(' ', '_') + '.png'))

LoRA Support

Elastic FLUX.1-dev engines support runtime LoRA hot-swap — load, switch, or disable LoRA files without recompilation or engine reload. LoRA weights are dynamic tensor inputs to the compiled engine.

Supported ranks: 1–256 (compiled with dynamic rank)

Supported formats: XLabs, diffusers, BFL Control (auto-detected)

Hot-swap: switch LoRA instantly by calling load_lora_weights()

Disable: unload_lora_weights() removes LoRA with minimal overhead

LoRA adds ~5-15% latency overhead. LoRA files must be downloaded locally before use (e.g. via huggingface-cli download).

Usage with LoRA

import torch
from elastic_models.diffusers import FluxPipeline

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

pipeline = FluxPipeline.from_pretrained(
    model_name,
    torch_dtype=torch.bfloat16,
    mode="S",
    lora_support=True,
)
pipeline.to(device)

# Load a LoRA and generate
pipeline.load_lora_weights("./loras/realism_lora.safetensors", strength=1.0)
output = pipeline(prompt=["A portrait photo of a woman in golden hour light"])
output.images[0].save("realism_lora.png")

# Hot-swap to a different LoRA (no engine reload)
pipeline.load_lora_weights("./loras/anime_lora.safetensors", strength=1.0)
output = pipeline(prompt=["Anime girl with blue hair in a garden"])
output.images[0].save("anime_lora.png")

# Disable LoRA
pipeline.unload_lora_weights()
output = pipeline(prompt=["A castle on a hill at sunset"])
output.images[0].save("no_lora.png")