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)