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 14, 05:30 UTC
[MISC] Rename the torch profiler filename as instance_id+rank_id for merging the Profiler results of each Rank (#25867)
Signed-off-by: wang.yuqi <noooop@126.com>
wang.yuqi committed
Oct 12, 2025 at 17:29 UTC
76852017ea9175e1301b34162fa952bf82f02e94
3 files changed
+8
-2
vllm/config/vllm.py
+4
@@ -5,6 +5,7 @@ import copy
5
import hashlib
6
import json
7
import os
8
+import time
9
from contextlib import contextmanager
10
from dataclasses import field, replace
11
from functools import lru_cache
@@ -270,6 +271,9 @@ class VllmConfig:
271
def __post_init__(self):
272
"""Verify configs are valid & consistent with each other."""
273
274
+ # To give each torch profile run a unique instance name.
275
+ self.instance_id = f"{time.time_ns()}"
276
+
277
self.try_verify_and_update_config()
278
279
if self.model_config is not None:
vllm/v1/worker/gpu_worker.py
+2
-1
@@ -79,6 +79,7 @@ class Worker(WorkerBase):
79
# VLLM_TORCH_PROFILER_DIR=/path/to/save/trace
80
if envs.VLLM_TORCH_PROFILER_DIR:
81
torch_profiler_trace_dir = envs.VLLM_TORCH_PROFILER_DIR
82
+ worker_name = f"{vllm_config.instance_id}-rank-{self.rank}"
83
logger.info(
84
"Profiling enabled. Traces will be saved to: %s",
85
torch_profiler_trace_dir,
@@ -101,7 +102,7 @@ class Worker(WorkerBase):
102
with_stack=envs.VLLM_TORCH_PROFILER_WITH_STACK,
103
with_flops=envs.VLLM_TORCH_PROFILER_WITH_FLOPS,
104
on_trace_ready=torch.profiler.tensorboard_trace_handler(
104
- torch_profiler_trace_dir, use_gzip=True
105
+ torch_profiler_trace_dir, worker_name=worker_name, use_gzip=True
106
),
107
)
108
else:
vllm/v1/worker/xpu_worker.py
+2
-1
@@ -39,6 +39,7 @@ class XPUWorker(Worker):
39
# VLLM_TORCH_PROFILER_DIR=/path/to/save/trace
40
if envs.VLLM_TORCH_PROFILER_DIR:
41
torch_profiler_trace_dir = envs.VLLM_TORCH_PROFILER_DIR
42
+ worker_name = f"{vllm_config.instance_id}-rank-{self.rank}"
43
logger.info(
44
"Profiling enabled. Traces will be saved to: %s",
45
torch_profiler_trace_dir,
@@ -61,7 +62,7 @@ class XPUWorker(Worker):
62
with_stack=envs.VLLM_TORCH_PROFILER_WITH_STACK,
63
with_flops=envs.VLLM_TORCH_PROFILER_WITH_FLOPS,
64
on_trace_ready=torch.profiler.tensorboard_trace_handler(
64
- torch_profiler_trace_dir, use_gzip=True
65
+ torch_profiler_trace_dir, worker_name=worker_name, use_gzip=True
66
),
67
)
68
else: