Skip to content

Commit f956e6e

Browse files
authored
[None][fix] trtllm-serve VisualGen: bind HTTP port only on rank 0 in multi-rank launch (NVIDIA#16049)
Signed-off-by: Yiyun Lu <55233584+luyiyun1021@users.noreply.github.com>
1 parent cf82c5d commit f956e6e

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tensorrt_llm/commands/serve.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,16 @@ def launch_visual_gen_server(
713713
visual_gen_args: Optional validated VisualGenArgs for model configuration.
714714
metadata_server_cfg: Optional metadata server configuration.
715715
"""
716+
# Only global rank 0 serves HTTP; in external multi-rank launch ranks > 0
717+
# must become workers before binding, else every rank on a multi-GPU node
718+
# races the same port and all but one die EADDRINUSE. VisualGen() on a
719+
# worker rank never returns (sys.exit in __init__).
720+
from tensorrt_llm._torch.visual_gen.executor import _detect_external_launch
721+
ext = _detect_external_launch()
722+
if ext is not None and ext[0] != 0:
723+
VisualGen(model=model, args=visual_gen_args)
724+
return
725+
716726
# Reserve the listening (host, port) by binding the socket *before*
717727
# constructing the VisualGen pipeline, then hand the bound socket to
718728
# uvicorn. VisualGen initialization can take many minutes; if we deferred

0 commit comments

Comments
 (0)