mplang-nightly 0.1.dev280__py3-none-any.whl → 0.1.dev282__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.
@@ -36,7 +36,9 @@ class CommunicatorProtocol(Protocol):
36
36
  Both ThreadCommunicator and HttpCommunicator implement this interface.
37
37
  """
38
38
 
39
- def send(self, to: int, key: str, data: bytes) -> None: ...
39
+ def send(
40
+ self, to: int, key: str, data: bytes, *, is_raw_bytes: bool = False
41
+ ) -> None: ...
40
42
  def recv(self, frm: int, key: str) -> bytes: ...
41
43
 
42
44
 
@@ -111,9 +113,8 @@ class BaseChannel(libspu.link.IChannel):
111
113
  len(data),
112
114
  )
113
115
 
114
- # Send raw bytes directly
115
- # v2 communicators accept Any, bytes is valid
116
- self._comm.send(self._peer_rank, key, data)
116
+ # Send raw bytes directly.
117
+ self._comm.send(self._peer_rank, key, data, is_raw_bytes=True)
117
118
 
118
119
  def Recv(self, tag: str) -> bytes:
119
120
  """Receive bytes from peer (blocking).
@@ -91,27 +91,37 @@ class HttpCommunicator:
91
91
  self._pending_sends: list[concurrent.futures.Future[None]] = []
92
92
  self.client = httpx.Client(timeout=None)
93
93
 
94
- def send(self, to: int, key: str, data: Any) -> None:
95
- """Send data to another rank asynchronously."""
96
- future = self._send_executor.submit(self._do_send, to, key, data)
94
+ def send(self, to: int, key: str, data: Any, *, is_raw_bytes: bool = False) -> None:
95
+ """Send data to another rank asynchronously.
96
+
97
+ Args:
98
+ to: Target rank.
99
+ key: Message key.
100
+ data: Payload.
101
+ is_raw_bytes: If True, treat `data` as raw bytes and transmit as
102
+ base64-encoded bytes (no serde). If False, the transport may still
103
+ treat `bytes` payloads as raw bytes.
104
+ """
105
+ future = self._send_executor.submit(self._do_send, to, key, data, is_raw_bytes)
97
106
  self._pending_sends.append(future)
98
107
 
99
- def _do_send(self, to: int, key: str, data: Any) -> None:
108
+ def _do_send(self, to: int, key: str, data: Any, is_raw_bytes: bool) -> None:
100
109
  """Perform the HTTP send."""
101
110
  url = f"{self.endpoints[to]}/comm/{key}"
102
111
  logger.debug(f"Rank {self.rank} sending to {to} key={key}, url={url}")
103
112
 
104
- # Detect SPU channel (tag prefix "spu:") and handle bytes
105
- if key.startswith("spu:") and isinstance(data, bytes):
106
- # Send raw bytes for SPU channels
113
+ # Raw-bytes transport rule:
114
+ # - If caller explicitly marks raw bytes, always use raw path.
115
+ # - Otherwise, if payload is `bytes`, use raw path.
116
+ # This avoids coupling encoding format to key naming conventions.
117
+ send_raw_bytes = is_raw_bytes or isinstance(data, bytes)
118
+
119
+ if send_raw_bytes:
107
120
  import base64
108
121
 
109
122
  payload = base64.b64encode(data).decode("ascii")
110
- is_raw_bytes = True
111
123
  else:
112
- # Use secure JSON serialization
113
124
  payload = serde.dumps_b64(data)
114
- is_raw_bytes = False
115
125
 
116
126
  size_bytes = len(payload)
117
127
 
@@ -132,7 +142,7 @@ class HttpCommunicator:
132
142
  json={
133
143
  "data": payload,
134
144
  "from_rank": self.rank,
135
- "is_raw_bytes": is_raw_bytes,
145
+ "is_raw_bytes": send_raw_bytes,
136
146
  },
137
147
  )
138
148
  resp.raise_for_status()
@@ -50,7 +50,7 @@ class ThreadCommunicator:
50
50
  self._shutdown = True
51
51
  self._cond.notify_all()
52
52
 
53
- def send(self, to: int, key: str, data: Any) -> None:
53
+ def send(self, to: int, key: str, data: Any, *, is_raw_bytes: bool = False) -> None:
54
54
  assert 0 <= to < self.world_size
55
55
  if self.use_serde:
56
56
  from mplang.edsl import serde
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mplang-nightly
3
- Version: 0.1.dev280
3
+ Version: 0.1.dev282
4
4
  Summary: Multi-Party Programming Language
5
5
  Author-email: SecretFlow Team <secretflow-contact@service.alipay.com>
6
6
  License: Apache License
@@ -4,7 +4,7 @@ mplang/cli_guide.md,sha256=hKC6AKgJn-lM_wZ0CzZIP2QUBxGPnT0Op_1YyeUhCfI,3581
4
4
  mplang/py.typed,sha256=RyhZV7Yxo8BvEoBiFz5fH3IWVqQKTcBBE-bzjx_N5GQ,583
5
5
  mplang/backends/__init__.py,sha256=EnKHmOX4YgvNVA42k_KfiS-Vn860yN7Rj9XkUU0g9ys,2042
6
6
  mplang/backends/bfv_impl.py,sha256=qobGXe7ldWvYVcqdkNsTcVdNV-hUVE9-Ks5pd3X0Mvc,25691
7
- mplang/backends/channel.py,sha256=MZwaF0DkkBF_98xdQ8ri0kROJmnCS1ldbwdZUi-sWAU,6876
7
+ mplang/backends/channel.py,sha256=S6LwfyS0H_17gv46ZqSrZirKTB_CCIFVbNTGuY1YIfc,6887
8
8
  mplang/backends/crypto_impl.py,sha256=m5tbZpedn4McG5t6HIaEjhTQUFOIaEDMdyEG0499S0Y,23187
9
9
  mplang/backends/field_impl.py,sha256=lIghppy0i8QL7aTNCr8tNWjC_bvOXBIKLnavaO0fIOA,14773
10
10
  mplang/backends/func_impl.py,sha256=vhkSJnvgSzvQWXqOE40O8npqOmtNqLxefzv9ETuQODQ,3573
@@ -23,8 +23,8 @@ mplang/backends/simp_driver/ops.py,sha256=WYObWDRCsiXH0UBWZX5vD5W98ZPkd88U_qBV8S
23
23
  mplang/backends/simp_driver/state.py,sha256=dNmYMFN2D2BBdgs6C0YLaHrfaBRMgs05UNxMWw6tZIs,1713
24
24
  mplang/backends/simp_driver/values.py,sha256=Lz1utNSIzH-dCzZAEjU6JRcxPsfKGfUJrYl6gIuMOGw,1509
25
25
  mplang/backends/simp_worker/__init__.py,sha256=gdrSY1-MDkupCoJ8xwwH7em7fgVWv3J4gBJ45uHdzgg,961
26
- mplang/backends/simp_worker/http.py,sha256=y5qpDpfM6vKBsicr2wCkgn-RHnED-b5J0r9hBJxrgN8,12746
27
- mplang/backends/simp_worker/mem.py,sha256=tMGiRppeca0TnY8WdqYQMQvsx5UVswCqdeOhiDlLQBs,3574
26
+ mplang/backends/simp_worker/http.py,sha256=UiqXKcH5DZG_eTXcW7qDSjIsBWtA37tkqBEowJJ0hQE,13186
27
+ mplang/backends/simp_worker/mem.py,sha256=hLJftzSMQIw64vjBdrSrFReFzWS6rlzf-0Q7SWkfhak,3605
28
28
  mplang/backends/simp_worker/ops.py,sha256=ntxfkD4e6Il4w7FshK1ODcUCUPMlipt33pDY_x5iC0U,5661
29
29
  mplang/backends/simp_worker/state.py,sha256=nIu0ybvdYqRqp0TkoSneUF2u31evDHucCRduVBaDals,1445
30
30
  mplang/dialects/__init__.py,sha256=CYMmkeQVU0Znr9n3_5clZKb16u7acJ5jl5Zjbx4Tn1U,1478
@@ -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.dev280.dist-info/METADATA,sha256=IG4D8STIc2G7ZtQAz3OlKptLansk_hvB03-2M2HNZCw,16783
103
- mplang_nightly-0.1.dev280.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
104
- mplang_nightly-0.1.dev280.dist-info/entry_points.txt,sha256=mG1oJT-GAjQR834a62_QIWb7litzWPPyVnwFqm-rWuY,55
105
- mplang_nightly-0.1.dev280.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
106
- mplang_nightly-0.1.dev280.dist-info/RECORD,,
102
+ mplang_nightly-0.1.dev282.dist-info/METADATA,sha256=IIsT9I92EC_kGSg_4EjX7skV9oHzfwCDpDg6PuLwaEo,16783
103
+ mplang_nightly-0.1.dev282.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
104
+ mplang_nightly-0.1.dev282.dist-info/entry_points.txt,sha256=mG1oJT-GAjQR834a62_QIWb7litzWPPyVnwFqm-rWuY,55
105
+ mplang_nightly-0.1.dev282.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
106
+ mplang_nightly-0.1.dev282.dist-info/RECORD,,