mplang-nightly 0.1.dev164__py3-none-any.whl → 0.1.dev166__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mplang/core/expr/evaluator.py +55 -15
- mplang/kernels/__init__.py +28 -0
- mplang/kernels/builtin.py +91 -56
- mplang/kernels/crypto.py +39 -30
- mplang/kernels/mock_tee.py +10 -8
- mplang/kernels/phe.py +238 -39
- mplang/kernels/spu.py +134 -45
- mplang/kernels/sql_duckdb.py +8 -13
- mplang/kernels/stablehlo.py +15 -9
- mplang/kernels/value.py +626 -0
- mplang/protos/v1alpha1/mpir_pb2.pyi +71 -21
- mplang/protos/v1alpha1/value_pb2.py +34 -0
- mplang/protos/v1alpha1/value_pb2.pyi +169 -0
- mplang/runtime/client.py +19 -8
- mplang/runtime/communicator.py +11 -4
- mplang/runtime/driver.py +16 -1
- mplang/runtime/link_comm.py +26 -79
- mplang/runtime/server.py +30 -29
- mplang/runtime/session.py +9 -0
- mplang/runtime/simulation.py +4 -5
- mplang/simp/__init__.py +1 -1
- {mplang_nightly-0.1.dev164.dist-info → mplang_nightly-0.1.dev166.dist-info}/METADATA +1 -1
- {mplang_nightly-0.1.dev164.dist-info → mplang_nightly-0.1.dev166.dist-info}/RECORD +26 -23
- {mplang_nightly-0.1.dev164.dist-info → mplang_nightly-0.1.dev166.dist-info}/WHEEL +0 -0
- {mplang_nightly-0.1.dev164.dist-info → mplang_nightly-0.1.dev166.dist-info}/entry_points.txt +0 -0
- {mplang_nightly-0.1.dev164.dist-info → mplang_nightly-0.1.dev166.dist-info}/licenses/LICENSE +0 -0
@@ -38,6 +38,7 @@ class _DataType:
|
|
38
38
|
class _DataTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[_DataType.ValueType], builtins.type):
|
39
39
|
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
|
40
40
|
UNDEFINED: _DataType.ValueType # 0
|
41
|
+
"""Undefined data type"""
|
41
42
|
U8: _DataType.ValueType # 1
|
42
43
|
"""uint8_t"""
|
43
44
|
I8: _DataType.ValueType # 2
|
@@ -83,6 +84,7 @@ class DataType(_DataType, metaclass=_DataTypeEnumTypeWrapper):
|
|
83
84
|
"""Data type enumeration"""
|
84
85
|
|
85
86
|
UNDEFINED: DataType.ValueType # 0
|
87
|
+
"""Undefined data type"""
|
86
88
|
U8: DataType.ValueType # 1
|
87
89
|
"""uint8_t"""
|
88
90
|
I8: DataType.ValueType # 2
|
@@ -138,14 +140,23 @@ class AttrProto(google.protobuf.message.Message):
|
|
138
140
|
class _AttrTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[AttrProto._AttrType.ValueType], builtins.type):
|
139
141
|
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
|
140
142
|
UNDEFINED: AttrProto._AttrType.ValueType # 0
|
143
|
+
"""Undefined attribute type"""
|
141
144
|
FLOAT: AttrProto._AttrType.ValueType # 1
|
145
|
+
"""Single float value"""
|
142
146
|
INT: AttrProto._AttrType.ValueType # 2
|
147
|
+
"""Single integer value"""
|
143
148
|
STRING: AttrProto._AttrType.ValueType # 3
|
149
|
+
"""Single string value"""
|
144
150
|
BOOL: AttrProto._AttrType.ValueType # 4
|
151
|
+
"""Single boolean value"""
|
145
152
|
BYTES: AttrProto._AttrType.ValueType # 5
|
153
|
+
"""Binary data"""
|
146
154
|
FLOATS: AttrProto._AttrType.ValueType # 6
|
155
|
+
"""Array of float values"""
|
147
156
|
INTS: AttrProto._AttrType.ValueType # 7
|
157
|
+
"""Array of integer values"""
|
148
158
|
STRINGS: AttrProto._AttrType.ValueType # 8
|
159
|
+
"""Array of string values"""
|
149
160
|
FUNCTION: AttrProto._AttrType.ValueType # 10
|
150
161
|
"""Textual function reference"""
|
151
162
|
GRAPH: AttrProto._AttrType.ValueType # 11
|
@@ -155,14 +166,23 @@ class AttrProto(google.protobuf.message.Message):
|
|
155
166
|
"""Define possible attribute types"""
|
156
167
|
|
157
168
|
UNDEFINED: AttrProto.AttrType.ValueType # 0
|
169
|
+
"""Undefined attribute type"""
|
158
170
|
FLOAT: AttrProto.AttrType.ValueType # 1
|
171
|
+
"""Single float value"""
|
159
172
|
INT: AttrProto.AttrType.ValueType # 2
|
173
|
+
"""Single integer value"""
|
160
174
|
STRING: AttrProto.AttrType.ValueType # 3
|
175
|
+
"""Single string value"""
|
161
176
|
BOOL: AttrProto.AttrType.ValueType # 4
|
177
|
+
"""Single boolean value"""
|
162
178
|
BYTES: AttrProto.AttrType.ValueType # 5
|
179
|
+
"""Binary data"""
|
163
180
|
FLOATS: AttrProto.AttrType.ValueType # 6
|
181
|
+
"""Array of float values"""
|
164
182
|
INTS: AttrProto.AttrType.ValueType # 7
|
183
|
+
"""Array of integer values"""
|
165
184
|
STRINGS: AttrProto.AttrType.ValueType # 8
|
185
|
+
"""Array of string values"""
|
166
186
|
FUNCTION: AttrProto.AttrType.ValueType # 10
|
167
187
|
"""Textual function reference"""
|
168
188
|
GRAPH: AttrProto.AttrType.ValueType # 11
|
@@ -182,24 +202,24 @@ class AttrProto(google.protobuf.message.Message):
|
|
182
202
|
type: global___AttrProto.AttrType.ValueType
|
183
203
|
"""Type of the attribute"""
|
184
204
|
f: builtins.float
|
185
|
-
"""FLOAT"""
|
205
|
+
"""FLOAT value"""
|
186
206
|
i: builtins.int
|
187
|
-
"""INT"""
|
207
|
+
"""INT value"""
|
188
208
|
s: builtins.str
|
189
|
-
"""STRING"""
|
209
|
+
"""STRING value"""
|
190
210
|
b: builtins.bool
|
191
|
-
"""BOOL"""
|
211
|
+
"""BOOL value"""
|
192
212
|
raw_bytes: builtins.bytes
|
193
213
|
"""BYTES - for raw binary data"""
|
194
214
|
@property
|
195
215
|
def floats(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]:
|
196
|
-
"""FLOATS"""
|
216
|
+
"""FLOATS - array of float values"""
|
197
217
|
@property
|
198
218
|
def ints(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]:
|
199
|
-
"""INTS"""
|
219
|
+
"""INTS - array of integer values"""
|
200
220
|
@property
|
201
221
|
def strs(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]:
|
202
|
-
"""STRINGS"""
|
222
|
+
"""STRINGS - array of string values"""
|
203
223
|
@property
|
204
224
|
def func(self) -> global___FuncProto:
|
205
225
|
"""FUNCTION - textual function reference"""
|
@@ -228,6 +248,8 @@ global___AttrProto = AttrProto
|
|
228
248
|
|
229
249
|
@typing_extensions.final
|
230
250
|
class FuncProto(google.protobuf.message.Message):
|
251
|
+
"""Function prototype message"""
|
252
|
+
|
231
253
|
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
232
254
|
|
233
255
|
@typing_extensions.final
|
@@ -254,7 +276,7 @@ class FuncProto(google.protobuf.message.Message):
|
|
254
276
|
DOC_STRING_FIELD_NUMBER: builtins.int
|
255
277
|
ATTRS_FIELD_NUMBER: builtins.int
|
256
278
|
type: builtins.str
|
257
|
-
"""Function type
|
279
|
+
"""Function type"""
|
258
280
|
name: builtins.str
|
259
281
|
"""Function name"""
|
260
282
|
body: builtins.str
|
@@ -279,13 +301,17 @@ global___FuncProto = FuncProto
|
|
279
301
|
|
280
302
|
@typing_extensions.final
|
281
303
|
class TensorTypeProto(google.protobuf.message.Message):
|
304
|
+
"""Tensor type definition"""
|
305
|
+
|
282
306
|
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
283
307
|
|
284
308
|
DTYPE_FIELD_NUMBER: builtins.int
|
285
309
|
SHAPE_DIMS_FIELD_NUMBER: builtins.int
|
286
310
|
dtype: global___DataType.ValueType
|
311
|
+
"""Data type of the tensor elements"""
|
287
312
|
@property
|
288
|
-
def shape_dims(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]:
|
313
|
+
def shape_dims(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]:
|
314
|
+
"""Shape dimensions of the tensor"""
|
289
315
|
def __init__(
|
290
316
|
self,
|
291
317
|
*,
|
@@ -298,16 +324,22 @@ global___TensorTypeProto = TensorTypeProto
|
|
298
324
|
|
299
325
|
@typing_extensions.final
|
300
326
|
class TableTypeProto(google.protobuf.message.Message):
|
327
|
+
"""Table type definition"""
|
328
|
+
|
301
329
|
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
302
330
|
|
303
331
|
@typing_extensions.final
|
304
332
|
class Column(google.protobuf.message.Message):
|
333
|
+
"""Column definition within a table"""
|
334
|
+
|
305
335
|
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
306
336
|
|
307
337
|
NAME_FIELD_NUMBER: builtins.int
|
308
338
|
DTYPE_FIELD_NUMBER: builtins.int
|
309
339
|
name: builtins.str
|
340
|
+
"""Name of the column"""
|
310
341
|
dtype: global___DataType.ValueType
|
342
|
+
"""Data type of the column"""
|
311
343
|
def __init__(
|
312
344
|
self,
|
313
345
|
*,
|
@@ -318,7 +350,8 @@ class TableTypeProto(google.protobuf.message.Message):
|
|
318
350
|
|
319
351
|
COLUMNS_FIELD_NUMBER: builtins.int
|
320
352
|
@property
|
321
|
-
def columns(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___TableTypeProto.Column]:
|
353
|
+
def columns(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___TableTypeProto.Column]:
|
354
|
+
"""List of columns in the table"""
|
322
355
|
def __init__(
|
323
356
|
self,
|
324
357
|
*,
|
@@ -330,6 +363,8 @@ global___TableTypeProto = TableTypeProto
|
|
330
363
|
|
331
364
|
@typing_extensions.final
|
332
365
|
class MPTypeProto(google.protobuf.message.Message):
|
366
|
+
"""Multi-party type definition"""
|
367
|
+
|
333
368
|
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
334
369
|
|
335
370
|
@typing_extensions.final
|
@@ -355,14 +390,16 @@ class MPTypeProto(google.protobuf.message.Message):
|
|
355
390
|
PMASK_FIELD_NUMBER: builtins.int
|
356
391
|
ATTRS_FIELD_NUMBER: builtins.int
|
357
392
|
@property
|
358
|
-
def tensor_type(self) -> global___TensorTypeProto:
|
393
|
+
def tensor_type(self) -> global___TensorTypeProto:
|
394
|
+
"""Tensor type specification"""
|
359
395
|
@property
|
360
|
-
def table_type(self) -> global___TableTypeProto:
|
396
|
+
def table_type(self) -> global___TableTypeProto:
|
397
|
+
"""Table type specification"""
|
361
398
|
pmask: builtins.int
|
362
|
-
"""
|
399
|
+
"""Party mask (-1 for dynamic mask, >=0 for static mask)"""
|
363
400
|
@property
|
364
401
|
def attrs(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___AttrProto]:
|
365
|
-
"""attributes"""
|
402
|
+
"""Additional attributes"""
|
366
403
|
def __init__(
|
367
404
|
self,
|
368
405
|
*,
|
@@ -379,6 +416,8 @@ global___MPTypeProto = MPTypeProto
|
|
379
416
|
|
380
417
|
@typing_extensions.final
|
381
418
|
class NodeProto(google.protobuf.message.Message):
|
419
|
+
"""Node prototype definition"""
|
420
|
+
|
382
421
|
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
383
422
|
|
384
423
|
@typing_extensions.final
|
@@ -406,16 +445,20 @@ class NodeProto(google.protobuf.message.Message):
|
|
406
445
|
ATTRS_FIELD_NUMBER: builtins.int
|
407
446
|
DOC_STRING_FIELD_NUMBER: builtins.int
|
408
447
|
op_type: builtins.str
|
448
|
+
"""Operation type of the node"""
|
409
449
|
name: builtins.str
|
450
|
+
"""Name of the node"""
|
410
451
|
@property
|
411
452
|
def inputs(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]:
|
412
|
-
"""{name:index}"""
|
453
|
+
"""Input specifications in format {name:index}"""
|
413
454
|
@property
|
414
455
|
def outs_info(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___MPTypeProto]:
|
415
|
-
""""""
|
456
|
+
"""Output type information"""
|
416
457
|
@property
|
417
|
-
def attrs(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___AttrProto]:
|
458
|
+
def attrs(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___AttrProto]:
|
459
|
+
"""Node attributes"""
|
418
460
|
doc_string: builtins.str
|
461
|
+
"""Documentation string"""
|
419
462
|
def __init__(
|
420
463
|
self,
|
421
464
|
*,
|
@@ -432,6 +475,8 @@ global___NodeProto = NodeProto
|
|
432
475
|
|
433
476
|
@typing_extensions.final
|
434
477
|
class VersionInfo(google.protobuf.message.Message):
|
478
|
+
"""Version information definition"""
|
479
|
+
|
435
480
|
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
436
481
|
|
437
482
|
MAJOR_FIELD_NUMBER: builtins.int
|
@@ -460,6 +505,8 @@ global___VersionInfo = VersionInfo
|
|
460
505
|
|
461
506
|
@typing_extensions.final
|
462
507
|
class GraphProto(google.protobuf.message.Message):
|
508
|
+
"""Graph prototype definition"""
|
509
|
+
|
463
510
|
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
464
511
|
|
465
512
|
@typing_extensions.final
|
@@ -485,14 +532,17 @@ class GraphProto(google.protobuf.message.Message):
|
|
485
532
|
OUTPUTS_FIELD_NUMBER: builtins.int
|
486
533
|
ATTRS_FIELD_NUMBER: builtins.int
|
487
534
|
@property
|
488
|
-
def version(self) -> global___VersionInfo:
|
535
|
+
def version(self) -> global___VersionInfo:
|
536
|
+
"""Version information"""
|
489
537
|
@property
|
490
|
-
def nodes(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___NodeProto]:
|
538
|
+
def nodes(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___NodeProto]:
|
539
|
+
"""List of nodes in the graph"""
|
491
540
|
@property
|
492
541
|
def outputs(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]:
|
493
|
-
"""{name:index}"""
|
542
|
+
"""Output specifications in format {name:index}"""
|
494
543
|
@property
|
495
|
-
def attrs(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___AttrProto]:
|
544
|
+
def attrs(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___AttrProto]:
|
545
|
+
"""Graph attributes"""
|
496
546
|
def __init__(
|
497
547
|
self,
|
498
548
|
*,
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
|
+
# source: mplang/protos/v1alpha1/value.proto
|
4
|
+
# Protobuf Python Version: 5.26.1
|
5
|
+
"""Generated protocol buffer code."""
|
6
|
+
from google.protobuf import descriptor as _descriptor
|
7
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
8
|
+
from google.protobuf import symbol_database as _symbol_database
|
9
|
+
from google.protobuf.internal import builder as _builder
|
10
|
+
# @@protoc_insertion_point(imports)
|
11
|
+
|
12
|
+
_sym_db = _symbol_database.Default()
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\"mplang/protos/v1alpha1/value.proto\x12\x16mplang.protos.v1alpha1\"\xe8\x02\n\x0eValueAttrProto\x12\x43\n\x04type\x18\x01 \x01(\x0e\x32/.mplang.protos.v1alpha1.ValueAttrProto.AttrTypeR\x04type\x12\x0c\n\x01\x66\x18\x02 \x01(\x02R\x01\x66\x12\x0c\n\x01i\x18\x03 \x01(\x03R\x01i\x12\x0c\n\x01s\x18\x04 \x01(\tR\x01s\x12\x0c\n\x01\x62\x18\x05 \x01(\x08R\x01\x62\x12\x1b\n\traw_bytes\x18\x06 \x01(\x0cR\x08rawBytes\x12\x16\n\x06\x66loats\x18\x07 \x03(\x02R\x06\x66loats\x12\x12\n\x04ints\x18\x08 \x03(\x03R\x04ints\x12\x12\n\x04strs\x18\t \x03(\tR\x04strs\"|\n\x08\x41ttrType\x12\r\n\tUNDEFINED\x10\x00\x12\t\n\x05\x46LOAT\x10\x01\x12\x07\n\x03INT\x10\x02\x12\n\n\x06STRING\x10\x03\x12\x08\n\x04\x42OOL\x10\x04\x12\t\n\x05\x42YTES\x10\x05\x12\n\n\x06\x46LOATS\x10\x06\x12\x08\n\x04INTS\x10\x07\x12\x0b\n\x07STRINGS\x10\x08\x12\t\n\x05\x45MPTY\x10\t\"\xa3\x02\n\nValueProto\x12\x12\n\x04kind\x18\x01 \x01(\tR\x04kind\x12#\n\rvalue_version\x18\x02 \x01(\rR\x0cvalueVersion\x12\x18\n\x07payload\x18\x03 \x01(\x0cR\x07payload\x12Y\n\rruntime_attrs\x18\x04 \x03(\x0b\x32\x34.mplang.protos.v1alpha1.ValueProto.RuntimeAttrsEntryR\x0cruntimeAttrs\x1ag\n\x11RuntimeAttrsEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12<\n\x05value\x18\x02 \x01(\x0b\x32&.mplang.protos.v1alpha1.ValueAttrProtoR\x05value:\x02\x38\x01\x62\x06proto3')
|
18
|
+
|
19
|
+
_globals = globals()
|
20
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
21
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'mplang.protos.v1alpha1.value_pb2', _globals)
|
22
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
23
|
+
DESCRIPTOR._loaded_options = None
|
24
|
+
_globals['_VALUEPROTO_RUNTIMEATTRSENTRY']._loaded_options = None
|
25
|
+
_globals['_VALUEPROTO_RUNTIMEATTRSENTRY']._serialized_options = b'8\001'
|
26
|
+
_globals['_VALUEATTRPROTO']._serialized_start=63
|
27
|
+
_globals['_VALUEATTRPROTO']._serialized_end=423
|
28
|
+
_globals['_VALUEATTRPROTO_ATTRTYPE']._serialized_start=299
|
29
|
+
_globals['_VALUEATTRPROTO_ATTRTYPE']._serialized_end=423
|
30
|
+
_globals['_VALUEPROTO']._serialized_start=426
|
31
|
+
_globals['_VALUEPROTO']._serialized_end=717
|
32
|
+
_globals['_VALUEPROTO_RUNTIMEATTRSENTRY']._serialized_start=614
|
33
|
+
_globals['_VALUEPROTO_RUNTIMEATTRSENTRY']._serialized_end=717
|
34
|
+
# @@protoc_insertion_point(module_scope)
|
@@ -0,0 +1,169 @@
|
|
1
|
+
"""
|
2
|
+
@generated by mypy-protobuf. Do not edit manually!
|
3
|
+
isort:skip_file
|
4
|
+
Copyright 2025 Ant Group Co., Ltd.
|
5
|
+
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
you may not use this file except in compliance with the License.
|
8
|
+
You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
See the License for the specific language governing permissions and
|
16
|
+
limitations under the License.
|
17
|
+
"""
|
18
|
+
import builtins
|
19
|
+
import collections.abc
|
20
|
+
import google.protobuf.descriptor
|
21
|
+
import google.protobuf.internal.containers
|
22
|
+
import google.protobuf.internal.enum_type_wrapper
|
23
|
+
import google.protobuf.message
|
24
|
+
import sys
|
25
|
+
import typing
|
26
|
+
|
27
|
+
if sys.version_info >= (3, 10):
|
28
|
+
import typing as typing_extensions
|
29
|
+
else:
|
30
|
+
import typing_extensions
|
31
|
+
|
32
|
+
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
|
33
|
+
|
34
|
+
@typing_extensions.final
|
35
|
+
class ValueAttrProto(google.protobuf.message.Message):
|
36
|
+
"""Lightweight attribute proto used solely for ValueProto runtime metadata."""
|
37
|
+
|
38
|
+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
39
|
+
|
40
|
+
class _AttrType:
|
41
|
+
ValueType = typing.NewType("ValueType", builtins.int)
|
42
|
+
V: typing_extensions.TypeAlias = ValueType
|
43
|
+
|
44
|
+
class _AttrTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[ValueAttrProto._AttrType.ValueType], builtins.type):
|
45
|
+
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
|
46
|
+
UNDEFINED: ValueAttrProto._AttrType.ValueType # 0
|
47
|
+
FLOAT: ValueAttrProto._AttrType.ValueType # 1
|
48
|
+
INT: ValueAttrProto._AttrType.ValueType # 2
|
49
|
+
STRING: ValueAttrProto._AttrType.ValueType # 3
|
50
|
+
BOOL: ValueAttrProto._AttrType.ValueType # 4
|
51
|
+
BYTES: ValueAttrProto._AttrType.ValueType # 5
|
52
|
+
FLOATS: ValueAttrProto._AttrType.ValueType # 6
|
53
|
+
INTS: ValueAttrProto._AttrType.ValueType # 7
|
54
|
+
STRINGS: ValueAttrProto._AttrType.ValueType # 8
|
55
|
+
EMPTY: ValueAttrProto._AttrType.ValueType # 9
|
56
|
+
"""Represents an explicitly empty attribute value (e.g., empty list)"""
|
57
|
+
|
58
|
+
class AttrType(_AttrType, metaclass=_AttrTypeEnumTypeWrapper): ...
|
59
|
+
UNDEFINED: ValueAttrProto.AttrType.ValueType # 0
|
60
|
+
FLOAT: ValueAttrProto.AttrType.ValueType # 1
|
61
|
+
INT: ValueAttrProto.AttrType.ValueType # 2
|
62
|
+
STRING: ValueAttrProto.AttrType.ValueType # 3
|
63
|
+
BOOL: ValueAttrProto.AttrType.ValueType # 4
|
64
|
+
BYTES: ValueAttrProto.AttrType.ValueType # 5
|
65
|
+
FLOATS: ValueAttrProto.AttrType.ValueType # 6
|
66
|
+
INTS: ValueAttrProto.AttrType.ValueType # 7
|
67
|
+
STRINGS: ValueAttrProto.AttrType.ValueType # 8
|
68
|
+
EMPTY: ValueAttrProto.AttrType.ValueType # 9
|
69
|
+
"""Represents an explicitly empty attribute value (e.g., empty list)"""
|
70
|
+
|
71
|
+
TYPE_FIELD_NUMBER: builtins.int
|
72
|
+
F_FIELD_NUMBER: builtins.int
|
73
|
+
I_FIELD_NUMBER: builtins.int
|
74
|
+
S_FIELD_NUMBER: builtins.int
|
75
|
+
B_FIELD_NUMBER: builtins.int
|
76
|
+
RAW_BYTES_FIELD_NUMBER: builtins.int
|
77
|
+
FLOATS_FIELD_NUMBER: builtins.int
|
78
|
+
INTS_FIELD_NUMBER: builtins.int
|
79
|
+
STRS_FIELD_NUMBER: builtins.int
|
80
|
+
type: global___ValueAttrProto.AttrType.ValueType
|
81
|
+
f: builtins.float
|
82
|
+
i: builtins.int
|
83
|
+
s: builtins.str
|
84
|
+
b: builtins.bool
|
85
|
+
raw_bytes: builtins.bytes
|
86
|
+
@property
|
87
|
+
def floats(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: ...
|
88
|
+
@property
|
89
|
+
def ints(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: ...
|
90
|
+
@property
|
91
|
+
def strs(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ...
|
92
|
+
def __init__(
|
93
|
+
self,
|
94
|
+
*,
|
95
|
+
type: global___ValueAttrProto.AttrType.ValueType = ...,
|
96
|
+
f: builtins.float = ...,
|
97
|
+
i: builtins.int = ...,
|
98
|
+
s: builtins.str = ...,
|
99
|
+
b: builtins.bool = ...,
|
100
|
+
raw_bytes: builtins.bytes = ...,
|
101
|
+
floats: collections.abc.Iterable[builtins.float] | None = ...,
|
102
|
+
ints: collections.abc.Iterable[builtins.int] | None = ...,
|
103
|
+
strs: collections.abc.Iterable[builtins.str] | None = ...,
|
104
|
+
) -> None: ...
|
105
|
+
def ClearField(self, field_name: typing_extensions.Literal["b", b"b", "f", b"f", "floats", b"floats", "i", b"i", "ints", b"ints", "raw_bytes", b"raw_bytes", "s", b"s", "strs", b"strs", "type", b"type"]) -> None: ...
|
106
|
+
|
107
|
+
global___ValueAttrProto = ValueAttrProto
|
108
|
+
|
109
|
+
@typing_extensions.final
|
110
|
+
class ValueProto(google.protobuf.message.Message):
|
111
|
+
"""Generic envelope for kernel-level transferable values.
|
112
|
+
|
113
|
+
DESIGN PRINCIPLES
|
114
|
+
* Small, stable schema: only descriptors needed for dynamic dispatch.
|
115
|
+
* Payload is opaque to the envelope; per-kind versioning lives in
|
116
|
+
value_version.
|
117
|
+
* Backward-compatible evolution: only append new optional fields.
|
118
|
+
|
119
|
+
Versioning Guidelines:
|
120
|
+
- value_version: per-kind semantic payload version (maintained by KernelValue
|
121
|
+
subclass).
|
122
|
+
- Adding fields: assign new unique field numbers; never reuse old numbers.
|
123
|
+
- Removing fields: reserve the field number & (optionally) name.
|
124
|
+
"""
|
125
|
+
|
126
|
+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
127
|
+
|
128
|
+
@typing_extensions.final
|
129
|
+
class RuntimeAttrsEntry(google.protobuf.message.Message):
|
130
|
+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
131
|
+
|
132
|
+
KEY_FIELD_NUMBER: builtins.int
|
133
|
+
VALUE_FIELD_NUMBER: builtins.int
|
134
|
+
key: builtins.str
|
135
|
+
@property
|
136
|
+
def value(self) -> global___ValueAttrProto: ...
|
137
|
+
def __init__(
|
138
|
+
self,
|
139
|
+
*,
|
140
|
+
key: builtins.str = ...,
|
141
|
+
value: global___ValueAttrProto | None = ...,
|
142
|
+
) -> None: ...
|
143
|
+
def HasField(self, field_name: typing_extensions.Literal["value", b"value"]) -> builtins.bool: ...
|
144
|
+
def ClearField(self, field_name: typing_extensions.Literal["key", b"key", "value", b"value"]) -> None: ...
|
145
|
+
|
146
|
+
KIND_FIELD_NUMBER: builtins.int
|
147
|
+
VALUE_VERSION_FIELD_NUMBER: builtins.int
|
148
|
+
PAYLOAD_FIELD_NUMBER: builtins.int
|
149
|
+
RUNTIME_ATTRS_FIELD_NUMBER: builtins.int
|
150
|
+
kind: builtins.str
|
151
|
+
"""Globally unique identifier for Value subclass, e.g. "mplang.ndarray"."""
|
152
|
+
value_version: builtins.int
|
153
|
+
"""Per-kind payload schema version (>=1)."""
|
154
|
+
payload: builtins.bytes
|
155
|
+
"""Primary data payload bytes (layout defined by each Value subclass)."""
|
156
|
+
@property
|
157
|
+
def runtime_attrs(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___ValueAttrProto]:
|
158
|
+
"""Additional runtime metadata required to recreate the Value instance."""
|
159
|
+
def __init__(
|
160
|
+
self,
|
161
|
+
*,
|
162
|
+
kind: builtins.str = ...,
|
163
|
+
value_version: builtins.int = ...,
|
164
|
+
payload: builtins.bytes = ...,
|
165
|
+
runtime_attrs: collections.abc.Mapping[builtins.str, global___ValueAttrProto] | None = ...,
|
166
|
+
) -> None: ...
|
167
|
+
def ClearField(self, field_name: typing_extensions.Literal["kind", b"kind", "payload", b"payload", "runtime_attrs", b"runtime_attrs", "value_version", b"value_version"]) -> None: ...
|
168
|
+
|
169
|
+
global___ValueProto = ValueProto
|
mplang/runtime/client.py
CHANGED
@@ -25,9 +25,10 @@ from __future__ import annotations
|
|
25
25
|
import base64
|
26
26
|
from typing import Any
|
27
27
|
|
28
|
-
import cloudpickle as pickle
|
29
28
|
import httpx
|
30
29
|
|
30
|
+
from mplang.kernels.value import Value, decode_value, encode_value
|
31
|
+
|
31
32
|
|
32
33
|
class ExecutionStatus:
|
33
34
|
"""Status of a computation execution."""
|
@@ -253,8 +254,10 @@ class HttpExecutorClient:
|
|
253
254
|
"""
|
254
255
|
url = f"/sessions/{session_name}/symbols/{symbol_name}"
|
255
256
|
|
256
|
-
# Serialize data
|
257
|
-
|
257
|
+
# Serialize data using Value envelope
|
258
|
+
if not isinstance(data, Value):
|
259
|
+
raise TypeError(f"Data must be a Value instance, got {type(data)}")
|
260
|
+
data_bytes = encode_value(data)
|
258
261
|
data_b64 = base64.b64encode(data_bytes).decode("utf-8")
|
259
262
|
|
260
263
|
payload = {"data": data_b64, "mptype": mptype or {}}
|
@@ -286,11 +289,15 @@ class HttpExecutorClient:
|
|
286
289
|
response.raise_for_status()
|
287
290
|
symbol_data = response.json()
|
288
291
|
|
289
|
-
# Deserialize data
|
292
|
+
# Deserialize data using Value envelope
|
290
293
|
data_bytes = base64.b64decode(symbol_data["data"])
|
291
|
-
return
|
294
|
+
return decode_value(data_bytes)
|
292
295
|
|
293
|
-
except
|
296
|
+
except httpx.HTTPStatusError as e:
|
297
|
+
if e.response is not None and e.response.status_code == 404:
|
298
|
+
return None
|
299
|
+
raise self._raise_http_error(f"get symbol {symbol_name}", e) from e
|
300
|
+
except httpx.RequestError as e:
|
294
301
|
raise self._raise_http_error(f"get symbol {symbol_name}", e) from e
|
295
302
|
|
296
303
|
async def delete_symbol(self, session_name: str, symbol_name: str) -> None:
|
@@ -403,8 +410,12 @@ class HttpExecutorClient:
|
|
403
410
|
"""
|
404
411
|
url = f"/api/v1/symbols/{symbol_name}"
|
405
412
|
try:
|
413
|
+
# Serialize using Value envelope
|
414
|
+
if not isinstance(data, Value):
|
415
|
+
raise TypeError(f"Data must be a Value instance, got {type(data)}")
|
416
|
+
data_bytes = encode_value(data)
|
406
417
|
payload = {
|
407
|
-
"data": base64.b64encode(
|
418
|
+
"data": base64.b64encode(data_bytes).decode("utf-8"),
|
408
419
|
"mptype": mptype or {},
|
409
420
|
}
|
410
421
|
resp = await self._client.put(url, json=payload)
|
@@ -421,7 +432,7 @@ class HttpExecutorClient:
|
|
421
432
|
resp.raise_for_status()
|
422
433
|
payload = resp.json()
|
423
434
|
data_bytes = base64.b64decode(payload["data"])
|
424
|
-
return
|
435
|
+
return decode_value(data_bytes)
|
425
436
|
except (httpx.HTTPStatusError, httpx.RequestError) as e:
|
426
437
|
raise self._raise_http_error(f"get global symbol {symbol_name}", e) from e
|
427
438
|
|
mplang/runtime/communicator.py
CHANGED
@@ -21,10 +21,10 @@ import base64
|
|
21
21
|
import logging
|
22
22
|
from typing import Any
|
23
23
|
|
24
|
-
import cloudpickle as pickle
|
25
24
|
import httpx
|
26
25
|
|
27
26
|
from mplang.core.comm import CommunicatorBase
|
27
|
+
from mplang.kernels.value import Value, decode_value, encode_value
|
28
28
|
|
29
29
|
|
30
30
|
class HttpCommunicator(CommunicatorBase):
|
@@ -52,8 +52,14 @@ class HttpCommunicator(CommunicatorBase):
|
|
52
52
|
)
|
53
53
|
|
54
54
|
try:
|
55
|
-
#
|
56
|
-
|
55
|
+
# Serialize data using Value envelope.
|
56
|
+
if not isinstance(data, Value):
|
57
|
+
raise TypeError(
|
58
|
+
f"Communicator requires Value instance, got {type(data).__name__}. "
|
59
|
+
"Wrap data in TensorValue or custom Value subclass."
|
60
|
+
)
|
61
|
+
data_bytes = encode_value(data)
|
62
|
+
|
57
63
|
data_b64 = base64.b64encode(data_bytes).decode("utf-8")
|
58
64
|
|
59
65
|
request_data = {
|
@@ -79,7 +85,8 @@ class HttpCommunicator(CommunicatorBase):
|
|
79
85
|
data_b64 = super().recv(frm, key)
|
80
86
|
|
81
87
|
data_bytes = base64.b64decode(data_b64)
|
82
|
-
|
88
|
+
# Deserialize using Value envelope
|
89
|
+
result = decode_value(data_bytes)
|
83
90
|
|
84
91
|
logging.debug(
|
85
92
|
f"Received data: from_rank={frm}, to_rank={self._rank}, key={key}"
|
mplang/runtime/driver.py
CHANGED
@@ -27,6 +27,8 @@ import uuid
|
|
27
27
|
from collections.abc import Sequence
|
28
28
|
from typing import Any
|
29
29
|
|
30
|
+
import numpy as np
|
31
|
+
|
30
32
|
from mplang.core.cluster import ClusterSpec
|
31
33
|
from mplang.core.expr.ast import Expr
|
32
34
|
from mplang.core.interp import InterpContext, InterpVar
|
@@ -34,6 +36,7 @@ from mplang.core.mask import Mask
|
|
34
36
|
from mplang.core.mpir import Writer
|
35
37
|
from mplang.core.mpobject import MPObject
|
36
38
|
from mplang.core.mptype import MPType
|
39
|
+
from mplang.kernels.value import TableValue, TensorValue
|
37
40
|
from mplang.runtime.client import HttpExecutorClient
|
38
41
|
|
39
42
|
|
@@ -257,7 +260,19 @@ class Driver(InterpContext):
|
|
257
260
|
try:
|
258
261
|
# The results will be in the same order as the clients (ranks)
|
259
262
|
results = await asyncio.gather(*tasks)
|
260
|
-
|
263
|
+
converted: list[Any] = []
|
264
|
+
for value in results:
|
265
|
+
if isinstance(value, TensorValue):
|
266
|
+
arr = value.to_numpy()
|
267
|
+
if isinstance(arr, np.ndarray) and arr.size == 1:
|
268
|
+
converted.append(arr.item())
|
269
|
+
else:
|
270
|
+
converted.append(arr)
|
271
|
+
elif isinstance(value, TableValue):
|
272
|
+
converted.append(value.to_pandas())
|
273
|
+
else:
|
274
|
+
converted.append(value)
|
275
|
+
return converted
|
261
276
|
except RuntimeError as e:
|
262
277
|
raise RuntimeError(
|
263
278
|
f"Failed to fetch symbol from one or more parties: {e}"
|