Skip to content

Commit 96fe63f

Browse files
authored
feat: nixl_connect: Improve Concurrency Support (#4433)
Signed-off-by: J Wyman <[email protected]>
1 parent 0ce7280 commit 96fe63f

File tree

16 files changed

+294
-156
lines changed

16 files changed

+294
-156
lines changed

components/src/dynamo/sglang/request_handlers/multimodal/encode_worker_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async def generate(
159159
# Create descriptor for the multimodal data
160160
descriptor = connect.Descriptor(precomputed_embeddings)
161161

162-
with self._connector.create_readable(descriptor) as readable:
162+
with await self._connector.create_readable(descriptor) as readable:
163163
request.serialized_request = readable.metadata()
164164

165165
logger.debug(f"Request: {request.model_dump_json()}")
@@ -184,6 +184,5 @@ async def async_init(self, runtime: DistributedRuntime):
184184
# Create and initialize a dynamo connector for this worker.
185185
# We'll needs this to move data between this worker and remote workers efficiently.
186186
self._connector = connect.Connector()
187-
await self._connector.initialize()
188187

189188
logger.info("Startup completed.")

components/src/dynamo/sglang/request_handlers/multimodal/worker_handler.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ def __init__(self):
7777
async def initialize(self):
7878
"""Initialize the connector for embeddings processing"""
7979
self._connector = connect.Connector()
80-
await self._connector.initialize()
8180

8281
async def process_embeddings(self, request: SglangMultimodalRequest):
8382
"""Process embeddings from serialized request"""
@@ -103,7 +102,6 @@ async def process_embeddings(self, request: SglangMultimodalRequest):
103102
"Connector is None - this should not happen after initialization"
104103
)
105104
self._connector = connect.Connector()
106-
await self._connector.initialize()
107105

108106
read_op = await self._connector.begin_read(
109107
request.serialized_request, descriptor

components/src/dynamo/trtllm/encode_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ async def process_embedding_request(
241241

242242
# Create readable operation with main embeddings tensor (works for both formats)
243243
descriptor = nixl_connect.Descriptor(encodings)
244-
with connector.create_readable(descriptor) as readable_op:
244+
with await connector.create_readable(descriptor) as readable_op:
245245
# Get the metadata for the readable operation
246246
op_metadata = readable_op.metadata()
247247

components/src/dynamo/trtllm/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ async def init(runtime: DistributedRuntime, config: Config):
332332
connector = None
333333
logging.info("Initializing NIXL Connect.")
334334
connector = nixl_connect.Connector()
335-
await connector.initialize()
336335

337336
dump_config(
338337
config.dump_config_to, {"engine_args": engine_args, "dynamo_args": config}

components/src/dynamo/vllm/multimodal_handlers/encode_worker_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ async def async_init(self, runtime: DistributedRuntime):
6969
# Create and initialize a dynamo connector for this worker.
7070
# We'll needs this to move data between this worker and remote workers efficiently.
7171
self._connector = connect.Connector()
72-
await self._connector.initialize()
7372
logger.info("Encode worker startup completed.")
7473

7574
async def generate(
@@ -130,7 +129,7 @@ async def generate(
130129
request.embeddings_shape = tuple(embeddings.shape)
131130
descriptor = connect.Descriptor(embeddings_cpu)
132131

133-
with self._connector.create_readable(descriptor) as readable:
132+
with await self._connector.create_readable(descriptor) as readable:
134133
request.serialized_request = readable.metadata()
135134
# Clear the image URL as hint that the image is passed as embeddings.
136135
request.multimodal_input.image_url = None

components/src/dynamo/vllm/multimodal_handlers/worker_handler.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def __init__(
5252
async def async_init(self, runtime: DistributedRuntime):
5353
"""Async initialization - connector needs async setup"""
5454
self._connector = connect.Connector()
55-
await self._connector.initialize()
5655
logger.info("Multimodal Decode Worker async initialization completed.")
5756

5857
async def generate(self, request: vLLMMultimodalRequest, context):
@@ -138,7 +137,6 @@ async def async_init(self, runtime: DistributedRuntime):
138137
"""Async initialization for connector that requires async setup"""
139138
# Initialize the connector asynchronously
140139
self._connector = connect.Connector()
141-
await self._connector.initialize()
142140
logger.info("Multimodal PD Worker async initialization completed.")
143141

144142
async def generate(self, request: vLLMMultimodalRequest, context):

docs/api/nixl_connect/connector.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ The metadata contains required information (identifiers, keys, etc.) which enabl
4747
@async_on_start
4848
async def async_init(self):
4949
self.connector = dynamo.nixl_connect.Connector()
50-
await self.connector.initialize()
5150
```
5251

5352
> [!Tip]
@@ -109,7 +108,7 @@ Use [`.wait_for_completion()`](write_operation.md#wait_for_completion) to block
109108
### `create_readable`
110109

111110
```python
112-
def create_readable(
111+
async def create_readable(
113112
self,
114113
local_descriptors: Descriptor | list[Descriptor],
115114
) -> ReadableOperation:
@@ -130,7 +129,7 @@ Use [`.wait_for_completion()`](readable_operation.md#wait_for_completion) to blo
130129
### `create_writable`
131130

132131
```python
133-
def create_writable(
132+
async def create_writable(
134133
self,
135134
local_descriptors: Descriptor | list[Descriptor],
136135
) -> WritableOperation:
@@ -151,6 +150,15 @@ Use [`.wait_for_completion()`](writable_operation.md#wait_for_completion) to blo
151150

152151
## Properties
153152

153+
### `hostname`
154+
155+
```python
156+
@property
157+
def hostname(self) -> str:
158+
```
159+
160+
Gets the name of the current worker's host.
161+
154162
### `is_cuda_available`
155163

156164
```python
@@ -169,22 +177,6 @@ def name(self) -> str | None:
169177

170178
Gets the Dynamo component name used by the connector.
171179

172-
### `namespace`
173-
174-
```python
175-
@property
176-
def namespace(self) -> str:
177-
```
178-
179-
Gets the Dynamo namespace used by the connector.
180-
181-
### `runtime`
182-
183-
```python
184-
def runtime(self) -> dynamo.runtime.DistributedRuntime:
185-
```
186-
187-
Gets the Dynamo distributed runtime instance associated with the connector.
188180

189181
## Related Classes
190182

docs/api/nixl_connect/read_operation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ therefore the operation should be awaited until completed unless cancellation is
3838
) -> None:
3939
descriptor = dynamo.nixl_connect.Descriptor(local_tensor)
4040

41-
with self.connector.begin_read(descriptor, remote_metadata) as read_op:
41+
with await self.connector.begin_read(remote_metadata, descriptor) as read_op:
4242
# Wait for the operation to complete writing data from the remote worker to local_tensor.
4343
await read_op.wait_for_completion()
4444
```

docs/api/nixl_connect/readable_operation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ therefore the operation should be awaited until completed unless cancellation is
3737
) -> None:
3838
descriptor = dynamo.nixl_connect.Descriptor(local_tensor)
3939

40-
with self.connector.create_readable(descriptor) as read_op:
40+
with await self.connector.create_readable(descriptor) as read_op:
4141
op_metadata = read_op.metadata()
4242

4343
# Send the metadata to the remote worker via sideband communication.

docs/api/nixl_connect/writable_operation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Cancellation is handled asynchronously.
3838
) -> None:
3939
descriptor = dynamo.nixl_connect.Descriptor(local_tensor)
4040

41-
with self.connector.create_writable(descriptor) as write_op:
41+
with await self.connector.create_writable(descriptor) as write_op:
4242
op_metadata = write_op.metadata()
4343

4444
# Send the metadata to the remote worker via sideband communication.

0 commit comments

Comments
 (0)