Skip to content

Commit

Permalink
Enable high-level profiler on multiple instances (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianSzwichtenberg authored Jun 17, 2024
1 parent 628869c commit ad890f1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions vllm/worker/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from contextlib import contextmanager

from vllm.logger import init_logger
from vllm.utils import get_vllm_instance_id

logger = init_logger(__name__)


class FileWriter(threading.Thread):

def __init__(self, filename, event_queue):
super().__init__()
self.filename = filename
Expand Down Expand Up @@ -48,13 +48,15 @@ def run(self):
class Profiler:
profiling_trace_events = queue.Queue()
event_tid = {'counter': 1, 'external': 2, 'internal': 3}
filename = 'server_events.json'
vllm_instance_id = get_vllm_instance_id()
filename = f'server_events_{vllm_instance_id}.json'
event_cache = []

def __init__(self):
self.enabled = os.getenv('VLLM_PROFILER_ENABLED',
'false').lower() == 'true' and int(
os.getenv('RANK', '0')) == 0
logger.info(f'Profiler enabled for: {self.vllm_instance_id}')
if self.enabled:
# initialize the trace file (JSON Array Format)
with open(self.filename, 'w') as outfile:
Expand Down

0 comments on commit ad890f1

Please sign in to comment.