From bc79a64d3a81b1540c15d376b967dd436503d926 Mon Sep 17 00:00:00 2001 From: Johnsonms Date: Sun, 15 Feb 2026 20:47:29 -0800 Subject: [PATCH] [Diff]: support SGLANG_TORCH_PROFILER_DIR environment variable for profiler log directory (#18454) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- python/sglang/multimodal_gen/runtime/utils/profiler.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/sglang/multimodal_gen/runtime/utils/profiler.py b/python/sglang/multimodal_gen/runtime/utils/profiler.py index 037133e8a..3af3dd9bb 100644 --- a/python/sglang/multimodal_gen/runtime/utils/profiler.py +++ b/python/sglang/multimodal_gen/runtime/utils/profiler.py @@ -27,12 +27,17 @@ class SGLDiffusionProfiler: full_profile: bool = False, num_steps: int | None = None, num_inference_steps: int | None = None, - log_dir: str = "./logs", + log_dir: str | None = None, ): self.request_id = request_id or "profile_trace" self.rank = rank self.full_profile = full_profile - self.log_dir = log_dir + + self.log_dir = ( + log_dir + if log_dir is not None + else os.getenv("SGLANG_TORCH_PROFILER_DIR", "./logs") + ) try: os.makedirs(self.log_dir, exist_ok=True)