A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 13, 04:30 UTC
[Log] Save profiler results to file instead of stdout (#28144)
Signed-off-by: Randall Smith <ransmith@amd.com> Co-authored-by: Randall Smith <ransmith@amd.com>
rasmith committed
Nov 14, 2025 at 17:26 UTC
ba041d980b5677a0ab6cebb3c7fe24cfe27bac66
1 file changed
+13
-8
vllm/v1/worker/gpu_worker.py
+13
-8
@@ -596,14 +596,19 @@ class Worker(WorkerBase):
596
self.profiler.start()
597
else:
598
self.profiler.stop()
599
- # only print profiler results on rank 0
600
- if (
601
- isinstance(self.profiler, torch.profiler.profile)
602
- and self.local_rank == 0
603
- ):
604
- print(
605
- self.profiler.key_averages().table(sort_by="self_cuda_time_total")
606
- )
599
+ if isinstance(self.profiler, torch.profiler.profile):
600
+ rank = self.local_rank
601
+ profiler_dir = envs.VLLM_TORCH_PROFILER_DIR
602
+ profiler_out_file = f"{profiler_dir}/profiler_out_{rank}.txt"
603
+ sort_key = "self_cuda_time_total"
604
+ table = self.profiler.key_averages().table(sort_by=sort_key)
605
+
606
+ with open(profiler_out_file, "w") as f:
607
+ print(table, file=f)
608
+
609
+ # only print profiler results on rank 0
610
+ if rank == 0:
611
+ print(table)
612
613
def execute_dummy_batch(self) -> None:
614
self.model_runner._dummy_run(1, uniform_decode=True)