[diffusion] feat: declare regional compile regions for flux (#43575)

Co-authored-by: Mick Qian <mickqian@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mick
2026-10-11 08:33:29 +08:00
committed by GitHub
co-authored by Mick Qian Claude Opus 5.5
parent 68e1a3dbb1
commit 9933cf5437
2 changed files with 22 additions and 0 deletions
@@ -1196,6 +1196,11 @@ class FluxTransformer2DModel(CachableDiT, LayerwiseOffloadableModuleMixin):
Reference: https://blackforestlabs.ai/announcing-black-forest-labs/
"""
_compile_conditions = [
lambda name, module: isinstance(
module, (FluxTransformerBlock, FluxSingleTransformerBlock)
)
]
param_names_mapping = FluxConfig().arch_config.param_names_mapping
@classmethod
@@ -5,6 +5,11 @@ from unittest.mock import MagicMock, patch
import pytest
import torch.nn as nn
from sglang.multimodal_gen.runtime.models.dits.flux import (
FluxSingleTransformerBlock,
FluxTransformer2DModel,
FluxTransformerBlock,
)
from sglang.multimodal_gen.runtime.models.dits.ltx_2 import (
LTX2VideoTransformer3DModel,
)
@@ -195,6 +200,18 @@ def test_ltx2_compile_conditions_match_only_direct_blocks():
)
def test_flux_compile_conditions_match_both_block_types():
def matches(module) -> bool:
return any(
condition("transformer_blocks.0", module)
for condition in FluxTransformer2DModel._compile_conditions
)
assert matches(FluxTransformerBlock.__new__(FluxTransformerBlock))
assert matches(FluxSingleTransformerBlock.__new__(FluxSingleTransformerBlock))
assert not matches(nn.Linear(2, 2))
def test_compile_matching_submodules_matches_only_declared_regions():
model = _RegionalModel()