From 1efc33c64038f5efc3c47a0f209039dff371fea6 Mon Sep 17 00:00:00 2001 From: Adarsh Shirawalmath <114558126+adarshxs@users.noreply.github.com> Date: Tue, 24 Feb 2026 18:51:23 +0530 Subject: [PATCH] [diffusion] refactor: remove enums and unify attention backends (#19149) --- .../pipeline_configs/diffusers_generic.py | 4 -- .../runtime/pipelines/diffusers_pipeline.py | 5 -- .../multimodal_gen/runtime/server_args.py | 66 ------------------- 3 files changed, 75 deletions(-) diff --git a/python/sglang/multimodal_gen/configs/pipeline_configs/diffusers_generic.py b/python/sglang/multimodal_gen/configs/pipeline_configs/diffusers_generic.py index 3eac5306f..96ab3c473 100644 --- a/python/sglang/multimodal_gen/configs/pipeline_configs/diffusers_generic.py +++ b/python/sglang/multimodal_gen/configs/pipeline_configs/diffusers_generic.py @@ -50,10 +50,6 @@ class DiffusersGenericPipelineConfig(PipelineConfig): vae_slicing: bool = False # slice VAE decode for lower memory usage vae_sp: bool = False - # Attention backend for diffusers models (e.g., "flash", "_flash_3_hub", "sage", "xformers") - # See: https://huggingface.co/docs/diffusers/main/en/optimization/attention_backends - diffusers_attention_backend: str | None = None - # Quantization config for pipeline-level quantization # See: https://huggingface.co/docs/diffusers/main/en/quantization/overview # Use PipelineQuantizationConfig for component-level control: diff --git a/python/sglang/multimodal_gen/runtime/pipelines/diffusers_pipeline.py b/python/sglang/multimodal_gen/runtime/pipelines/diffusers_pipeline.py index fc8e3461a..c0d6bbfa7 100644 --- a/python/sglang/multimodal_gen/runtime/pipelines/diffusers_pipeline.py +++ b/python/sglang/multimodal_gen/runtime/pipelines/diffusers_pipeline.py @@ -490,11 +490,6 @@ class DiffusersPipeline(ComposedPipelineBase): """ backend = server_args.attention_backend - if backend is None: - config = server_args.pipeline_config - if config is not None: - backend = getattr(config, "diffusers_attention_backend", None) - if backend is None: return diff --git a/python/sglang/multimodal_gen/runtime/server_args.py b/python/sglang/multimodal_gen/runtime/server_args.py index 2539b87c3..72126e0ac 100644 --- a/python/sglang/multimodal_gen/runtime/server_args.py +++ b/python/sglang/multimodal_gen/runtime/server_args.py @@ -152,59 +152,6 @@ def _sanitize_for_logging(obj: Any, key_hint: str | None = None) -> Any: return "" -class ExecutionMode(str, Enum): - """ - Enumeration for different pipeline modes. - - Inherits from str to allow string comparison for backward compatibility. - """ - - INFERENCE = "inference" - - @classmethod - def from_string(cls, value: str) -> "ExecutionMode": - """Convert string to ExecutionMode enum.""" - try: - return cls(value.lower()) - except ValueError: - raise ValueError( - f"Invalid mode: {value}. Must be one of: {', '.join([m.value for m in cls])}" - ) from None - - @classmethod - def choices(cls) -> list[str]: - """Get all available choices as strings for argparse.""" - return [mode.value for mode in cls] - - -class WorkloadType(str, Enum): - """ - Enumeration for different workload types. - - Inherits from str to allow string comparison for backward compatibility. - """ - - I2V = "i2v" # Image to Video - T2V = "t2v" # Text to Video - T2I = "t2i" # Text to Image - I2I = "i2i" # Image to Image - - @classmethod - def from_string(cls, value: str) -> "WorkloadType": - """Convert string to WorkloadType enum.""" - try: - return cls(value.lower()) - except ValueError: - raise ValueError( - f"Invalid workload type: {value}. Must be one of: {', '.join([m.value for m in cls])}" - ) from None - - @classmethod - def choices(cls) -> list[str]: - """Get all available choices as strings for argparse.""" - return [workload.value for workload in cls] - - class Backend(str, Enum): """ Enumeration for different model backends. @@ -648,13 +595,6 @@ class ServerArgs: default=None, help="Configuration for the attention backend. Can be a JSON string, a path to a JSON/YAML file, or key=value pairs.", ) - parser.add_argument( - "--diffusers-attention-backend", - type=str, - dest="attention_backend", - default=None, - help=argparse.SUPPRESS, - ) parser.add_argument( "--cache-dit-config", type=str, @@ -1070,12 +1010,6 @@ class ServerArgs: @classmethod def from_kwargs(cls, **kwargs: Any) -> "ServerArgs": - # Convert mode string to enum if necessary - if "mode" in kwargs and isinstance(kwargs["mode"], str): - kwargs["mode"] = ExecutionMode.from_string(kwargs["mode"]) - # Convert workload_type string to enum if necessary - if "workload_type" in kwargs and isinstance(kwargs["workload_type"], str): - kwargs["workload_type"] = WorkloadType.from_string(kwargs["workload_type"]) # Convert backend string to enum if necessary if "backend" in kwargs and isinstance(kwargs["backend"], str): kwargs["backend"] = Backend.from_string(kwargs["backend"])