From 194abb8e54a8db2144c9ee7f61e391b9eea00738 Mon Sep 17 00:00:00 2001 From: Michael <13900043+michaelzhang-ai@users.noreply.github.com> Date: Fri, 23 Oct 2026 13:26:56 -0700 Subject: [PATCH] [CI] [AMD] diffusion: Drain the Cosmos Dreams decode stream after freeing its outputs (#45983) --- .../model_specific_stages/cosmos3_simulation/dreams.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3_simulation/dreams.py b/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3_simulation/dreams.py index 83db15ef46..3623236ede 100644 --- a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3_simulation/dreams.py +++ b/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3_simulation/dreams.py @@ -872,11 +872,13 @@ class CausalDecodeQueue: def __exit__(self, exc_type, exc_value, traceback) -> None: try: - self.stream.synchronize() - finally: self.vae.reset_causal_decode_state() if exc_type is not None: self.outputs.clear() + finally: + # Drain last: freeing pinned outputs records host-allocator events + # on this stream, so they must land before the final sync. + self.stream.synchronize() def _denormalize(self, latents: torch.Tensor) -> torch.Tensor: return denormalize_vae_latents(latents, self._mean, self._std)