[CI] Reducing mithril-h100-pool in ready&merge CI, optimize ready CI duration (#4354)

Signed-off-by: [Your Name] <your.email@example.com>
Signed-off-by: wangyu <410167048@qq.com>
Signed-off-by: wangyu <53896905+yenuo26@users.noreply.github.com>
Signed-off-by: Hongsheng Liu <liuhongsheng4@huawei.com>
Signed-off-by: [Your Name] <[Your Email]>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
wangyuandHongsheng Liu authored and GitHub committed 2026-06-29 05:17:57 +00:00
1 parent e4026a50ad
commit 7619ed6b82
84 files changed
+1718 -2428

No files matched your search

+95 -20
View File
@@ -17,6 +17,7 @@ import soundfile as sf
from PIL import Image
from tests.helpers.media import (
convert_audio_bytes_to_text,
cosine_similarity_text,
)
@@ -374,8 +375,15 @@ def _estimate_voice_gender_from_audio(audio_bytes: bytes) -> str:
return "unknown"
def _assert_preset_voice_gender_from_audio(audio_bytes: bytes | None, voice_name: str | None) -> None:
def _assert_preset_voice_gender_from_audio(
audio_bytes: bytes | None,
voice_name: str | None,
*,
response_format: str | None = None,
) -> None:
"""If ``voice_name`` matches a known preset, assert classifier gender matches (skip when unknown)."""
if response_format == "pcm":
return
if not voice_name or not audio_bytes:
return
key = str(voice_name).lower()
@@ -432,6 +440,61 @@ def _assert_pcm_int16_speech_hnr(audio_bytes: bytes, min_hnr_db: float = _MIN_PC
)
def _response_has_audio_output(response: Any) -> bool:
if response.audio_bytes:
return len(response.audio_bytes) > 0
if isinstance(getattr(response, "audio_content", None), str) and response.audio_content.strip():
return True
audio_data = getattr(response, "audio_data", None)
return bool(audio_data)
def _omni_assertion_needs_audio_transcript(request_config: dict[str, Any], run_level: str) -> bool:
if run_level not in {"advanced_model", "full_model"}:
return False
modalities = request_config.get("modalities", ["text", "audio"])
if "audio" not in modalities:
return False
keywords_dict = request_config.get("key_words", {}) or {}
if keywords_dict.get("audio") and "text" not in modalities:
return True
if request_config.get("audio_ref_text"):
return True
return "text" in modalities
def _speech_assertion_needs_audio_transcript(request_config: dict[str, Any], run_level: str) -> bool:
if run_level not in {"advanced_model", "full_model"}:
return False
if request_config.get("response_format") == "pcm":
return False
return bool(request_config.get("input"))
def _resolve_audio_transcript(
response: Any,
request_config: dict[str, Any],
run_level: str,
*,
speech_api: bool,
) -> str | None:
"""Run Whisper only when this run_level / request_config needs a transcript for assertions."""
needs = (
_speech_assertion_needs_audio_transcript(request_config, run_level)
if speech_api
else _omni_assertion_needs_audio_transcript(request_config, run_level)
)
if not needs:
return None
existing = getattr(response, "audio_content", None)
if isinstance(existing, str) and existing.strip():
return existing
audio_bytes = getattr(response, "audio_bytes", None)
if not audio_bytes:
return None
return convert_audio_bytes_to_text(audio_bytes)
def assert_omni_response(response: Any, request_config: dict[str, Any], run_level):
"""
Validate response results.
@@ -447,15 +510,18 @@ def assert_omni_response(response: Any, request_config: dict[str, Any], run_leve
modalities = request_config.get("modalities", ["text", "audio"])
if run_level in {"advanced_model", "full_model"}:
transcript = _resolve_audio_transcript(response, request_config, run_level, speech_api=False)
# Verify output success
if "audio" in modalities:
assert response.audio_content is not None, "No audio output is generated"
print(f"audio content is: {response.audio_content}")
assert _response_has_audio_output(response), "No audio output is generated"
if transcript is not None:
print(f"audio content is: {transcript}")
speaker = request_config.get("speaker")
if speaker:
_assert_preset_voice_gender_from_audio(
response.audio_bytes,
speaker,
response_format=request_config.get("response_format"),
)
if "text" in modalities:
assert response.text_content is not None, "No text output is generated"
@@ -474,7 +540,8 @@ def assert_omni_response(response: Any, request_config: dict[str, Any], run_leve
)
else:
if keywords:
audio_lower = response.audio_content.lower()
assert transcript is not None, "No audio transcript for keyword validation"
audio_lower = transcript.lower()
assert any(str(kw).lower() in audio_lower for kw in keywords), (
"The output does not contain any of the keywords."
)
@@ -484,7 +551,7 @@ def assert_omni_response(response: Any, request_config: dict[str, Any], run_leve
audio_ref_text = request_config.get("audio_ref_text")
similarity_threshold = request_config.get("similarity_threshold", 0.8)
if "text" in modalities:
transcript = (response.audio_content or "").strip()
assert transcript is not None, "No audio transcript for similarity validation"
text_output = (response.text_content or "").strip()
# For very short outputs (e.g. one-word answers), n-gram cosine
# similarity with length penalty is unreliable because Whisper
@@ -513,8 +580,9 @@ def assert_omni_response(response: Any, request_config: dict[str, Any], run_leve
print(f"similarity is: {similarity}")
assert similarity > similarity_threshold, "The audio content is not same as the text"
if audio_ref_text:
assert transcript is not None, "No audio transcript for reference-text validation"
audio_similarity = cosine_similarity_text(
response.audio_content.lower(),
transcript.strip().lower(),
str(audio_ref_text).lower(),
)
assert audio_similarity > similarity_threshold, (
@@ -557,8 +625,6 @@ def assert_audio_speech_response(response: Any, request_config: dict[str, Any],
req_fmt = request_config.get("response_format")
if req_fmt == "pcm" and response.audio_bytes:
min_hnr_db = float(request_config.get("min_hnr_db", _MIN_PCM_SPEECH_HNR_DB))
_assert_pcm_int16_speech_hnr(response.audio_bytes, min_hnr_db=min_hnr_db)
if response.audio_format:
assert "pcm" in response.audio_format.lower(), (
f"Expected audio/pcm content-type, got {response.audio_format!r}"
@@ -566,18 +632,27 @@ def assert_audio_speech_response(response: Any, request_config: dict[str, Any],
elif req_fmt == "wav" and response.audio_format:
assert req_fmt in response.audio_format
if run_level in {"advanced_model", "full_model"} and req_fmt != "pcm":
expected_text = request_config.get("input")
if expected_text:
transcript = (response.audio_content or "").strip()
print(f"audio content is: {transcript}")
print(f"input text is: {expected_text}")
similarity = cosine_similarity_text(transcript.lower(), expected_text.lower())
print(f"Cosine similarity: {similarity:.3f}")
assert similarity > 0.9, (
f"Transcript doesn't match input: similarity={similarity:.2f}, transcript='{transcript}'"
)
_assert_preset_voice_gender_from_audio(response.audio_bytes, request_config.get("voice"))
if run_level in {"advanced_model", "full_model"}:
if req_fmt == "pcm" and response.audio_bytes:
min_hnr_db = float(request_config.get("min_hnr_db", _MIN_PCM_SPEECH_HNR_DB))
_assert_pcm_int16_speech_hnr(response.audio_bytes, min_hnr_db=min_hnr_db)
transcript = _resolve_audio_transcript(response, request_config, run_level, speech_api=True)
if transcript is not None:
expected_text = request_config.get("input")
if expected_text:
print(f"audio content is: {transcript}")
print(f"input text is: {expected_text}")
similarity = cosine_similarity_text(transcript.strip().lower(), str(expected_text).lower())
print(f"Cosine similarity: {similarity:.3f}")
assert similarity > 0.9, (
f"Transcript doesn't match input: similarity={similarity:.2f}, transcript='{transcript}'"
)
_assert_preset_voice_gender_from_audio(
response.audio_bytes,
request_config.get("voice"),
response_format=request_config.get("response_format"),
)
def assert_diffusion_response(response: "DiffusionResponse", request_config: dict[str, Any], run_level: str = None):
+1
View File
@@ -201,6 +201,7 @@ def run_pre_test_cleanup() -> None:
wait_for_gpu_memory_to_clear(
devices=list(range(num_gpus)),
threshold_ratio=0.05,
timeout_s=60,
)
except Exception as e:
print(f"Pre-test cleanup note: {e}")
+9 -54
View File
@@ -45,7 +45,6 @@ from tests.helpers.assertions import (
from tests.helpers.env import run_post_test_cleanup, run_pre_test_cleanup
from tests.helpers.media import (
_merge_base64_audio_to_segment,
convert_audio_bytes_to_text,
decode_b64_image,
)
from vllm_omni.config.stage_config import resolve_deploy_yaml
@@ -898,16 +897,13 @@ class OpenAIClientHandler:
if details := getattr(chunk.usage, "prompt_tokens_details", None):
result.cached_tokens = details.cached_tokens
audio_content = None
if audio_data:
merged_seg = _merge_base64_audio_to_segment(audio_data)
wav_buf = BytesIO()
merged_seg.export(wav_buf, format="wav")
result.audio_bytes = wav_buf.getvalue()
audio_content = convert_audio_bytes_to_text(result.audio_bytes)
result.text_content = text_content
result.audio_data = audio_data
result.audio_content = audio_content
result.e2e_latency = time.perf_counter() - wall_start
result.success = True
except Exception as e:
@@ -932,12 +928,9 @@ class OpenAIClientHandler:
result.prompt_tokens = usage.prompt_tokens
if details := getattr(usage, "prompt_tokens_details", None):
result.cached_tokens = details.cached_tokens
audio_content = None
if audio_data:
result.audio_bytes = base64.b64decode(audio_data)
audio_content = convert_audio_bytes_to_text(result.audio_bytes)
result.text_content = text_content
result.audio_content = audio_content
result.e2e_latency = time.perf_counter() - wall_start
if chat_completion.choices and chat_completion.choices[0].logprobs is not None:
result.logprobs = chat_completion.choices[0].logprobs.content
@@ -1587,6 +1580,8 @@ class OpenAIClientHandler:
extra_body["mm_processor_kwargs"] = mm
if "sampling_params_list" in request_config:
extra_body["sampling_params_list"] = request_config["sampling_params_list"]
if request_config.get("extra_body"):
extra_body.update(request_config["extra_body"])
create_kwargs: dict[str, Any] = {
"model": request_config.get("model"),
@@ -1648,8 +1643,8 @@ class OpenAIClientHandler:
Process streaming /v1/audio/speech responses into an OmniResponse.
This mirrors _process_stream_omni_response but operates on low-level
audio bytes and produces an OmniResponse with audio_content filled
from Whisper transcription.
audio bytes. Whisper transcription runs in assert_audio_speech_response
when the run_level requires it.
"""
result = OmniResponse()
@@ -1685,14 +1680,9 @@ class OpenAIClientHandler:
raise TypeError(f"Unsupported audio speech streaming response type: {type(response)}")
raw_bytes = bytes(data)
if response_format == "pcm":
transcript = None
else:
transcript = convert_audio_bytes_to_text(raw_bytes)
# Populate OmniResponse.
result.audio_bytes = raw_bytes
result.audio_content = transcript
result.e2e_latency = time.perf_counter() - wall_start
result.success = True
result.audio_format = getattr(response, "response", None)
@@ -1725,13 +1715,7 @@ class OpenAIClientHandler:
else:
raise TypeError(f"Unsupported audio speech response type: {type(response)}")
if response_format == "pcm":
transcript = None
else:
transcript = convert_audio_bytes_to_text(raw_bytes)
result.audio_bytes = raw_bytes
result.audio_content = transcript
result.e2e_latency = time.perf_counter() - wall_start
result.success = True
result.audio_format = getattr(response, "response", None)
@@ -2796,25 +2780,6 @@ class OmniRunnerHandler:
# ---------------------------------------------------------------------------
def _core_model_stage_config_path_with_dummy_load_format(stage_config_path: str | None, run_level: str) -> str | None:
"""For ``core_model`` runs, patch every stage in the deploy YAML to ``load_format: dummy``."""
if run_level != "core_model" or stage_config_path is None:
return stage_config_path
from tests.helpers.stage_config import modify_stage_config
with open(stage_config_path, encoding="utf-8") as f:
cfg = yaml.safe_load(f) or {}
new_schema_stages = cfg.get("stages")
stage_key = "stages" if new_schema_stages is not None else "stage_args"
update_path = "load_format" if new_schema_stages is not None else "engine_args.load_format"
stage_entries = cfg.get(stage_key, [])
stage_ids = [stage["stage_id"] for stage in stage_entries if "stage_id" in stage]
return modify_stage_config(
stage_config_path,
updates={stage_key: {stage_id: {update_path: "dummy"} for stage_id in stage_ids}},
)
def iter_omni_server(
request: Any,
run_level: str,
@@ -2822,25 +2787,13 @@ def iter_omni_server(
omni_fixture_lock: threading.Lock,
) -> Generator[Any, Any, None]:
"""Start/stop an Omni HTTP server; used by ``omni_server`` / ``omni_server_function`` fixtures."""
from tests.helpers.stage_config import modify_stage_config
from tests.helpers.stage_config import stage_config_path_for_run_level
with omni_fixture_lock:
params: OmniServerParams = request.param
model = model_prefix + params.model
port = params.port
stage_config_path = params.stage_config_path
if run_level in {"advanced_model", "full_model"} and stage_config_path is not None:
with open(stage_config_path, encoding="utf-8") as f:
cfg = yaml.safe_load(f) or {}
new_schema_stages = cfg.get("stages")
stage_key = "stages" if new_schema_stages is not None else "stage_args"
delete_path = "load_format" if new_schema_stages is not None else "engine_args.load_format"
stage_entries = cfg.get(stage_key, [])
stage_ids = [stage["stage_id"] for stage in stage_entries if "stage_id" in stage]
stage_config_path = modify_stage_config(
stage_config_path,
deletes={stage_key: {stage_id: [delete_path] for stage_id in stage_ids}},
)
stage_config_path = stage_config_path_for_run_level(params.stage_config_path, run_level)
server_args = params.server_args or []
if params.use_omni and params.stage_init_timeout is not None:
@@ -2905,6 +2858,8 @@ def iter_omni_runner(
omni_fixture_lock: threading.Lock,
) -> Generator[Any, None, None]:
"""Yield an :class:`OmniRunner`; used by ``omni_runner`` / ``omni_runner_function`` fixtures."""
from tests.helpers.stage_config import stage_config_path_for_run_level
with omni_fixture_lock:
param = request.param
if not isinstance(param, (tuple, list)) or len(param) not in (2, 3):
@@ -2918,7 +2873,7 @@ def iter_omni_runner(
else:
model, stage_config_path, extra = param[0], param[1], param[2]
extra_omni_kwargs = dict(extra) if extra is not None else {}
stage_config_path = _core_model_stage_config_path_with_dummy_load_format(stage_config_path, run_level)
stage_config_path = stage_config_path_for_run_level(stage_config_path, run_level)
model = model_prefix + model
with OmniRunner(model, seed=42, stage_configs_path=stage_config_path, **extra_omni_kwargs) as runner:
print("OmniRunner started successfully")
+74 -1
View File
@@ -627,7 +627,80 @@ def get_deploy_config_path(rel_path: str) -> str:
return str(_DEPLOY_DIR / rel_path)
def _get_config_value_by_path(config_dict: dict, path: str) -> Any:
"""Read a dot-separated path from a nested dict (e.g. ``engine_args.load_format``)."""
current: Any = config_dict
for key in path.split("."):
if not isinstance(current, dict) or key not in current:
return None
current = current[key]
return current
def _stage_load_format_paths(stage_config_path: str) -> tuple[str, str, list[int]]:
"""Return ``(stage_key, load_format_field_path, stage_ids)`` for a deploy YAML."""
with open(stage_config_path, encoding="utf-8") as f:
cfg = yaml.safe_load(f) or {}
new_schema_stages = cfg.get("stages")
stage_key = "stages" if new_schema_stages is not None else "stage_args"
load_format_path = "load_format" if new_schema_stages is not None else "engine_args.load_format"
stage_entries = cfg.get(stage_key, [])
stage_ids = [stage["stage_id"] for stage in stage_entries if "stage_id" in stage]
return stage_key, load_format_path, stage_ids
def _add_dummy_load_format(
stage_config_path: str | None,
run_level: str,
) -> str | None:
"""For ``core_model`` runs, patch every stage in the deploy YAML to ``load_format: dummy``."""
if run_level != "core_model" or stage_config_path is None:
return stage_config_path
stage_key, load_format_path, stage_ids = _stage_load_format_paths(stage_config_path)
return modify_stage_config(
stage_config_path,
updates={stage_key: {stage_id: {load_format_path: "dummy"} for stage_id in stage_ids}},
)
def _delete_dummy_load_format(
stage_config_path: str | None,
run_level: str,
) -> str | None:
"""For ``advanced_model`` / ``full_model``, strip ``load_format: dummy`` so real weights load."""
if run_level not in {"advanced_model", "full_model"} or stage_config_path is None:
return stage_config_path
stage_key, load_format_path, _stage_ids = _stage_load_format_paths(stage_config_path)
with open(stage_config_path, encoding="utf-8") as f:
cfg = yaml.safe_load(f) or {}
stage_entries = cfg.get(stage_key, [])
deletes: dict[int, list[str]] = {}
for stage in stage_entries:
stage_id = stage.get("stage_id")
if stage_id is None:
continue
if _get_config_value_by_path(stage, load_format_path) == "dummy":
deletes[stage_id] = [load_format_path]
if not deletes:
return stage_config_path
return modify_stage_config(
stage_config_path,
deletes={stage_key: deletes},
)
def stage_config_path_for_run_level(stage_config_path: str | None, run_level: str) -> str | None:
"""Apply run-level deploy YAML tweaks for weight loading (dummy vs real)."""
if run_level in {"advanced_model", "full_model"}:
return _delete_dummy_load_format(stage_config_path, run_level)
return _add_dummy_load_format(stage_config_path, run_level)
__all__ = [
"modify_stage_config",
"get_deploy_config_path",
"modify_stage_config",
"stage_config_path_for_run_level",
]