From f2f16cd5f37f041a6a1e4fc8df046a8984ed70a8 Mon Sep 17 00:00:00 2001 From: Mick Date: Wed, 10 Dec 2025 15:59:17 +0800 Subject: [PATCH 1/4] [diffusion] profile: early exit when enough steps are captured to reduce the trace file size --- python/sglang/multimodal_gen/runtime/utils/profiler.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/sglang/multimodal_gen/runtime/utils/profiler.py b/python/sglang/multimodal_gen/runtime/utils/profiler.py index ba42114e535c..08de8d4f331e 100644 --- a/python/sglang/multimodal_gen/runtime/utils/profiler.py +++ b/python/sglang/multimodal_gen/runtime/utils/profiler.py @@ -56,14 +56,14 @@ def __init__( # profile denoising stage only warmup = 1 num_actual_steps = num_inference_steps if num_steps == -1 else num_steps - num_active_steps = num_actual_steps + warmup + self.num_active_steps = num_actual_steps + warmup self.profiler = torch.profiler.profile( **common_torch_profiler_args, schedule=torch.profiler.schedule( skip_first=0, wait=0, warmup=warmup, - active=num_active_steps, + active=self.num_active_steps, repeat=1, ), ) @@ -88,8 +88,12 @@ def step_stage(self): self._step() def step_denoising_step(self): - if not self.full_profile: + if not self.full_profile and self.num_active_steps >= 0: self._step() + self.num_active_steps -= 1 + if self.num_active_steps == 0: + # early exit when enough steps are captured, to reduce the trace file size + self.stop(dump_rank=0) @classmethod def get_instance(cls) -> "SGLDiffusionProfiler": From f6411a7c48144dbbf70f66d734523d45f9873e42 Mon Sep 17 00:00:00 2001 From: Mick Date: Wed, 10 Dec 2025 16:05:49 +0800 Subject: [PATCH 2/4] upd --- python/sglang/multimodal_gen/runtime/utils/profiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/sglang/multimodal_gen/runtime/utils/profiler.py b/python/sglang/multimodal_gen/runtime/utils/profiler.py index 08de8d4f331e..fdeaa1e71d01 100644 --- a/python/sglang/multimodal_gen/runtime/utils/profiler.py +++ b/python/sglang/multimodal_gen/runtime/utils/profiler.py @@ -91,7 +91,7 @@ def step_denoising_step(self): if not self.full_profile and self.num_active_steps >= 0: self._step() self.num_active_steps -= 1 - if self.num_active_steps == 0: + if self.num_active_steps < 0: # early exit when enough steps are captured, to reduce the trace file size self.stop(dump_rank=0) From 9501960e7d32e47337f826e6fcf11ef5e03f441f Mon Sep 17 00:00:00 2001 From: Mick Date: Wed, 10 Dec 2025 16:07:13 +0800 Subject: [PATCH 3/4] upd --- python/sglang/multimodal_gen/runtime/utils/profiler.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python/sglang/multimodal_gen/runtime/utils/profiler.py b/python/sglang/multimodal_gen/runtime/utils/profiler.py index fdeaa1e71d01..2bf9c283e3b1 100644 --- a/python/sglang/multimodal_gen/runtime/utils/profiler.py +++ b/python/sglang/multimodal_gen/runtime/utils/profiler.py @@ -88,10 +88,11 @@ def step_stage(self): self._step() def step_denoising_step(self): - if not self.full_profile and self.num_active_steps >= 0: - self._step() - self.num_active_steps -= 1 - if self.num_active_steps < 0: + if not self.full_profile: + if self.num_active_steps >= 0: + self._step() + self.num_active_steps -= 1 + else: # early exit when enough steps are captured, to reduce the trace file size self.stop(dump_rank=0) From d7eaf4ee059ad8835b1ccf4b7b996f1fa9aa6429 Mon Sep 17 00:00:00 2001 From: Mick Date: Wed, 10 Dec 2025 16:08:06 +0800 Subject: [PATCH 4/4] upd --- .../pipelines_core/stages/input_validation.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py b/python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py index c403946bea89..dd5de7157566 100644 --- a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py +++ b/python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py @@ -219,6 +219,17 @@ def forward( batch, server_args, condition_image_width, condition_image_height ) + # if height or width is not specified at this point, set default to 720p + default_height = 720 + default_width = 1080 + if batch.height is None and batch.width is None: + batch.height = default_height + batch.width = default_width + elif batch.height is None: + batch.height = batch.width * default_height // default_width + elif batch.width is None: + batch.width = batch.height * default_width // default_height + return batch def verify_input(self, batch: Req, server_args: ServerArgs) -> VerificationResult: @@ -251,6 +262,7 @@ def verify_output(self, batch: Req, server_args: ServerArgs) -> VerificationResu result.add_check("height", batch.height, V.positive_int) result.add_check("width", batch.width, V.positive_int) # Validate height and width + if batch.height % 8 != 0 or batch.width % 8 != 0: raise ValueError( f"Height and width must be divisible by 8 but are {batch.height} and {batch.width}."