mplang-nightly 0.1.dev285__py3-none-any.whl → 0.1.dev286__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/edsl/typing.py +25 -9
- {mplang_nightly-0.1.dev285.dist-info → mplang_nightly-0.1.dev286.dist-info}/METADATA +1 -1
- {mplang_nightly-0.1.dev285.dist-info → mplang_nightly-0.1.dev286.dist-info}/RECORD +6 -6
- {mplang_nightly-0.1.dev285.dist-info → mplang_nightly-0.1.dev286.dist-info}/WHEEL +0 -0
- {mplang_nightly-0.1.dev285.dist-info → mplang_nightly-0.1.dev286.dist-info}/entry_points.txt +0 -0
- {mplang_nightly-0.1.dev285.dist-info → mplang_nightly-0.1.dev286.dist-info}/licenses/LICENSE +0 -0
mplang/edsl/typing.py
CHANGED
|
@@ -82,11 +82,18 @@ underlying HE libraries.
|
|
|
82
82
|
- **Core Type**: `Tensor[Scalar, ...]`
|
|
83
83
|
- **API Standard**: Follows NumPy/JAX conventions. All layout and arithmetic operations are valid.
|
|
84
84
|
|
|
85
|
+
- **World 2: The Element-wise HE World**
|
|
85
86
|
- **Core Type**: `Tensor[EncryptedScalar, ...]` (e.g., `Tensor[phe.CiphertextType, ...]`)
|
|
86
87
|
- **API Standard**: Follows TenSEAL-like (Tensor-level) conventions. Layout operations
|
|
87
88
|
(`transpose`, `reshape`) are valid as they merely shuffle independent ciphertext objects.
|
|
88
89
|
Arithmetic operations are overloaded for element-wise HE computation.
|
|
89
90
|
|
|
91
|
+
- **World 3: The SIMD HE World**
|
|
92
|
+
- **Core Type**: `Tensor[Vector[...], ...]` where the inner `Vector` holds SIMD-encrypted slots
|
|
93
|
+
- **API Standard**: SIMD-HE specific (e.g., BFV/CKKS). Only specific operations are supported
|
|
94
|
+
due to the batched nature of SIMD encryption. Layout operations must account for slot packing,
|
|
95
|
+
and arithmetic operates on batched ciphertexts with slot-wise semantics.
|
|
96
|
+
|
|
90
97
|
===========================
|
|
91
98
|
Principle 3: Contracts via Protocols
|
|
92
99
|
===========================
|
|
@@ -137,7 +144,15 @@ class BaseType:
|
|
|
137
144
|
"""Base class for all MPLang types."""
|
|
138
145
|
|
|
139
146
|
def __repr__(self) -> str:
|
|
140
|
-
|
|
147
|
+
# Prevent infinite recursion: only call __str__ if it's overridden
|
|
148
|
+
if type(self).__str__ is not BaseType.__str__:
|
|
149
|
+
return str(self)
|
|
150
|
+
# Fallback to default object repr if __str__ not implemented
|
|
151
|
+
return object.__repr__(self)
|
|
152
|
+
|
|
153
|
+
def __str__(self) -> str:
|
|
154
|
+
# Default implementation for subclasses that don't override
|
|
155
|
+
return f"{self.__class__.__name__}()"
|
|
141
156
|
|
|
142
157
|
|
|
143
158
|
# ==============================================================================
|
|
@@ -175,11 +190,11 @@ class ScalarType(BaseType):
|
|
|
175
190
|
|
|
176
191
|
@serde.register_class
|
|
177
192
|
class IntegerType(ScalarType):
|
|
178
|
-
"""Represents a
|
|
193
|
+
"""Represents a fixed-width integer type with configurable bitwidth.
|
|
179
194
|
|
|
180
|
-
This is a standard integer type with
|
|
181
|
-
arbitrary-precision arithmetic.
|
|
182
|
-
the range of
|
|
195
|
+
This is a standard integer type with parameterized bit width, used for
|
|
196
|
+
arbitrary-precision arithmetic. By configuring larger bitwidths (e.g., 128, 256),
|
|
197
|
+
this type can represent integers that exceed the range of standard types like i64.
|
|
183
198
|
|
|
184
199
|
Examples:
|
|
185
200
|
>>> i128 = IntegerType(bitwidth=128, signed=True) # i128
|
|
@@ -229,15 +244,16 @@ class IntegerType(ScalarType):
|
|
|
229
244
|
|
|
230
245
|
@serde.register_class
|
|
231
246
|
class FloatType(ScalarType):
|
|
232
|
-
"""Represents a floating-point type.
|
|
247
|
+
"""Represents a fixed-width floating-point type with configurable bitwidth.
|
|
233
248
|
|
|
234
|
-
This supports standard IEEE 754 floating-point types with
|
|
235
|
-
precision
|
|
249
|
+
This supports standard IEEE 754 floating-point types with parameterized
|
|
250
|
+
bit width for different precision requirements.
|
|
236
251
|
|
|
237
252
|
Examples:
|
|
238
253
|
>>> f16 = FloatType(bitwidth=16) # half precision
|
|
239
254
|
>>> f32 = FloatType(bitwidth=32) # single precision
|
|
240
255
|
>>> f64 = FloatType(bitwidth=64) # double precision
|
|
256
|
+
>>> f128 = FloatType(bitwidth=128) # quadruple precision
|
|
241
257
|
"""
|
|
242
258
|
|
|
243
259
|
def __init__(self, *, bitwidth: int = 32):
|
|
@@ -245,7 +261,7 @@ class FloatType(ScalarType):
|
|
|
245
261
|
|
|
246
262
|
Args:
|
|
247
263
|
bitwidth: Number of bits for the float representation.
|
|
248
|
-
Standard values: 16 (half), 32 (single), 64 (double).
|
|
264
|
+
Standard values: 16 (half), 32 (single), 64 (double), 128 (quadruple).
|
|
249
265
|
"""
|
|
250
266
|
if bitwidth not in (16, 32, 64, 128):
|
|
251
267
|
raise ValueError(f"bitwidth must be 16, 32, 64, or 128, got {bitwidth}")
|
|
@@ -52,7 +52,7 @@ mplang/edsl/program.py,sha256=_JdEU2-nb79VlFLcgMJf4JS30TARBeUIzno0y0SFVsg,4467
|
|
|
52
52
|
mplang/edsl/registry.py,sha256=hudXZPUrUUueEwgksDKN0cnE3iiXucuTaDdDK8uSPmk,6822
|
|
53
53
|
mplang/edsl/serde.py,sha256=8K94laE8ObeGuBoF6m7g3A-xEe98EvqQ_6ZPPspddAY,11641
|
|
54
54
|
mplang/edsl/tracer.py,sha256=WQFNL2ZgXSLjxD4JA7cXIDUKIQXe3aZ94qer57IKPXc,23128
|
|
55
|
-
mplang/edsl/typing.py,sha256=
|
|
55
|
+
mplang/edsl/typing.py,sha256=23DjgISpJO7ofG1qZeWFJ8hl6Au_OLw4qlgWSOuujh4,30352
|
|
56
56
|
mplang/kernels/Makefile,sha256=5PoPpajcb_8ByPGNHzVytmovXUwkjJs_K8MbXX9qDYs,1033
|
|
57
57
|
mplang/kernels/__init__.py,sha256=J_rDl9lAXd7QL3Nt_P3YX6j9yge7ssguSaHuafPZNKE,876
|
|
58
58
|
mplang/kernels/gf128.cpp,sha256=WIvCr3MijzwJxMi1Wnfhm8aWT8oL0fia6FeyTmFJtPQ,5975
|
|
@@ -99,8 +99,8 @@ mplang/tool/program.py,sha256=W3H8bpPirnoJ4ZrmyPYuMCPadJis20o__n_1MKqCsWU,11058
|
|
|
99
99
|
mplang/utils/__init__.py,sha256=Hwrwti2nfPxWUXV8DN6T1QaqXH_Jsd27k8UMSdBGUns,1073
|
|
100
100
|
mplang/utils/func_utils.py,sha256=aZ-X43w8JKJgiF-IUMS0G7QqrNeoTM5ZPzRNd-tKxpw,5180
|
|
101
101
|
mplang/utils/logging.py,sha256=9dMhwprVbx1WMGJrgoQbWmV50vyYuLU4NSPnetcl1Go,7237
|
|
102
|
-
mplang_nightly-0.1.
|
|
103
|
-
mplang_nightly-0.1.
|
|
104
|
-
mplang_nightly-0.1.
|
|
105
|
-
mplang_nightly-0.1.
|
|
106
|
-
mplang_nightly-0.1.
|
|
102
|
+
mplang_nightly-0.1.dev286.dist-info/METADATA,sha256=jhn3cljBrdSLTIGeIfxXbCGXrjXj9Jw7Oq83HGpo9y0,16783
|
|
103
|
+
mplang_nightly-0.1.dev286.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
104
|
+
mplang_nightly-0.1.dev286.dist-info/entry_points.txt,sha256=mG1oJT-GAjQR834a62_QIWb7litzWPPyVnwFqm-rWuY,55
|
|
105
|
+
mplang_nightly-0.1.dev286.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
106
|
+
mplang_nightly-0.1.dev286.dist-info/RECORD,,
|
|
File without changes
|
{mplang_nightly-0.1.dev285.dist-info → mplang_nightly-0.1.dev286.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{mplang_nightly-0.1.dev285.dist-info → mplang_nightly-0.1.dev286.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|