[NPU] Diffusion CI fixes (#43210)
This commit is contained in:
@@ -344,6 +344,7 @@ class MediaRef(msgspec.Struct, kw_only=True, frozen=True):
|
||||
max_tokens_per_frame: Optional[int] = None
|
||||
max_image_tokens: Optional[int] = None
|
||||
use_audio: Optional[bool] = None
|
||||
image_grid_thw: Optional[ImageGridThw] = None
|
||||
|
||||
@classmethod
|
||||
def from_json_value(cls, value: Any) -> "MediaRef":
|
||||
@@ -506,6 +507,9 @@ NullableTopLogprobs = Optional[TopLogprobRow]
|
||||
# sglang.api.v1.HiddenStateRow: JSON bare array.
|
||||
HiddenStateRow = List[float]
|
||||
|
||||
# sglang.api.v1.ImageGridThw: JSON bare array.
|
||||
ImageGridThw = List[Int64List]
|
||||
|
||||
# sglang.api.v1.MediaItem: JSON: the value's shape picks the arm.
|
||||
MediaItem = Union[str, MediaRef]
|
||||
|
||||
@@ -1267,7 +1271,7 @@ def encode_GenerateStreamError(v: GenerateStreamError) -> Dict[str, Any]:
|
||||
return d
|
||||
|
||||
|
||||
_FIELDS_MediaRef = ("url", "detail", "max_dynamic_patch", "content_hash", "min_pixels", "max_pixels", "total_max_pixels", "fps", "num_frames", "min_frames", "max_frames", "max_tokens_per_frame", "max_image_tokens", "use_audio",)
|
||||
_FIELDS_MediaRef = ("url", "detail", "max_dynamic_patch", "content_hash", "min_pixels", "max_pixels", "total_max_pixels", "fps", "num_frames", "min_frames", "max_frames", "max_tokens_per_frame", "max_image_tokens", "use_audio", "image_grid_thw",)
|
||||
|
||||
|
||||
def decode_MediaRef(value: Any) -> MediaRef:
|
||||
@@ -1302,6 +1306,8 @@ def decode_MediaRef(value: Any) -> MediaRef:
|
||||
kw["max_image_tokens"] = None if x is None else _expect_int(x, expected="i64")
|
||||
elif key == "use_audio":
|
||||
kw["use_audio"] = None if x is None else _expect_bool(x, expected="a boolean")
|
||||
elif key == "image_grid_thw":
|
||||
kw["image_grid_thw"] = None if x is None else decode_ImageGridThw(x)
|
||||
else:
|
||||
raise _unknown_field(key, fields=_FIELDS_MediaRef)
|
||||
return MediaRef(**kw)
|
||||
@@ -1336,9 +1342,19 @@ def encode_MediaRef(v: MediaRef) -> Dict[str, Any]:
|
||||
d["max_image_tokens"] = v.max_image_tokens
|
||||
if v.use_audio is not None:
|
||||
d["use_audio"] = v.use_audio
|
||||
if v.image_grid_thw is not None:
|
||||
d["image_grid_thw"] = encode_ImageGridThw(v.image_grid_thw)
|
||||
return d
|
||||
|
||||
|
||||
def decode_ImageGridThw(value: Any) -> ImageGridThw:
|
||||
return [decode_Int64List(e) for e in _expect_seq(value, expected="a sequence")]
|
||||
|
||||
|
||||
def encode_ImageGridThw(v: ImageGridThw) -> List[Any]:
|
||||
return [encode_Int64List(e) for e in v]
|
||||
|
||||
|
||||
def decode_MediaItem(value: Any) -> MediaItem:
|
||||
if isinstance(value, str):
|
||||
return value
|
||||
|
||||
+17
@@ -362,6 +362,23 @@ class GlmImageAR(PipelineStage):
|
||||
e,
|
||||
)
|
||||
raise
|
||||
except requests.HTTPError as e:
|
||||
# HTTPError alone omits the server's request-validation details.
|
||||
response = e.response
|
||||
if response is not None:
|
||||
logger.error(
|
||||
"SGLang encoder at %s returned HTTP %s: %s",
|
||||
server_args.srt_encoder_url,
|
||||
response.status_code,
|
||||
response.text[:2000],
|
||||
)
|
||||
else:
|
||||
logger.error(
|
||||
"SGLang encoder at %s failed with no response: %s",
|
||||
server_args.srt_encoder_url,
|
||||
e,
|
||||
)
|
||||
raise
|
||||
except requests.RequestException as e:
|
||||
logger.error(
|
||||
"SGLang encoder request to %s failed: %s",
|
||||
|
||||
@@ -203,6 +203,7 @@ TWO_NPU_CASES: list[DiffusionTestCase] = [
|
||||
"seed": 1101,
|
||||
},
|
||||
),
|
||||
pin_consistency_quality=False,
|
||||
run_perf_check=True,
|
||||
run_consistency_check=True,
|
||||
run_component_accuracy_check=False,
|
||||
|
||||
@@ -40,6 +40,7 @@ from sglang.multimodal_gen.test.test_utils import (
|
||||
SGL_TEST_FILES_CI_DATA_REPO,
|
||||
SGL_TEST_FILES_CI_DATA_REVISION,
|
||||
)
|
||||
from sglang.srt.environ import envs
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -348,6 +349,8 @@ class DiffusionTestCase:
|
||||
run_lora_dynamic_load_check: bool = False
|
||||
run_lora_dynamic_switch_check: bool = False
|
||||
run_multi_lora_api_check: bool = False
|
||||
# Cached MiniMax goldens require its implicit-quality cache mode.
|
||||
pin_consistency_quality: bool = True
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if self.perf_repeat_requests < 1:
|
||||
@@ -377,7 +380,19 @@ class DiffusionTestCase:
|
||||
# removes the pin.
|
||||
# Replaces rather than mutates: several cases share one module-level
|
||||
# sampling-params instance.
|
||||
if self.run_consistency_check and "quality" not in self.sampling_params.extras:
|
||||
cache_dit_requested = self.sampling_params.extras.get("enable_cache_dit")
|
||||
if cache_dit_requested is None:
|
||||
cache_dit_requested = self.server_args.enable_cache_dit or (
|
||||
self.server_args.env_vars.get("SGLANG_CACHE_DIT_ENABLED", "").lower()
|
||||
== "true"
|
||||
)
|
||||
# Cached goldens require the cached path; an explicit exact tier disables
|
||||
# MiniMax-H3's environment-selected Cache-DiT configuration.
|
||||
if (
|
||||
self.run_consistency_check
|
||||
and "quality" not in self.sampling_params.extras
|
||||
and (self.pin_consistency_quality or not cache_dit_requested)
|
||||
):
|
||||
object.__setattr__(
|
||||
self,
|
||||
"sampling_params",
|
||||
@@ -714,16 +729,22 @@ MODELOPT_QWEN_IMAGE_2512_NVFP4_CI_sampling_params = replace(
|
||||
extras={"num_inference_steps": 50, "seed": 0},
|
||||
)
|
||||
|
||||
# CI prefetches the input; standalone runs retain the release URL fallback.
|
||||
TI2I_QWEN_IMAGE_EDIT_INPUT = (
|
||||
envs.SGLANG_TEST_TI2I_INPUT_IMAGE.get()
|
||||
or "https://github.com/lm-sys/lm-sys.github.io/releases/download/test/TI2I_Qwen_Image_Edit_Input.jpg"
|
||||
)
|
||||
|
||||
MODELOPT_TI2I_CI_sampling_params = DiffusionSamplingParams(
|
||||
prompt="Convert 2D style to 3D style",
|
||||
image_path="https://github.com/lm-sys/lm-sys.github.io/releases/download/test/TI2I_Qwen_Image_Edit_Input.jpg",
|
||||
image_path=TI2I_QWEN_IMAGE_EDIT_INPUT,
|
||||
output_size="512x512",
|
||||
extras={"num_inference_steps": 8, "seed": 0},
|
||||
)
|
||||
|
||||
TI2I_sampling_params = DiffusionSamplingParams(
|
||||
prompt="Convert 2D style to 3D style",
|
||||
image_path="https://github.com/lm-sys/lm-sys.github.io/releases/download/test/TI2I_Qwen_Image_Edit_Input.jpg",
|
||||
image_path=TI2I_QWEN_IMAGE_EDIT_INPUT,
|
||||
)
|
||||
|
||||
MULTI_IMAGE_TI2I_sampling_params = DiffusionSamplingParams(
|
||||
|
||||
@@ -40,9 +40,14 @@ SGL_TEST_FILES_CI_DATA_REPO = "sgl-project/ci-data-diffusion"
|
||||
SGL_TEST_FILES_CI_DATA_REVISION = "75992dbf1d6eaeacbc1c2cd6beb48f77dd7ae4f7"
|
||||
|
||||
# The NPU pin is kept as a separate branch so ascend GT can be bumped independently
|
||||
# when it's regenerated on its own cadence.
|
||||
# when it's regenerated on its own cadence. 2173af2f re-generated the MiniMax-H3
|
||||
# frames after #38671 made num_inference_steps=50 run 50 denoising updates
|
||||
# (previously 49). The regeneration must run on a branch where
|
||||
# pin_consistency_quality=False for this case (npu_diffusion_ci_fixes_2): generating
|
||||
# on main pins quality='exact', which disables MiniMax-H3's env-selected Cache-DiT
|
||||
# and produces a golden from a different code path than the test runs.
|
||||
if current_platform.is_npu():
|
||||
SGL_TEST_FILES_CI_DATA_REVISION = "609c4cef31864d75dbd11fe3c26b8ae09469204d"
|
||||
SGL_TEST_FILES_CI_DATA_REVISION = "2173af2fe762e2c95e18b06d017604d520196eff"
|
||||
|
||||
SGL_TEST_FILES_CONSISTENCY_GT_ROOT = (
|
||||
"https://raw.githubusercontent.com/"
|
||||
|
||||
@@ -22,6 +22,42 @@ from sglang.multimodal_gen.test.server.testcase_configs import (
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("request_override", [None, True, False])
|
||||
@pytest.mark.parametrize("pin_consistency_quality", [True, False])
|
||||
def test_cached_consistency_case_preserves_cache_selection(
|
||||
request_override, pin_consistency_quality
|
||||
):
|
||||
extras = {} if request_override is None else {"enable_cache_dit": request_override}
|
||||
case = DiffusionTestCase(
|
||||
"cached_consistency",
|
||||
DiffusionServerArgs(
|
||||
model_path="test",
|
||||
modality="video",
|
||||
env_vars={"SGLANG_CACHE_DIT_ENABLED": "true"},
|
||||
),
|
||||
DiffusionSamplingParams(prompt="test", extras=extras),
|
||||
run_consistency_check=True,
|
||||
pin_consistency_quality=pin_consistency_quality,
|
||||
)
|
||||
if pin_consistency_quality or request_override is False:
|
||||
assert case.sampling_params.extras["quality"] == "exact"
|
||||
else:
|
||||
# An explicit quality tier suppresses the legacy MiniMax cache mode.
|
||||
assert "quality" not in case.sampling_params.extras
|
||||
|
||||
|
||||
@pytest.mark.parametrize("pin_consistency_quality", [True, False])
|
||||
def test_cached_consistency_case_preserves_explicit_quality(pin_consistency_quality):
|
||||
case = DiffusionTestCase(
|
||||
"explicit_quality",
|
||||
DiffusionServerArgs(model_path="test", modality="video", enable_cache_dit=True),
|
||||
DiffusionSamplingParams(prompt="test", extras={"quality": "exact"}),
|
||||
run_consistency_check=True,
|
||||
pin_consistency_quality=pin_consistency_quality,
|
||||
)
|
||||
assert case.sampling_params.extras["quality"] == "exact"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("generate_baseline", [False, True])
|
||||
def test_e2e_only_does_not_require_stage_metrics(monkeypatch, generate_baseline):
|
||||
monkeypatch.setenv("SGLANG_GEN_BASELINE", str(int(generate_baseline)))
|
||||
|
||||
@@ -376,6 +376,7 @@ class Envs:
|
||||
SGLANG_IS_IN_CI = EnvBool(False)
|
||||
SGLANG_IS_IN_CI_AMD = EnvBool(False)
|
||||
SGLANG_TEST_MAX_RETRY = EnvInt(None)
|
||||
SGLANG_TEST_TI2I_INPUT_IMAGE = EnvStr(None)
|
||||
# Expand jit_kernel test grids to their full parameter ranges (nightly).
|
||||
SGLANG_JIT_KERNEL_RUN_FULL_TESTS = EnvBool(False)
|
||||
SGLANG_SKIP_SGL_KERNEL_VERSION_CHECK = EnvBool(False)
|
||||
|
||||
Reference in New Issue
Block a user