[diffusion] CI: infer diffusion test sampling params from task type (#26530)

This commit is contained in:
Mick
2026-06-01 11:57:41 +08:00
committed by GitHub
parent a779791b3f
commit 4b0453f814
4 changed files with 97 additions and 65 deletions
@@ -18,7 +18,6 @@ from sglang.multimodal_gen.test.server.testcase_configs import (
DiffusionSamplingParams,
DiffusionServerArgs,
DiffusionTestCase,
HUNYUAN3D_SHAPE_sampling_params,
MODELOPT_T2I_CI_sampling_params,
MODELOPT_T2V_CI_sampling_params,
MODELOPT_TI2I_CI_sampling_params,
@@ -27,8 +26,6 @@ from sglang.multimodal_gen.test.server.testcase_configs import (
MULTI_IMAGE_TI2I_UPLOAD_sampling_params,
T2I_sampling_params,
T2V_sampling_params,
TI2I_sampling_params,
TI2V_sampling_params,
_make_modelopt_ci_case,
_with_default_num_gpus,
)
@@ -65,7 +62,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
DiffusionServerArgs(
model_path=DEFAULT_QWEN_IMAGE_MODEL_NAME_FOR_TEST,
),
T2I_sampling_params,
),
DiffusionTestCase(
"qwen_image_t2i_cache_dit_enabled",
@@ -73,7 +69,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
model_path=DEFAULT_QWEN_IMAGE_MODEL_NAME_FOR_TEST,
enable_cache_dit=True,
),
T2I_sampling_params,
),
DiffusionTestCase(
"qwen_image_t2i_cache_dit_scm_config_diffusers_1gpu",
@@ -100,7 +95,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
DiffusionTestCase(
"flux_image_t2i",
DiffusionServerArgs(model_path=DEFAULT_FLUX_1_DEV_MODEL_NAME_FOR_TEST),
T2I_sampling_params,
),
# TODO: modeling of flux different from official flux, so weights can't be loaded
# consider opting for a different quantized hf-repo
@@ -143,12 +137,10 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
dit_layerwise_offload=True,
dit_offload_prefetch_size=2,
),
T2I_sampling_params,
),
DiffusionTestCase(
"zimage_image_t2i",
DiffusionServerArgs(model_path=DEFAULT_SMALL_MODEL_NAME_FOR_TEST),
T2I_sampling_params,
),
DiffusionTestCase(
"zimage_image_t2i_fp8",
@@ -156,7 +148,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
model_path=DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
extras=["--transformer-path MickJ/Z-Image-Turbo-fp8"],
),
T2I_sampling_params,
),
# Multi-LoRA test case for Z-Image-Turbo
DiffusionTestCase(
@@ -166,7 +157,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
lora_path="reverentelusarca/elusarca-anime-style-lora-z-image-turbo",
second_lora_path="tarn59/pixel_art_style_lora_z_image_turbo",
),
T2I_sampling_params,
run_lora_basic_api_check=True,
run_lora_dynamic_switch_check=True,
run_multi_lora_api_check=True,
@@ -175,7 +165,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
DiffusionTestCase(
"qwen_image_edit_ti2i",
DiffusionServerArgs(model_path=DEFAULT_QWEN_IMAGE_EDIT_MODEL_NAME_FOR_TEST),
TI2I_sampling_params,
),
DiffusionTestCase(
"qwen_image_edit_2509_ti2i",
@@ -189,7 +178,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
DiffusionServerArgs(
model_path=DEFAULT_QWEN_IMAGE_EDIT_2511_MODEL_NAME_FOR_TEST,
),
TI2I_sampling_params,
),
DiffusionTestCase(
"qwen_image_layered_i2i",
@@ -201,7 +189,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
DiffusionTestCase(
"joyai_image_edit_ti2i",
DiffusionServerArgs(model_path=DEFAULT_JOYAI_IMAGE_EDIT_MODEL_NAME_FOR_TEST),
TI2I_sampling_params,
run_consistency_check=False,
run_component_accuracy_check=False,
),
@@ -223,7 +210,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
DiffusionServerArgs(
model_path=DEFAULT_WAN_2_1_T2V_1_3B_MODEL_NAME_FOR_TEST,
),
T2V_sampling_params,
),
# TeaCache acceleration test for Wan video model
DiffusionTestCase(
@@ -306,7 +292,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
DiffusionTestCase(
"flux_2_ti2i",
DiffusionServerArgs(model_path=DEFAULT_FLUX_2_DEV_MODEL_NAME_FOR_TEST),
TI2I_sampling_params,
),
DiffusionTestCase(
"flux_2_t2i_customized_vae_path",
@@ -322,7 +307,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
DiffusionServerArgs(
model_path="FastVideo/FastHunyuan-diffusers",
),
T2V_sampling_params,
),
# === Text and Image to Video (TI2V) ===
DiffusionTestCase(
@@ -330,14 +314,12 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
DiffusionServerArgs(
model_path=DEFAULT_WAN_2_2_TI2V_5B_MODEL_NAME_FOR_TEST,
),
TI2V_sampling_params,
),
DiffusionTestCase(
"fastwan2_2_ti2v_5b",
DiffusionServerArgs(
model_path="FastVideo/FastWan2.2-TI2V-5B-FullAttn-Diffusers",
),
TI2V_sampling_params,
),
# flaky
# === Helios T2V ===
@@ -386,7 +368,6 @@ ONE_GPU_CASES: list[DiffusionTestCase] = [
"SGLANG_LTX2_SNAPSHOT_RELEASE_EMPTY_CACHE": "true",
},
),
T2I_sampling_params,
run_component_accuracy_check=False,
),
]
@@ -399,7 +380,6 @@ if not current_platform.is_hip():
DiffusionServerArgs(
model_path="tencent/Hunyuan3D-2",
),
HUNYUAN3D_SHAPE_sampling_params,
run_consistency_check=False,
),
)
@@ -411,7 +391,6 @@ if not current_platform.is_hip():
DiffusionServerArgs(
model_path="IPostYellow/TurboWan2.1-T2V-1.3B-Diffusers",
),
T2V_sampling_params,
)
)
# Skip all ModelOpt tests on AMD: FP8 requires torch._scaled_mm (HIPBLAS_STATUS_NOT_SUPPORTED
@@ -512,7 +491,6 @@ TWO_GPU_CASES = [
DiffusionServerArgs(
model_path=DEFAULT_WAN_2_2_I2V_A14B_MODEL_NAME_FOR_TEST,
),
TI2V_sampling_params,
),
DiffusionTestCase(
"wan2_2_t2v_a14b_2gpu",
@@ -520,7 +498,6 @@ TWO_GPU_CASES = [
model_path=DEFAULT_WAN_2_2_T2V_A14B_MODEL_NAME_FOR_TEST,
extras=["--ulysses-degree=2"],
),
T2V_sampling_params,
),
# TeaCache bring-up test for Wan2.2 T2V A14B — verifies enable_teacache=True
# doesn't crash. Perf check disabled because Wan2.2-specific TeaCache
@@ -571,7 +548,6 @@ TWO_GPU_CASES = [
model_path=DEFAULT_WAN_2_1_T2V_1_3B_MODEL_NAME_FOR_TEST,
cfg_parallel=True,
),
T2V_sampling_params,
),
DiffusionTestCase(
"wan2_1_t2v_1_3b_cache_dit_sp_only_2gpu",
@@ -599,7 +575,6 @@ TWO_GPU_CASES = [
model_path=DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
extras=["--use-fsdp-inference"],
),
T2I_sampling_params,
),
DiffusionTestCase(
"mova_360p_tp2",
@@ -608,7 +583,6 @@ TWO_GPU_CASES = [
tp_size=2,
dit_layerwise_offload=True,
),
TI2V_sampling_params,
run_perf_check=False,
),
DiffusionTestCase(
@@ -619,7 +593,6 @@ TWO_GPU_CASES = [
ulysses_degree=2,
dit_layerwise_offload=True,
),
TI2V_sampling_params,
run_perf_check=False,
),
DiffusionTestCase(
@@ -640,7 +613,6 @@ TWO_GPU_CASES = [
"--pipeline-class-name LTX2TwoStagePipeline --ltx2-two-stage-device-mode original",
],
),
TI2V_sampling_params,
run_component_accuracy_check=False,
),
DiffusionTestCase(
@@ -649,7 +621,6 @@ TWO_GPU_CASES = [
model_path=DEFAULT_WAN_2_1_I2V_14B_480P_MODEL_NAME_FOR_TEST,
extras=["--ulysses-degree=2"],
),
TI2V_sampling_params,
),
DiffusionTestCase(
"ltx_2.3_two_stage_t2v_2gpus",
@@ -672,7 +643,6 @@ TWO_GPU_CASES = [
lora_path="starsfriday/Wan2.1-Divine-Power-LoRA",
extras=["--ulysses-degree=2"],
),
TI2V_sampling_params,
run_lora_basic_api_check=True,
),
DiffusionTestCase(
@@ -681,7 +651,6 @@ TWO_GPU_CASES = [
model_path=DEFAULT_WAN_2_1_I2V_14B_720P_MODEL_NAME_FOR_TEST,
extras=["--ulysses-degree=2"],
),
TI2V_sampling_params,
),
DiffusionTestCase(
"qwen_image_t2i_2_gpus",
@@ -691,7 +660,6 @@ TWO_GPU_CASES = [
ulysses_degree=1,
ring_degree=2,
),
T2I_sampling_params,
),
DiffusionTestCase(
"zimage_image_t2i_2_gpus",
@@ -699,7 +667,6 @@ TWO_GPU_CASES = [
model_path=DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
ulysses_degree=2,
),
T2I_sampling_params,
),
DiffusionTestCase(
"zimage_image_t2i_2_gpus_non_square",
@@ -718,7 +685,6 @@ TWO_GPU_CASES = [
DiffusionServerArgs(
model_path=DEFAULT_FLUX_1_DEV_MODEL_NAME_FOR_TEST,
),
T2I_sampling_params,
),
DiffusionTestCase(
"flux_2_image_t2i_2_gpus",
@@ -734,7 +700,6 @@ TWO_GPU_CASES = [
model_path="Lightricks/LTX-2.3",
cfg_parallel=True,
),
TI2V_sampling_params,
run_component_accuracy_check=False,
),
]
@@ -2613,38 +2613,38 @@
"LTX2HalveResolutionStage": 0.06,
"LTX2LoRASwitchStage": 0.01,
"LTX2SigmaPreparationStage": 0.27,
"TimestepPreparationStage": 22.21,
"TimestepPreparationStage": 60.49,
"LTX2AVLatentPreparationStage": 0.18,
"LTX2ImageEncodingStage": 0.02,
"LTX2AVDenoisingStage": 16162.58,
"LTX2UpsampleStage": 3.23,
"LTX2RefinementStage": 1593.51,
"LTX2AVDecodingStage": 650.0,
"LTX2ImageEncodingStage": 1185.13,
"LTX2AVDenoisingStage": 22802.53,
"LTX2UpsampleStage": 37.42,
"LTX2RefinementStage": 3123.85,
"LTX2AVDecodingStage": 3266.55,
"per_frame_generation": null
},
"denoise_step_ms": {
"0": 1565.09,
"1": 1034.27,
"2": 989.12,
"3": 1048.34,
"4": 938.4,
"5": 952.6,
"6": 992.87,
"7": 843.37,
"8": 808.52,
"9": 715.13,
"10": 1100.0,
"11": 717.4,
"12": 790.42,
"13": 761.88,
"14": 375.63,
"15": 453.87,
"16": 448.42,
"17": 451.66
"0": 1942.27,
"1": 1736.24,
"2": 1740.39,
"3": 1816.87,
"4": 1576.27,
"5": 1611.1,
"6": 1586.7,
"7": 1559.69,
"8": 1456.36,
"9": 1591.21,
"10": 1534.93,
"11": 852.43,
"12": 836.03,
"13": 855.98,
"14": 443.03,
"15": 957.19,
"16": 876.98,
"17": 878.4
},
"expected_e2e_ms": 22500.0,
"expected_avg_denoise_ms": 900.0,
"expected_median_denoise_ms": 980.0,
"expected_e2e_ms": 30068.97,
"expected_avg_denoise_ms": 1325.11,
"expected_median_denoise_ms": 1547.31,
"estimated_full_test_time_s": 363.2
}
}
@@ -21,6 +21,7 @@ from __future__ import annotations
import json
import os
import shlex
import statistics
from dataclasses import dataclass, field, replace
from functools import lru_cache
@@ -28,7 +29,10 @@ from pathlib import Path
from typing import Sequence
from sglang.multimodal_gen.configs.pipeline_configs.base import ModelTaskType
from sglang.multimodal_gen.registry import get_model_info
from sglang.multimodal_gen.registry import (
get_model_info,
get_pipeline_config_classes,
)
from sglang.multimodal_gen.runtime.utils.perf_logger import RequestPerfRecord
@@ -253,7 +257,7 @@ class DiffusionTestCase:
id: str # pytest test id and scenario name
server_args: DiffusionServerArgs
sampling_params: DiffusionSamplingParams
sampling_params: DiffusionSamplingParams | None = None
run_perf_check: bool = True
run_consistency_check: bool = True
run_component_accuracy_check: bool = True
@@ -265,6 +269,13 @@ class DiffusionTestCase:
run_multi_lora_api_check: bool = False
def __post_init__(self) -> None:
if self.sampling_params is None:
object.__setattr__(
self,
"sampling_params",
get_default_sampling_params_for_server_args(self.server_args),
)
has_startup_lora = self.server_args.lora_path is not None
has_dynamic_lora = self.server_args.dynamic_lora_path is not None
has_second_lora = self.server_args.second_lora_path is not None
@@ -438,6 +449,62 @@ HUNYUAN3D_SHAPE_sampling_params = DiffusionSamplingParams(
image_path="https://raw.githubusercontent.com/sgl-project/sgl-test-files/main/diffusion-ci/consistency_gt/1-gpu/hunyuan3d_2_0/hunyuan3d.png",
)
def _get_extra_arg_value(extras: Sequence[str], option_name: str) -> str | None:
tokens: list[str] = []
for item in extras:
tokens.extend(shlex.split(item))
option_prefix = f"{option_name}="
for index, token in enumerate(tokens):
if token.startswith(option_prefix):
return token[len(option_prefix) :]
if token == option_name and index + 1 < len(tokens):
return tokens[index + 1]
return None
def get_model_task_type_for_server_args(
server_args: DiffusionServerArgs,
) -> ModelTaskType:
pipeline_class_name = _get_extra_arg_value(
server_args.extras, "--pipeline-class-name"
)
if pipeline_class_name:
config_classes = get_pipeline_config_classes(pipeline_class_name)
if config_classes is not None:
pipeline_config_cls, _ = config_classes
return pipeline_config_cls.task_type
model_info = get_model_info(server_args.model_path)
if model_info is None:
raise ValueError(f"Could not resolve model info for {server_args.model_path!r}")
return model_info.pipeline_config_cls.task_type
def get_default_sampling_params_for_model_task(
task_type: ModelTaskType,
) -> DiffusionSamplingParams:
if task_type == ModelTaskType.T2I:
return T2I_sampling_params
if task_type in (ModelTaskType.I2I, ModelTaskType.TI2I):
return TI2I_sampling_params
if task_type == ModelTaskType.T2V:
return T2V_sampling_params
if task_type in (ModelTaskType.I2V, ModelTaskType.TI2V):
return TI2V_sampling_params
if task_type == ModelTaskType.I2M:
return HUNYUAN3D_SHAPE_sampling_params
raise ValueError(f"No default sampling params for model task {task_type!r}")
def get_default_sampling_params_for_server_args(
server_args: DiffusionServerArgs,
) -> DiffusionSamplingParams:
task_type = get_model_task_type_for_server_args(server_args)
return get_default_sampling_params_for_model_task(task_type)
MODELOPT_FLUX1_FP8_TRANSFORMER = "lmsys/flux1-dev-modelopt-fp8-sglang-transformer"
MODELOPT_FLUX2_FP8_TRANSFORMER = "lmsys/flux2-dev-modelopt-fp8-sglang-transformer"
MODELOPT_WAN22_FP8_MODEL = "nvidia/Wan2.2-T2V-A14B-Diffusers-FP8"
@@ -33,7 +33,7 @@ if TYPE_CHECKING:
logger = init_logger(__name__)
SGL_TEST_FILES_CI_DATA_REVISION = "68a42bf2229361497e6c4ff22ce89a157bf2f531"
SGL_TEST_FILES_CI_DATA_REVISION = "a17a6cd676d16d0f6c93cc80d0144138ab87dca1"
SGL_TEST_FILES_CONSISTENCY_GT_ROOT = (
"https://raw.githubusercontent.com/"
f"sgl-project/ci-data/{SGL_TEST_FILES_CI_DATA_REVISION}/"