[Core][Diffusion] Add pause_generation(mode="keep") for diffusion stages (#7685)

Signed-off-by: cr-gao <gaochenrui@sjtu.edu.cn>
This commit is contained in:
vOv authored and GitHub committed 2026-09-22 01:31:22 +08:00
1 parent 62b15142bd
commit d8d162d810
17 files changed
+1383 -65

No files matched your search

+18 -1
View File
@@ -877,6 +877,19 @@ class DiffusionWorker:
logger.info(f"[Worker {self.rank}] Wake-up complete.")
return True
def synchronize_device(self, timeout: float | None = None) -> None:
"""Wait until this rank has no device work left.
A KV prefetch still receiving on its background thread has queued no
device work yet, so it is joined first. ``timeout`` bounds that join
(and the multi-process worker's output drain before this call); the
device wait itself is unbounded.
"""
manager = getattr(self.model_runner, "kv_transfer_manager", None)
if manager is not None and not manager.wait_prefetch(timeout=timeout):
raise TimeoutError("Diffusion KV prefetch did not finish before pause")
current_omni_platform.synchronize()
def handle_sleep_task(self, task: OmniSleepTask | dict) -> OmniACK | None:
from vllm_omni.platforms import current_omni_platform
@@ -1214,11 +1227,13 @@ class WorkerProc:
self._async_output_pending = max(0, self._async_output_pending - 1)
self._async_output_done.notify_all()
def drain_async_outputs(self, timeout: float = _ASYNC_OUTPUT_DRAIN_TIMEOUT_S) -> bool:
def drain_async_outputs(self, timeout: float | None = None) -> bool:
"""Block until background D2H/SHM packing has no work left.
Returns False if outputs are still in flight when ``timeout`` expires.
"""
if timeout is None:
timeout = _ASYNC_OUTPUT_DRAIN_TIMEOUT_S
with self._async_output_done:
if self._async_output_pending == 0:
return True
@@ -1334,6 +1349,8 @@ class WorkerProc:
}
try:
if method == "synchronize_device" and not self.drain_async_outputs(timeout=kwargs.get("timeout")):
raise TimeoutError("Diffusion async outputs did not drain before pause")
if method in _MEMORY_RELEASING_METHODS:
self.drain_async_outputs()
# Use execute_method from WorkerWrapperBase for consistent method resolution