mplang-nightly 0.1.dev158__py3-none-any.whl → 0.1.dev268__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/__init__.py +21 -45
- mplang/py.typed +13 -0
- mplang/v1/__init__.py +157 -0
- mplang/v1/_device.py +602 -0
- mplang/{analysis → v1/analysis}/__init__.py +1 -1
- mplang/{analysis → v1/analysis}/diagram.py +5 -7
- mplang/v1/core/__init__.py +157 -0
- mplang/{core → v1/core}/cluster.py +30 -14
- mplang/{core → v1/core}/comm.py +5 -1
- mplang/{core → v1/core}/context_mgr.py +1 -1
- mplang/{core/dtype.py → v1/core/dtypes.py} +44 -2
- mplang/{core → v1/core}/expr/__init__.py +7 -7
- mplang/{core → v1/core}/expr/ast.py +13 -14
- mplang/{core → v1/core}/expr/evaluator.py +65 -24
- mplang/{core → v1/core}/expr/printer.py +24 -18
- mplang/{core → v1/core}/expr/transformer.py +3 -3
- mplang/{core → v1/core}/expr/utils.py +2 -2
- mplang/{core → v1/core}/expr/visitor.py +1 -1
- mplang/{core → v1/core}/expr/walk.py +1 -1
- mplang/{core → v1/core}/interp.py +6 -6
- mplang/{core → v1/core}/mpir.py +23 -16
- mplang/{core → v1/core}/mpobject.py +6 -6
- mplang/{core → v1/core}/mptype.py +13 -10
- mplang/{core → v1/core}/pfunc.py +4 -4
- mplang/{core → v1/core}/primitive.py +106 -201
- mplang/{core → v1/core}/table.py +36 -8
- mplang/{core → v1/core}/tensor.py +1 -1
- mplang/{core → v1/core}/tracer.py +9 -9
- mplang/{api.py → v1/host.py} +38 -6
- mplang/v1/kernels/__init__.py +41 -0
- mplang/{kernels → v1/kernels}/base.py +1 -1
- mplang/v1/kernels/basic.py +240 -0
- mplang/{kernels → v1/kernels}/context.py +42 -27
- mplang/{kernels → v1/kernels}/crypto.py +44 -37
- mplang/v1/kernels/fhe.py +858 -0
- mplang/{kernels → v1/kernels}/mock_tee.py +12 -13
- mplang/{kernels → v1/kernels}/phe.py +263 -57
- mplang/{kernels → v1/kernels}/spu.py +137 -48
- mplang/{kernels → v1/kernels}/sql_duckdb.py +12 -15
- mplang/{kernels → v1/kernels}/stablehlo.py +30 -23
- mplang/v1/kernels/value.py +626 -0
- mplang/{ops → v1/ops}/__init__.py +5 -16
- mplang/{ops → v1/ops}/base.py +2 -5
- mplang/{ops/builtin.py → v1/ops/basic.py} +34 -26
- mplang/v1/ops/crypto.py +262 -0
- mplang/v1/ops/fhe.py +272 -0
- mplang/{ops → v1/ops}/jax_cc.py +33 -68
- mplang/v1/ops/nnx_cc.py +168 -0
- mplang/{ops → v1/ops}/phe.py +16 -4
- mplang/{ops → v1/ops}/spu.py +3 -5
- mplang/v1/ops/sql_cc.py +303 -0
- mplang/{ops → v1/ops}/tee.py +9 -24
- mplang/{protos → v1/protos}/v1alpha1/mpir_pb2.pyi +71 -21
- mplang/v1/protos/v1alpha1/value_pb2.py +34 -0
- mplang/v1/protos/v1alpha1/value_pb2.pyi +169 -0
- mplang/{runtime → v1/runtime}/__init__.py +2 -2
- mplang/v1/runtime/channel.py +230 -0
- mplang/{runtime → v1/runtime}/cli.py +35 -20
- mplang/{runtime → v1/runtime}/client.py +19 -8
- mplang/{runtime → v1/runtime}/communicator.py +59 -15
- mplang/{runtime → v1/runtime}/data_providers.py +80 -19
- mplang/{runtime → v1/runtime}/driver.py +30 -12
- mplang/v1/runtime/link_comm.py +196 -0
- mplang/{runtime → v1/runtime}/server.py +58 -42
- mplang/{runtime → v1/runtime}/session.py +57 -71
- mplang/{runtime → v1/runtime}/simulation.py +55 -28
- mplang/v1/simp/api.py +353 -0
- mplang/{simp → v1/simp}/mpi.py +8 -9
- mplang/{simp/__init__.py → v1/simp/party.py} +19 -145
- mplang/{simp → v1/simp}/random.py +21 -22
- mplang/v1/simp/smpc.py +238 -0
- mplang/v1/utils/table_utils.py +185 -0
- mplang/v2/__init__.py +424 -0
- mplang/v2/backends/__init__.py +57 -0
- mplang/v2/backends/bfv_impl.py +705 -0
- mplang/v2/backends/channel.py +217 -0
- mplang/v2/backends/crypto_impl.py +723 -0
- mplang/v2/backends/field_impl.py +454 -0
- mplang/v2/backends/func_impl.py +107 -0
- mplang/v2/backends/phe_impl.py +148 -0
- mplang/v2/backends/simp_design.md +136 -0
- mplang/v2/backends/simp_driver/__init__.py +41 -0
- mplang/v2/backends/simp_driver/http.py +168 -0
- mplang/v2/backends/simp_driver/mem.py +280 -0
- mplang/v2/backends/simp_driver/ops.py +135 -0
- mplang/v2/backends/simp_driver/state.py +60 -0
- mplang/v2/backends/simp_driver/values.py +52 -0
- mplang/v2/backends/simp_worker/__init__.py +29 -0
- mplang/v2/backends/simp_worker/http.py +354 -0
- mplang/v2/backends/simp_worker/mem.py +102 -0
- mplang/v2/backends/simp_worker/ops.py +167 -0
- mplang/v2/backends/simp_worker/state.py +49 -0
- mplang/v2/backends/spu_impl.py +275 -0
- mplang/v2/backends/spu_state.py +187 -0
- mplang/v2/backends/store_impl.py +62 -0
- mplang/v2/backends/table_impl.py +838 -0
- mplang/v2/backends/tee_impl.py +215 -0
- mplang/v2/backends/tensor_impl.py +519 -0
- mplang/v2/cli.py +603 -0
- mplang/v2/cli_guide.md +122 -0
- mplang/v2/dialects/__init__.py +36 -0
- mplang/v2/dialects/bfv.py +665 -0
- mplang/v2/dialects/crypto.py +689 -0
- mplang/v2/dialects/dtypes.py +378 -0
- mplang/v2/dialects/field.py +210 -0
- mplang/v2/dialects/func.py +135 -0
- mplang/v2/dialects/phe.py +723 -0
- mplang/v2/dialects/simp.py +944 -0
- mplang/v2/dialects/spu.py +349 -0
- mplang/v2/dialects/store.py +63 -0
- mplang/v2/dialects/table.py +407 -0
- mplang/v2/dialects/tee.py +346 -0
- mplang/v2/dialects/tensor.py +1175 -0
- mplang/v2/edsl/README.md +279 -0
- mplang/v2/edsl/__init__.py +99 -0
- mplang/v2/edsl/context.py +311 -0
- mplang/v2/edsl/graph.py +463 -0
- mplang/v2/edsl/jit.py +62 -0
- mplang/v2/edsl/object.py +53 -0
- mplang/v2/edsl/primitive.py +284 -0
- mplang/v2/edsl/printer.py +119 -0
- mplang/v2/edsl/registry.py +207 -0
- mplang/v2/edsl/serde.py +375 -0
- mplang/v2/edsl/tracer.py +614 -0
- mplang/v2/edsl/typing.py +816 -0
- mplang/v2/kernels/Makefile +30 -0
- mplang/v2/kernels/__init__.py +23 -0
- mplang/v2/kernels/gf128.cpp +148 -0
- mplang/v2/kernels/ldpc.cpp +82 -0
- mplang/v2/kernels/okvs.cpp +283 -0
- mplang/v2/kernels/okvs_opt.cpp +291 -0
- mplang/v2/kernels/py_kernels.py +398 -0
- mplang/v2/libs/collective.py +330 -0
- mplang/v2/libs/device/__init__.py +51 -0
- mplang/v2/libs/device/api.py +813 -0
- mplang/v2/libs/device/cluster.py +352 -0
- mplang/v2/libs/ml/__init__.py +23 -0
- mplang/v2/libs/ml/sgb.py +1861 -0
- mplang/v2/libs/mpc/__init__.py +41 -0
- mplang/v2/libs/mpc/_utils.py +99 -0
- mplang/v2/libs/mpc/analytics/__init__.py +35 -0
- mplang/v2/libs/mpc/analytics/aggregation.py +372 -0
- mplang/v2/libs/mpc/analytics/groupby.md +99 -0
- mplang/v2/libs/mpc/analytics/groupby.py +331 -0
- mplang/v2/libs/mpc/analytics/permutation.py +386 -0
- mplang/v2/libs/mpc/common/constants.py +39 -0
- mplang/v2/libs/mpc/ot/__init__.py +32 -0
- mplang/v2/libs/mpc/ot/base.py +222 -0
- mplang/v2/libs/mpc/ot/extension.py +477 -0
- mplang/v2/libs/mpc/ot/silent.py +217 -0
- mplang/v2/libs/mpc/psi/__init__.py +40 -0
- mplang/v2/libs/mpc/psi/cuckoo.py +228 -0
- mplang/v2/libs/mpc/psi/okvs.py +49 -0
- mplang/v2/libs/mpc/psi/okvs_gct.py +79 -0
- mplang/v2/libs/mpc/psi/oprf.py +310 -0
- mplang/v2/libs/mpc/psi/rr22.py +344 -0
- mplang/v2/libs/mpc/psi/unbalanced.py +200 -0
- mplang/v2/libs/mpc/vole/__init__.py +31 -0
- mplang/v2/libs/mpc/vole/gilboa.py +327 -0
- mplang/v2/libs/mpc/vole/ldpc.py +383 -0
- mplang/v2/libs/mpc/vole/silver.py +336 -0
- mplang/v2/runtime/__init__.py +15 -0
- mplang/v2/runtime/dialect_state.py +41 -0
- mplang/v2/runtime/interpreter.py +871 -0
- mplang/v2/runtime/object_store.py +194 -0
- mplang/v2/runtime/value.py +141 -0
- {mplang_nightly-0.1.dev158.dist-info → mplang_nightly-0.1.dev268.dist-info}/METADATA +24 -17
- mplang_nightly-0.1.dev268.dist-info/RECORD +180 -0
- {mplang_nightly-0.1.dev158.dist-info → mplang_nightly-0.1.dev268.dist-info}/WHEEL +1 -1
- mplang/core/__init__.py +0 -92
- mplang/device.py +0 -340
- mplang/kernels/builtin.py +0 -207
- mplang/ops/crypto.py +0 -109
- mplang/ops/ibis_cc.py +0 -139
- mplang/ops/sql.py +0 -61
- mplang/protos/v1alpha1/mpir_pb2_grpc.py +0 -3
- mplang/runtime/link_comm.py +0 -131
- mplang/simp/smpc.py +0 -201
- mplang/utils/table_utils.py +0 -73
- mplang_nightly-0.1.dev158.dist-info/RECORD +0 -77
- /mplang/{core → v1/core}/mask.py +0 -0
- /mplang/{protos → v1/protos}/v1alpha1/mpir_pb2.py +0 -0
- /mplang/{runtime → v1/runtime}/exceptions.py +0 -0
- /mplang/{runtime → v1/runtime}/http_api.md +0 -0
- /mplang/{kernels → v1/simp}/__init__.py +0 -0
- /mplang/{utils → v1/utils}/__init__.py +0 -0
- /mplang/{utils → v1/utils}/crypto.py +0 -0
- /mplang/{utils → v1/utils}/func_utils.py +0 -0
- /mplang/{utils → v1/utils}/spu_utils.py +0 -0
- {mplang_nightly-0.1.dev158.dist-info → mplang_nightly-0.1.dev268.dist-info}/entry_points.txt +0 -0
- {mplang_nightly-0.1.dev158.dist-info → mplang_nightly-0.1.dev268.dist-info}/licenses/LICENSE +0 -0
mplang/v2/cli_guide.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# MPLang v2 CLI Workflow Guide
|
|
2
|
+
|
|
3
|
+
This document describes how to use the MPLang v2 Command Line Interface (CLI) to manage local clusters, submit jobs, and inspect runtime state. This workflow is designed for development and debugging.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
Ensure you have `mplang` installed in your environment.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
source .venv/bin/activate
|
|
11
|
+
# or
|
|
12
|
+
uv sync
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Workflow Overview
|
|
16
|
+
|
|
17
|
+
The recommended development workflow involves using two terminal windows:
|
|
18
|
+
1. **Terminal 1**: Runs the cluster (servers).
|
|
19
|
+
2. **Terminal 2**: Submits jobs and queries cluster status.
|
|
20
|
+
|
|
21
|
+
## Step-by-Step Guide
|
|
22
|
+
|
|
23
|
+
### 1. Generate Cluster Configuration
|
|
24
|
+
|
|
25
|
+
First, generate a `cluster.yaml` file. This defines the topology of your MPLang cluster.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Generate a config for 2 workers starting at port 8100
|
|
29
|
+
python -m mplang.v2.cli config gen -w 2 -p 8100 -o cluster.yaml
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2. Start the Cluster (Terminal 1)
|
|
33
|
+
|
|
34
|
+
In your **first terminal**, start the cluster using the `up` command. This will start the worker processes defined in your config.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Terminal 1
|
|
38
|
+
python -m mplang.v2.cli up -c cluster.yaml
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
You should see logs indicating that workers have started (e.g., `[Worker 0] INFO: Started server process...`). Keep this terminal open.
|
|
42
|
+
|
|
43
|
+
### 3. Prepare a Job Script
|
|
44
|
+
|
|
45
|
+
Create a Python script (e.g., `my_job.py`) that defines the computation you want to run.
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
# my_job.py
|
|
49
|
+
from mplang.v2.dialects import simp
|
|
50
|
+
import numpy as np
|
|
51
|
+
|
|
52
|
+
def main():
|
|
53
|
+
print("Starting job...")
|
|
54
|
+
|
|
55
|
+
# Create data on Party 0
|
|
56
|
+
x = simp.constant((0,), np.array([1, 2, 3]))
|
|
57
|
+
|
|
58
|
+
# Shuffle data to Party 1
|
|
59
|
+
y = simp.shuffle_static(x, {1: 0})
|
|
60
|
+
|
|
61
|
+
print("Computation graph constructed.")
|
|
62
|
+
return y
|
|
63
|
+
|
|
64
|
+
if __name__ == "__main__":
|
|
65
|
+
main()
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 4. Submit the Job (Terminal 2)
|
|
69
|
+
|
|
70
|
+
In your **second terminal**, use the `run` command to submit the script to the running cluster.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Terminal 2
|
|
74
|
+
python -m mplang.v2.cli run -c cluster.yaml -f my_job.py
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The CLI will connect to the driver, which orchestrates the execution across the workers.
|
|
78
|
+
|
|
79
|
+
### 5. Check Cluster Status
|
|
80
|
+
|
|
81
|
+
You can check the health and latency of your workers at any time.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Terminal 2
|
|
85
|
+
python -m mplang.v2.cli status -c cluster.yaml
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Output Example:**
|
|
89
|
+
```text
|
|
90
|
+
Rank | Endpoint | Status | Response Time
|
|
91
|
+
--------------------------------------------------------------------------------
|
|
92
|
+
0 | http://127.0.0.1:8100 | OK | 0.002s
|
|
93
|
+
1 | http://127.0.0.1:8101 | OK | 0.003s
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 6. Inspect Runtime Objects (Symbols)
|
|
97
|
+
|
|
98
|
+
To debug or verify intermediate results, you can list the objects currently stored in the memory of each worker.
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Terminal 2
|
|
102
|
+
python -m mplang.v2.cli objects -c cluster.yaml
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Output Example:**
|
|
106
|
+
```text
|
|
107
|
+
Rank | Endpoint | Count | Objects
|
|
108
|
+
--------------------------------------------------------------------------------
|
|
109
|
+
0 | http://127.0.0.1:8100 | 1 | 7f8b... (x)
|
|
110
|
+
1 | http://127.0.0.1:8101 | 1 | 3a2c... (y)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Command Reference
|
|
114
|
+
|
|
115
|
+
| Command | Description | Usage |
|
|
116
|
+
| :--- | :--- | :--- |
|
|
117
|
+
| `config gen` | Generate cluster config file | `python -m mplang.v2.cli config gen -w <workers> -o <file>` |
|
|
118
|
+
| `up` | Start all workers locally | `python -m mplang.v2.cli up -c <config>` |
|
|
119
|
+
| `run` | Submit a job script | `python -m mplang.v2.cli run -c <config> -f <script>` |
|
|
120
|
+
| `status` | Check worker health | `python -m mplang.v2.cli status -c <config>` |
|
|
121
|
+
| `objects` | List objects on workers | `python -m mplang.v2.cli objects -c <config>` |
|
|
122
|
+
| `worker` | Start a single worker (prod) | `python -m mplang.v2.cli worker --rank <id> -c <config>` |
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright 2025 Ant Group Co., Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
Serde registration for MPLang dialects.
|
|
17
|
+
|
|
18
|
+
This module ensures all dialect types are registered with the serde system.
|
|
19
|
+
Each dialect module (bfv, crypto, tee, spu) now registers its own types
|
|
20
|
+
inline with the class definitions.
|
|
21
|
+
|
|
22
|
+
This module imports all dialects to trigger their registrations, ensuring
|
|
23
|
+
types are available for serialization/deserialization.
|
|
24
|
+
|
|
25
|
+
Import this module after edsl.graph to ensure base types are registered first.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from __future__ import annotations
|
|
29
|
+
|
|
30
|
+
# Import dialects to trigger their type registrations
|
|
31
|
+
# Each dialect module registers its types at import time via _register_*_types()
|
|
32
|
+
from mplang.v2.dialects import bfv as _bfv # noqa: F401
|
|
33
|
+
from mplang.v2.dialects import crypto as _crypto # noqa: F401
|
|
34
|
+
from mplang.v2.dialects import spu as _spu # noqa: F401
|
|
35
|
+
from mplang.v2.dialects import store as _store # noqa: F401
|
|
36
|
+
from mplang.v2.dialects import tee as _tee # noqa: F401
|