Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
a8f5aec2
Unverified
Commit
a8f5aec2
authored
May 15, 2025
by
Russell Bryant
Committed by
GitHub
May 14, 2025
Browse files
[V1] Update zmq socket creation in nixl connector (#18148)
Signed-off-by:
Russell Bryant
<
rbryant@redhat.com
>
parent
de71fec8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
15 deletions
+34
-15
tests/test_utils.py
tests/test_utils.py
+6
-1
vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
...distributed/kv_transfer/kv_connector/v1/nixl_connector.py
+10
-14
vllm/utils.py
vllm/utils.py
+18
-0
No files found.
tests/test_utils.py
View file @
a8f5aec2
...
...
@@ -17,7 +17,7 @@ from vllm.config import ParallelConfig, VllmConfig, set_current_vllm_config
from
vllm.utils
import
(
CacheInfo
,
FlexibleArgumentParser
,
LRUCache
,
MemorySnapshot
,
PlaceholderModule
,
StoreBoolean
,
bind_kv_cache
,
deprecate_kwargs
,
get_open_port
,
make_zmq_socket
,
memory_profiling
,
make_zmq_path
,
make_zmq_socket
,
memory_profiling
,
merge_async_iterators
,
sha256
,
split_zmq_path
,
supports_kw
,
swap_dict_values
)
...
...
@@ -714,3 +714,8 @@ def test_make_zmq_socket_ipv6():
# Clean up
zsock
.
close
()
ctx
.
term
()
def
test_make_zmq_path
():
assert
make_zmq_path
(
"tcp"
,
"127.0.0.1"
,
"5555"
)
==
"tcp://127.0.0.1:5555"
assert
make_zmq_path
(
"tcp"
,
"::1"
,
"5555"
)
==
"tcp://[::1]:5555"
vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
View file @
a8f5aec2
...
...
@@ -21,7 +21,7 @@ from vllm.distributed.parallel_state import (
get_tensor_model_parallel_rank
,
get_tensor_model_parallel_world_size
,
get_tp_group
)
from
vllm.logger
import
init_logger
from
vllm.utils
import
round_down
from
vllm.utils
import
make_zmq_path
,
make_zmq_socket
,
round_down
from
vllm.v1.core.sched.output
import
SchedulerOutput
from
vllm.v1.request
import
RequestStatus
...
...
@@ -379,7 +379,7 @@ class NixlConnectorWorker:
# hack to keeps us moving. We will switch when moving to etcd
# or where we have a single ZMQ socket in the scheduler.
port
=
envs
.
VLLM_NIXL_SIDE_CHANNEL_PORT
+
rank
path
=
f
"tcp://
{
host
}
:
{
port
}
"
path
=
make_zmq_path
(
"tcp"
,
host
,
port
)
logger
.
debug
(
"Starting listening on path: %s"
,
path
)
with
zmq_ctx
(
zmq
.
ROUTER
,
path
)
as
sock
:
ready_event
.
set
()
...
...
@@ -397,7 +397,7 @@ class NixlConnectorWorker:
# NOTE(rob): we need each rank to have a unique port. This is
# a hack to keep us moving. We will switch when moving to etcd
# or where we have a single ZMQ socket in the scheduler.
path
=
f
"tcp://
{
host
}
:
{
port
+
self
.
rank
}
"
path
=
make_zmq_path
(
"tcp"
,
host
,
port
+
self
.
rank
)
logger
.
debug
(
"Querying metadata on path: %s"
,
path
)
with
zmq_ctx
(
zmq
.
REQ
,
path
)
as
sock
:
# Send query for the request.
...
...
@@ -741,20 +741,16 @@ class NixlConnectorWorker:
def
zmq_ctx
(
socket_type
:
Any
,
addr
:
str
)
->
Iterator
[
zmq
.
Socket
]:
"""Context manager for a ZMQ socket"""
if
socket_type
not
in
(
zmq
.
ROUTER
,
zmq
.
REQ
):
raise
ValueError
(
f
"Unexpected socket type:
{
socket_type
}
"
)
ctx
:
Optional
[
zmq
.
Context
]
=
None
try
:
ctx
=
zmq
.
Context
()
# type: ignore[attr-defined]
if
socket_type
==
zmq
.
ROUTER
:
socket
=
ctx
.
socket
(
zmq
.
ROUTER
)
socket
.
bind
(
addr
)
elif
socket_type
==
zmq
.
REQ
:
socket
=
ctx
.
socket
(
zmq
.
REQ
)
socket
.
connect
(
addr
)
else
:
raise
ValueError
(
f
"Unexpected socket type:
{
socket_type
}
"
)
yield
socket
yield
make_zmq_socket
(
ctx
=
ctx
,
path
=
addr
,
socket_type
=
socket_type
,
bind
=
socket_type
==
zmq
.
ROUTER
)
finally
:
if
ctx
is
not
None
:
ctx
.
destroy
(
linger
=
0
)
vllm/utils.py
View file @
a8f5aec2
...
...
@@ -2350,6 +2350,24 @@ def split_zmq_path(path: str) -> Tuple[str, str, str]:
return
scheme
,
host
,
port
def
make_zmq_path
(
scheme
:
str
,
host
:
str
,
port
:
Optional
[
int
]
=
None
)
->
str
:
"""Make a ZMQ path from its parts.
Args:
scheme: The ZMQ transport scheme (e.g. tcp, ipc, inproc).
host: The host - can be an IPv4 address, IPv6 address, or hostname.
port: Optional port number, only used for TCP sockets.
Returns:
A properly formatted ZMQ path string.
"""
if
not
port
:
return
f
"
{
scheme
}
://
{
host
}
"
if
is_valid_ipv6_address
(
host
):
return
f
"
{
scheme
}
://[
{
host
}
]:
{
port
}
"
return
f
"
{
scheme
}
://
{
host
}
:
{
port
}
"
# Adapted from: https://github.com/sgl-project/sglang/blob/v0.4.1/python/sglang/srt/utils.py#L783 # noqa: E501
def
make_zmq_socket
(
ctx
:
Union
[
zmq
.
asyncio
.
Context
,
zmq
.
Context
],
# type: ignore[name-defined]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment