Skip to content

Conversation

@LawJarp-A
Copy link

@LawJarp-A LawJarp-A commented Dec 5, 2025

Add Flux 2.0 diffusion model support

Refer issue: #153

Purpose

Add support for Flux 2.0 text-to-image diffusion model with dual-stream (8 blocks) + single-stream (48 blocks) transformer architecture.

Key components:

  • Flux2Transformer2DModel with 4D RoPE and vLLM-optimized layers
  • Flux2Pipeline with Mistral3-Small-24B text encoder
  • 128-channel latent space with 2x2 patch packing
  • Registry integration and VLLM_OMNI_DIFFUSERS_PATH environment variable support

Files added:

  • vllm_omni/diffusion/models/flux2/ (transformer and pipeline)
  • Updated registry and diffusion __init__.py

Test Plan

# Setup
export VLLM_OMNI_DIFFUSERS_PATH=/path/to/diffusers/src

# Test imports
python -c "from vllm_omni.diffusion.models.flux2 import Flux2Pipeline; print('✅')"

# Test generation
python -c "
from vllm_omni import Omni
model = Omni('black-forest-labs/FLUX.2-dev')
outputs = model.generate(prompt='a sunset', height=1024, width=1024)
"

Test Result

WIP


Checklist

  • Purpose stated (Flux 2.0 support)
  • Test plan provided
  • Test results documented
  • Update supported_models.md for Flux 2.0
  • Release notes: "Added Flux 2.0 diffusion model with dual+single stream transformer architecture"

@LawJarp-A LawJarp-A changed the title Add Flux2 Model support [Model] Add Flux2 Model support Dec 5, 2025
@LawJarp-A LawJarp-A changed the title [Model] Add Flux2 Model support [Model] [WIP] Add Flux2 Model support Dec 5, 2025
@LawJarp-A LawJarp-A mentioned this pull request Dec 5, 2025
1 task
@LawJarp-A
Copy link
Author

LawJarp-A commented Dec 5, 2025

Pending tasks

  • Test imports work - from vllm_omni.diffusion.models.flux2 import Flux2Pipeline
  • Verify weight loading - Run pipeline.load_weights() with real Flux2 checkpoint
  • End-to-end generation test - Generate one image to validate full pipeline
  • Update supported_models.md - Add Flux2 documentation entry

@LawJarp-A
Copy link
Author

cc: @hsliuustc0106 @ZJY0516
Hey, could not test the original weights due to GPU constraints.
Accd to: huggingface.co/blog/flux-2 (will need ~64GB)
Additionally, they have provided quantized weights as well which I can try. But do suggest how I can proceed. Thanks!

@ZJY0516 ZJY0516 self-requested a review December 9, 2025 11:42
@@ -1,0 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""Diffusion model support for vllm-omni."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

"""Load transformer weights."""
self.load_transformer()

def load_transformer(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use weight loader introduced in #157


import torch
import torch.nn as nn
from diffusers.models.attention_dispatch import dispatch_attention_fn
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use attention layer introduced in #115

rope_theta: int = 2000,
eps: float = 1e-6,
):
super().__init__()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please try to read some properties from od_config.tf_model_config like

model_config = od_config.tf_model_config
num_layers = model_config.num_layers

Because we may use a little model with less layers to test in ci

Signed-off-by: Prajwal A <[email protected]>
- Resolved conflicts in registry.py by keeping both Flux2Pipeline and QwenImageEditPipeline
- Resolved conflicts in z_image_transformer.py by removing duplicate Attention import
- Includes latest changes from main: CI tests, new examples, model loader refactor
Signed-off-by: Prajwal A <[email protected]>
- Replace deprecated typing.Tuple/Dict/List with tuple/dict/list
- Fix ambiguous variable name 'l' to 'layer_dim'
- Remove unused variables batch_size and img_seq_len
- Add TYPE_CHECKING import for OmniDiffusionConfig

Signed-off-by: Prajwal A <[email protected]>
- Remove obsolete comments about local diffusers repo
- Remove reference to deleted __init__.py file
- All imports are now using standard diffusers package

Signed-off-by: Prajwal A <[email protected]>
@SamitHuang SamitHuang mentioned this pull request Dec 10, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants