Skip to content

Commit 7058d7d

Browse files
authored
[Refactor] Remove duplicate find_free_port (#20333)
Signed-off-by: yewentao256 <zhyanwentao@126.com>
1 parent a0389e0 commit 7058d7d

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

tests/kernels/moe/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
spawn) # pyright: ignore[reportPrivateImportUsage]
1515
from typing_extensions import Concatenate, ParamSpec
1616

17-
from vllm.model_executor.layers.fused_moe.utils import find_free_port
17+
from vllm.utils import get_open_port
1818

1919
has_deep_ep = importlib.util.find_spec("deep_ep") is not None
2020
if has_deep_ep:
@@ -95,7 +95,7 @@ def parallel_launch(
9595
world_size,
9696
world_size,
9797
0,
98-
f"tcp://{os.getenv('LOCALHOST', 'localhost')}:{find_free_port()}",
98+
f"tcp://{os.getenv('LOCALHOST', 'localhost')}:{get_open_port()}",
9999
worker,
100100
) + args,
101101
nprocs=world_size,

vllm/model_executor/layers/fused_moe/utils.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3-
import socket
4-
from contextlib import closing
53
from math import prod
64
from typing import Optional
75

@@ -98,10 +96,3 @@ def _fp8_perm(m: torch.Tensor, idx: torch.Tensor) -> torch.Tensor:
9896
return m.view(dtype=torch.uint8)[idx, ...].view(dtype=m.dtype)
9997
else:
10098
return m[idx, ...]
101-
102-
103-
def find_free_port():
104-
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
105-
s.bind(('', 0))
106-
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
107-
return s.getsockname()[1]

0 commit comments

Comments
 (0)