@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 0cdd213641
Fork 0

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] Improve Worker process title and logging prefix (#22205)

Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>

22quinn committed Sep 8, 2025 at 21:43 UTC 0cdd213641d7adcf7ad0e9cf79867344ea1291d9
4 files changed +37 -23
vllm/utils/__init__.py
+3 -7
@@ -3359,7 +3359,7 @@ def has_triton_kernels() -> bool:
3359
3360 def set_process_title(name: str,
3361 suffix: str = "",
3362 - append: bool = False) -> None:
3362 + prefix: str = envs.VLLM_PROCESS_NAME_PREFIX) -> None:
3363 """
3364 Set the current process title to a specific name with an
3365 optional suffix.
@@ -3367,15 +3367,11 @@ def set_process_title(name: str,
3367 Args:
3368 name: The title to assign to the current process.
3369 suffix: An optional suffix to append to the base name.
3370 - append: Whether to append to the existing process title.
3370 + prefix: A prefix to prepend to the front separated by `::`.
3371 """
3372 if suffix:
3373 name = f"{name}_{suffix}"
3374 - if append:
3375 - name = f"{setproctitle.getproctitle()}_{name}"
3376 - else:
3377 - name = f"{envs.VLLM_PROCESS_NAME_PREFIX}::{name}"
3378 - setproctitle.setproctitle(name)
3374 + setproctitle.setproctitle(f"{prefix}::{name}")
3375
3376
3377 def _add_prefix(file: TextIO, worker_name: str, pid: int) -> None:
vllm/v1/engine/core.py
+3 -3
@@ -224,7 +224,7 @@ class EngineCore:
224
225 def add_request(self, request: Request, request_wave: int = 0):
226 """Add request to the scheduler.
227 -
227 +
228 `request_wave`: indicate which wave of requests this is expected to
229 belong to in DP case
230 """
@@ -433,7 +433,7 @@ class EngineCore:
433 def preprocess_add_request(
434 self, request: EngineCoreRequest) -> tuple[Request, int]:
435 """Preprocess the request.
436 -
436 +
437 This function could be directly used in input processing thread to allow
438 request initialization running in parallel with Model forward
439 """
@@ -697,7 +697,7 @@ class EngineCoreProc(EngineCore):
697 parallel_config: ParallelConfig = kwargs[
698 "vllm_config"].parallel_config
699 if parallel_config.data_parallel_size > 1 or dp_rank > 0:
700 - set_process_title("DPEngineCore", str(dp_rank))
700 + set_process_title("EngineCore", f"DP{dp_rank}")
701 decorate_logs()
702 # Set data parallel rank for this engine process.
703 parallel_config.data_parallel_rank = dp_rank
vllm/v1/engine/utils.py
+1 -1
@@ -116,7 +116,7 @@ class CoreEngineProcManager:
116 local_dp_ranks.append(local_index)
117 self.processes.append(
118 context.Process(target=target_fn,
119 - name=f"EngineCore_{global_index}",
119 + name=f"EngineCore_DP{global_index}",
120 kwargs=common_kwargs | {
121 "dp_rank": global_index,
122 "local_dp_rank": local_index,
vllm/v1/executor/multiproc_executor.py
+30 -12
@@ -26,6 +26,8 @@ from vllm.distributed import (destroy_distributed_environment,
26 from vllm.distributed.device_communicators.shm_broadcast import (Handle,
27 MessageQueue)
28 from vllm.distributed.kv_transfer.kv_connector.utils import KVOutputAggregator
29 +from vllm.distributed.parallel_state import (get_dp_group, get_ep_group,
30 + get_pp_group, get_tp_group)
31 from vllm.executor.multiproc_worker_utils import (
32 set_multiprocessing_worker_envs)
33 from vllm.logger import init_logger
@@ -397,17 +399,6 @@ class WorkerProc:
399 wrapper.init_worker(all_kwargs)
400 self.worker = wrapper
401
400 - pp_size = vllm_config.parallel_config.pipeline_parallel_size
401 - tp_size = vllm_config.parallel_config.tensor_parallel_size
402 - pp_str = f"PP{rank // tp_size}" if pp_size > 1 else ""
403 - tp_str = f"TP{rank % tp_size}" if tp_size > 1 else ""
404 - suffix = f"{pp_str}{'_' if pp_str and tp_str else ''}{tp_str}"
405 - process_name = "VllmWorker"
406 - if suffix:
407 - set_process_title(suffix, append=True)
408 - process_name = f"{process_name} {suffix}"
409 - decorate_logs(process_name)
410 -
402 # Initialize MessageQueue for receiving SchedulerOutput
403 self.rpc_broadcast_mq = MessageQueue.create_from_handle(
404 input_shm_handle, self.worker.rank)
@@ -425,8 +416,14 @@ class WorkerProc:
416 name="WorkerAsyncOutputCopy")
417 self.async_output_copy_thread.start()
418
428 - # Initialize device and loads weights
419 + # Initialize device
420 self.worker.init_device()
421 +
422 + # Set process title and log prefix
423 + self.setup_proc_title_and_log_prefix(
424 + enable_ep=vllm_config.parallel_config.enable_expert_parallel)
425 +
426 + # Load model
427 self.worker.load_model()
428
429 @staticmethod
@@ -663,3 +660,24 @@ class WorkerProc:
660
661 if output_rank is None or self.rank == output_rank:
662 self.handle_output(output)
663 +
664 + @staticmethod
665 + def setup_proc_title_and_log_prefix(enable_ep: bool) -> None:
666 + dp_size = get_dp_group().world_size
667 + dp_rank = get_dp_group().rank_in_group
668 + pp_size = get_pp_group().world_size
669 + pp_rank = get_pp_group().rank_in_group
670 + tp_size = get_tp_group().world_size
671 + tp_rank = get_tp_group().rank_in_group
672 + process_name = "Worker"
673 + if dp_size > 1:
674 + process_name += f"_DP{dp_rank}"
675 + if pp_size > 1:
676 + process_name += f"_PP{pp_rank}"
677 + if tp_size > 1:
678 + process_name += f"_TP{tp_rank}"
679 + if enable_ep:
680 + ep_rank = get_ep_group().rank_in_group
681 + process_name += f"_EP{ep_rank}"
682 + set_process_title(name=process_name)
683 + decorate_logs(process_name)