Merge branch 'main' into qwen-image-2.1

Signed-off-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
Isotr0py authored and GitHub committed 2026-09-22 10:11:12 +08:00
commit 8e0695f362
51 files changed
+2189 -70

No files matched your search

+4 -4
View File
@@ -186,7 +186,7 @@ class AsyncOmni(AsyncOmniBase, EngineClient):
# Reject diffusion list-prompt early with a clear API error.
if isinstance(prompt, list) and any(
getattr(client, "stage_type", "") == "diffusion" for client in getattr(self.engine, "stage_clients", [])
stage_config.stage_type == "diffusion" for stage_config in self.engine.stage_configs
):
raise ValueError(
"Diffusion stages accept only a single prompt per request. "
@@ -626,7 +626,7 @@ class AsyncOmni(AsyncOmniBase, EngineClient):
def _split_stage_ids_by_type(self, stage_ids: list[int] | None = None) -> tuple[list[int], list[int]]:
"""Split stage ids into AR/LLM (EngineCore) vs diffusion (worker RPC)."""
n_stages = len(self.engine.stage_clients)
n_stages = len(self.engine.stage_configs)
if stage_ids is None:
stage_ids = list(range(n_stages))
else:
@@ -640,8 +640,8 @@ class AsyncOmni(AsyncOmniBase, EngineClient):
ar_stage_ids: list[int] = []
diffusion_stage_ids: list[int] = []
for sid in stage_ids:
client = self.engine.stage_clients[sid]
if getattr(client, "stage_type", "llm") == "diffusion":
stage_config = self.engine.stage_configs[sid]
if stage_config.stage_type == "diffusion":
diffusion_stage_ids.append(sid)
else:
ar_stage_ids.append(sid)
+3 -5
View File
@@ -155,13 +155,13 @@ class AsyncOmniBase(OmniBase):
def _get_comprehension_stage_index(self) -> int | None:
fallback_idx: int | None = None
for idx, stage_client in enumerate(self.engine.stage_clients):
for idx, stage_config in enumerate(self.engine.stage_configs):
stage_vllm_config = self.engine.stage_vllm_configs[idx]
if stage_vllm_config is None:
continue
if fallback_idx is None:
fallback_idx = idx
if stage_client.is_comprehension:
if stage_config.is_comprehension:
return idx
return fallback_idx
@@ -186,13 +186,11 @@ class AsyncOmniBase(OmniBase):
def get_diffusion_od_config(self) -> Any | None:
"""Return the diffusion-stage config when the pipeline has one."""
saw_diffusion_stage = False
saw_diffusion_stage = any(stage_config.stage_type == "diffusion" for stage_config in self.engine.stage_configs)
for stage_client in self.engine.stage_clients:
if getattr(stage_client, "stage_type", None) != "diffusion":
continue
saw_diffusion_stage = True
od_config = getattr(stage_client, "od_config", None)
if od_config is not None:
return od_config
+2 -1
View File
@@ -28,7 +28,8 @@ async def receive_text_with_timeout(websocket: WebSocket, timeout_s: float | Non
return await websocket.receive_text()
try:
return await asyncio.wait_for(websocket.receive_text(), timeout=timeout_s)
except TimeoutError:
# asyncio.TimeoutError is not the builtin TimeoutError before Python 3.11.
except (TimeoutError, asyncio.TimeoutError):
return None
@@ -246,6 +246,12 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
except ValueError:
logger.warning("Invalid SPEAKER_MAX_UPLOADED=%r; using default 1000", _raw_cap)
self._max_uploaded_speakers = 1000
_policy = os.environ.get("VLLM_OMNI_SPEAKER_REGISTRATION_POLICY", "overwrite").lower()
if _policy not in ("overwrite", "immutable"):
raise ValueError(
f"Invalid VLLM_OMNI_SPEAKER_REGISTRATION_POLICY={_policy!r}; expected 'overwrite' or 'immutable'."
)
self._registration_policy = _policy
self.uploaded_speakers: dict[str, dict[str, Any]] = {}
self._ref_audio_data_url_cache: dict[str, str] = {}
self._ref_audio_resolve_cache: OrderedDict[str, tuple[np.ndarray, int, int, str]] = OrderedDict()
@@ -410,6 +416,7 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
adapter = self._adapter
if adapter is not None:
adapter.load_capabilities()
self._drop_shadowing_uploads()
available_speakers = self._get_available_speakers()
logger.info("Loaded %d supported speakers: %s", len(available_speakers), sorted(available_speakers))
@@ -448,6 +455,7 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
ctx = SpeechServingContext(server=self, engine_client=self.engine_client)
self._adapter = adapter_cls(ctx)
self._adapter.load_capabilities()
self._drop_shadowing_uploads()
return self._adapter
def _uses_native_speed_control(self) -> bool:
@@ -803,6 +811,39 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
f"the cap via SPEAKER_MAX_UPLOADED."
)
def _drop_shadowing_uploads(self) -> None:
"""Uploads are restored from disk before the adapter exists, so a name
registered under a built-in speaker before the collision guard would
keep shadowing it across restarts. Drop such entries from the registry;
the file stays on disk for the operator to remove."""
caps = self._adapter.capabilities if self._adapter is not None else None
if caps is None:
return
for voice_name_lower in list(self.uploaded_speakers):
if voice_name_lower in caps.supported_speakers or voice_name_lower in caps.precomputed_speakers:
info = self.uploaded_speakers.pop(voice_name_lower)
logger.warning(
"Uploaded voice %r shadows a built-in speaker and is ignored; remove %s to clear this warning.",
voice_name_lower,
info.get("file_path"),
)
def _check_registration_allowed(self, voice_name_lower: str, name: str) -> None:
"""Reject names that would shadow a built-in voice or, under the
immutable policy, silently overwrite an existing upload."""
caps = self._adapter.capabilities if self._adapter is not None else None
if caps is not None and (
voice_name_lower in caps.supported_speakers or voice_name_lower in caps.precomputed_speakers
):
raise ValueError(
f"Voice name '{name}' is reserved by a built-in speaker of this model; choose a different name."
)
if self._registration_policy == "immutable" and voice_name_lower in self.uploaded_speakers:
raise ValueError(
f"Voice '{name}' already exists and VLLM_OMNI_SPEAKER_REGISTRATION_POLICY is 'immutable'; "
f"delete it first via DELETE /v1/audio/voices/{name}."
)
def _evict_existing_upload(self, voice_name_lower: str, name: str) -> None:
"""Drop an existing upload with this name so the caller can re-register it."""
if voice_name_lower not in self.uploaded_speakers:
@@ -885,6 +926,7 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
async with self._upload_lock:
voice_name_lower = name.lower()
self._check_registration_allowed(voice_name_lower, name)
self._evict_existing_upload(voice_name_lower, name)
self._check_upload_cap()
@@ -1005,6 +1047,7 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
async with self._upload_lock:
voice_name_lower = name.lower()
self._check_registration_allowed(voice_name_lower, name)
self._evict_existing_upload(voice_name_lower, name)
self._check_upload_cap()