modelexpress-client 0.7.0

Client library for Model Express gRPC server
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings

from . import p2p_pb2 as p2p__pb2

GRPC_GENERATED_VERSION = '1.66.2'
GRPC_VERSION = grpc.__version__
_version_not_supported = False

try:
    from grpc._utilities import first_version_is_lower
    _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
except ImportError:
    _version_not_supported = True

if _version_not_supported:
    raise RuntimeError(
        f'The grpc package installed is at version {GRPC_VERSION},'
        + ' but the generated code in p2p_pb2_grpc.py depends on'
        + f' grpcio>={GRPC_GENERATED_VERSION}.'
        + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
        + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
    )


class P2pServiceStub(object):
    """P2P Metadata Service for coordinating NIXL/RDMA transfers between vLLM instances.
    The server stores model metadata keyed by mx_source_id (a hash of SourceIdentity).
    Clients query for existing sources and publish their own metadata.
    """

    def __init__(self, channel):
        """Constructor.

        Args:
            channel: A grpc.Channel.
        """
        self.PublishMetadata = channel.unary_unary(
                '/model_express.p2p.P2pService/PublishMetadata',
                request_serializer=p2p__pb2.PublishMetadataRequest.SerializeToString,
                response_deserializer=p2p__pb2.PublishMetadataResponse.FromString,
                _registered_method=True)
        self.ListSources = channel.unary_unary(
                '/model_express.p2p.P2pService/ListSources',
                request_serializer=p2p__pb2.ListSourcesRequest.SerializeToString,
                response_deserializer=p2p__pb2.ListSourcesResponse.FromString,
                _registered_method=True)
        self.GetMetadata = channel.unary_unary(
                '/model_express.p2p.P2pService/GetMetadata',
                request_serializer=p2p__pb2.GetMetadataRequest.SerializeToString,
                response_deserializer=p2p__pb2.GetMetadataResponse.FromString,
                _registered_method=True)
        self.UpdateStatus = channel.unary_unary(
                '/model_express.p2p.P2pService/UpdateStatus',
                request_serializer=p2p__pb2.UpdateStatusRequest.SerializeToString,
                response_deserializer=p2p__pb2.UpdateStatusResponse.FromString,
                _registered_method=True)


class P2pServiceServicer(object):
    """P2P Metadata Service for coordinating NIXL/RDMA transfers between vLLM instances.
    The server stores model metadata keyed by mx_source_id (a hash of SourceIdentity).
    Clients query for existing sources and publish their own metadata.
    """

    def PublishMetadata(self, request, context):
        """Publish model metadata - called by client after loading model weights
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def ListSources(self, request, context):
        """List available source workers - lightweight, no tensor metadata.
        Returns one SourceInstanceRef per worker; clients filter by worker_rank
        to find matching peers and then call GetMetadata for the chosen one.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def GetMetadata(self, request, context):
        """Fetch full tensor metadata for one specific worker (MB-scale).
        Call this after filtering ListSources results by worker_rank.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def UpdateStatus(self, request, context):
        """Update source status - called by source after NIXL registration and warmup
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_P2pServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'PublishMetadata': grpc.unary_unary_rpc_method_handler(
                    servicer.PublishMetadata,
                    request_deserializer=p2p__pb2.PublishMetadataRequest.FromString,
                    response_serializer=p2p__pb2.PublishMetadataResponse.SerializeToString,
            ),
            'ListSources': grpc.unary_unary_rpc_method_handler(
                    servicer.ListSources,
                    request_deserializer=p2p__pb2.ListSourcesRequest.FromString,
                    response_serializer=p2p__pb2.ListSourcesResponse.SerializeToString,
            ),
            'GetMetadata': grpc.unary_unary_rpc_method_handler(
                    servicer.GetMetadata,
                    request_deserializer=p2p__pb2.GetMetadataRequest.FromString,
                    response_serializer=p2p__pb2.GetMetadataResponse.SerializeToString,
            ),
            'UpdateStatus': grpc.unary_unary_rpc_method_handler(
                    servicer.UpdateStatus,
                    request_deserializer=p2p__pb2.UpdateStatusRequest.FromString,
                    response_serializer=p2p__pb2.UpdateStatusResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'model_express.p2p.P2pService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('model_express.p2p.P2pService', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class P2pService(object):
    """P2P Metadata Service for coordinating NIXL/RDMA transfers between vLLM instances.
    The server stores model metadata keyed by mx_source_id (a hash of SourceIdentity).
    Clients query for existing sources and publish their own metadata.
    """

    @staticmethod
    def PublishMetadata(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/model_express.p2p.P2pService/PublishMetadata',
            p2p__pb2.PublishMetadataRequest.SerializeToString,
            p2p__pb2.PublishMetadataResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def ListSources(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/model_express.p2p.P2pService/ListSources',
            p2p__pb2.ListSourcesRequest.SerializeToString,
            p2p__pb2.ListSourcesResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def GetMetadata(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/model_express.p2p.P2pService/GetMetadata',
            p2p__pb2.GetMetadataRequest.SerializeToString,
            p2p__pb2.GetMetadataResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def UpdateStatus(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/model_express.p2p.P2pService/UpdateStatus',
            p2p__pb2.UpdateStatusRequest.SerializeToString,
            p2p__pb2.UpdateStatusResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)


class WorkerServiceStub(object):
    """============================================================================
    Worker Service (P2P manifest exchange)
    ============================================================================

    Per-worker gRPC service for direct manifest retrieval. Sources start this
    service when MX_P2P_METADATA=1. Targets call GetTensorManifest for tensor
    descriptors or artifact manifest RPCs for sealed file-backed artifacts.
    Artifact bytes move through NIXL; PrepareArtifactChunk only creates a
    source-side registered DRAM range and returns its transfer descriptor.
    """

    def __init__(self, channel):
        """Constructor.

        Args:
            channel: A grpc.Channel.
        """
        self.GetTensorManifest = channel.unary_unary(
                '/model_express.p2p.WorkerService/GetTensorManifest',
                request_serializer=p2p__pb2.GetTensorManifestRequest.SerializeToString,
                response_deserializer=p2p__pb2.GetTensorManifestResponse.FromString,
                _registered_method=True)
        self.PrepareTensorRead = channel.unary_unary(
                '/model_express.p2p.WorkerService/PrepareTensorRead',
                request_serializer=p2p__pb2.PrepareTensorReadRequest.SerializeToString,
                response_deserializer=p2p__pb2.PrepareTensorReadResponse.FromString,
                _registered_method=True)
        self.ReleaseTensorRead = channel.unary_unary(
                '/model_express.p2p.WorkerService/ReleaseTensorRead',
                request_serializer=p2p__pb2.ReleaseTensorReadRequest.SerializeToString,
                response_deserializer=p2p__pb2.ReleaseTensorReadResponse.FromString,
                _registered_method=True)
        self.GetArtifactManifestHeader = channel.unary_unary(
                '/model_express.p2p.WorkerService/GetArtifactManifestHeader',
                request_serializer=p2p__pb2.GetArtifactManifestHeaderRequest.SerializeToString,
                response_deserializer=p2p__pb2.GetArtifactManifestHeaderResponse.FromString,
                _registered_method=True)
        self.GetArtifactManifestChunks = channel.unary_unary(
                '/model_express.p2p.WorkerService/GetArtifactManifestChunks',
                request_serializer=p2p__pb2.GetArtifactManifestChunksRequest.SerializeToString,
                response_deserializer=p2p__pb2.GetArtifactManifestChunksResponse.FromString,
                _registered_method=True)
        self.PrepareArtifactChunk = channel.unary_unary(
                '/model_express.p2p.WorkerService/PrepareArtifactChunk',
                request_serializer=p2p__pb2.PrepareArtifactChunkRequest.SerializeToString,
                response_deserializer=p2p__pb2.PrepareArtifactChunkResponse.FromString,
                _registered_method=True)
        self.ReleaseArtifactChunk = channel.unary_unary(
                '/model_express.p2p.WorkerService/ReleaseArtifactChunk',
                request_serializer=p2p__pb2.ReleaseArtifactChunkRequest.SerializeToString,
                response_deserializer=p2p__pb2.ReleaseArtifactChunkResponse.FromString,
                _registered_method=True)


class WorkerServiceServicer(object):
    """============================================================================
    Worker Service (P2P manifest exchange)
    ============================================================================

    Per-worker gRPC service for direct manifest retrieval. Sources start this
    service when MX_P2P_METADATA=1. Targets call GetTensorManifest for tensor
    descriptors or artifact manifest RPCs for sealed file-backed artifacts.
    Artifact bytes move through NIXL; PrepareArtifactChunk only creates a
    source-side registered DRAM range and returns its transfer descriptor.
    """

    def GetTensorManifest(self, request, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def PrepareTensorRead(self, request, context):
        """Prepare/Release protect a mutable RL generator's live tensor storage while
        another generator reads it during active-refit P2P transfer.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def ReleaseTensorRead(self, request, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def GetArtifactManifestHeader(self, request, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def GetArtifactManifestChunks(self, request, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def PrepareArtifactChunk(self, request, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def ReleaseArtifactChunk(self, request, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_WorkerServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'GetTensorManifest': grpc.unary_unary_rpc_method_handler(
                    servicer.GetTensorManifest,
                    request_deserializer=p2p__pb2.GetTensorManifestRequest.FromString,
                    response_serializer=p2p__pb2.GetTensorManifestResponse.SerializeToString,
            ),
            'PrepareTensorRead': grpc.unary_unary_rpc_method_handler(
                    servicer.PrepareTensorRead,
                    request_deserializer=p2p__pb2.PrepareTensorReadRequest.FromString,
                    response_serializer=p2p__pb2.PrepareTensorReadResponse.SerializeToString,
            ),
            'ReleaseTensorRead': grpc.unary_unary_rpc_method_handler(
                    servicer.ReleaseTensorRead,
                    request_deserializer=p2p__pb2.ReleaseTensorReadRequest.FromString,
                    response_serializer=p2p__pb2.ReleaseTensorReadResponse.SerializeToString,
            ),
            'GetArtifactManifestHeader': grpc.unary_unary_rpc_method_handler(
                    servicer.GetArtifactManifestHeader,
                    request_deserializer=p2p__pb2.GetArtifactManifestHeaderRequest.FromString,
                    response_serializer=p2p__pb2.GetArtifactManifestHeaderResponse.SerializeToString,
            ),
            'GetArtifactManifestChunks': grpc.unary_unary_rpc_method_handler(
                    servicer.GetArtifactManifestChunks,
                    request_deserializer=p2p__pb2.GetArtifactManifestChunksRequest.FromString,
                    response_serializer=p2p__pb2.GetArtifactManifestChunksResponse.SerializeToString,
            ),
            'PrepareArtifactChunk': grpc.unary_unary_rpc_method_handler(
                    servicer.PrepareArtifactChunk,
                    request_deserializer=p2p__pb2.PrepareArtifactChunkRequest.FromString,
                    response_serializer=p2p__pb2.PrepareArtifactChunkResponse.SerializeToString,
            ),
            'ReleaseArtifactChunk': grpc.unary_unary_rpc_method_handler(
                    servicer.ReleaseArtifactChunk,
                    request_deserializer=p2p__pb2.ReleaseArtifactChunkRequest.FromString,
                    response_serializer=p2p__pb2.ReleaseArtifactChunkResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'model_express.p2p.WorkerService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('model_express.p2p.WorkerService', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class WorkerService(object):
    """============================================================================
    Worker Service (P2P manifest exchange)
    ============================================================================

    Per-worker gRPC service for direct manifest retrieval. Sources start this
    service when MX_P2P_METADATA=1. Targets call GetTensorManifest for tensor
    descriptors or artifact manifest RPCs for sealed file-backed artifacts.
    Artifact bytes move through NIXL; PrepareArtifactChunk only creates a
    source-side registered DRAM range and returns its transfer descriptor.
    """

    @staticmethod
    def GetTensorManifest(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/model_express.p2p.WorkerService/GetTensorManifest',
            p2p__pb2.GetTensorManifestRequest.SerializeToString,
            p2p__pb2.GetTensorManifestResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def PrepareTensorRead(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/model_express.p2p.WorkerService/PrepareTensorRead',
            p2p__pb2.PrepareTensorReadRequest.SerializeToString,
            p2p__pb2.PrepareTensorReadResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def ReleaseTensorRead(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/model_express.p2p.WorkerService/ReleaseTensorRead',
            p2p__pb2.ReleaseTensorReadRequest.SerializeToString,
            p2p__pb2.ReleaseTensorReadResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def GetArtifactManifestHeader(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/model_express.p2p.WorkerService/GetArtifactManifestHeader',
            p2p__pb2.GetArtifactManifestHeaderRequest.SerializeToString,
            p2p__pb2.GetArtifactManifestHeaderResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def GetArtifactManifestChunks(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/model_express.p2p.WorkerService/GetArtifactManifestChunks',
            p2p__pb2.GetArtifactManifestChunksRequest.SerializeToString,
            p2p__pb2.GetArtifactManifestChunksResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def PrepareArtifactChunk(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/model_express.p2p.WorkerService/PrepareArtifactChunk',
            p2p__pb2.PrepareArtifactChunkRequest.SerializeToString,
            p2p__pb2.PrepareArtifactChunkResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def ReleaseArtifactChunk(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/model_express.p2p.WorkerService/ReleaseArtifactChunk',
            p2p__pb2.ReleaseArtifactChunkRequest.SerializeToString,
            p2p__pb2.ReleaseArtifactChunkResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)