mplang-nightly 0.1.dev331__py3-none-any.whl → 0.1.dev332__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.
@@ -51,10 +51,11 @@ class SPUState(DialectState):
51
51
  def __init__(self, infra: WorkerInfra | None = None) -> None:
52
52
  # Optional shared infrastructure (for per-request isolation via link.spawn)
53
53
  self._infra = infra
54
- # Key: (local_rank, world_size, protocol, field, link_mode)
54
+ # Key: (local_rank, world_size, protocol, field, link_mode, spu_endpoints)
55
55
  # Value: (Runtime, Io)
56
56
  self._runtimes: dict[
57
- tuple[int, int, str, str, str], tuple[spu_api.Runtime, spu_api.Io]
57
+ tuple[int, int, str, str, str, tuple[str, ...] | None],
58
+ tuple[spu_api.Runtime, spu_api.Io],
58
59
  ] = {}
59
60
  # Local template link cache (used when no WorkerInfra is provided)
60
61
  self._template_links: dict[tuple, libspu.link.Context] = {}
@@ -75,14 +76,14 @@ class SPUState(DialectState):
75
76
  """
76
77
 
77
78
  def _create() -> libspu.link.Context:
78
- if communicator is not None:
79
+ if spu_endpoints:
80
+ return self._create_brpc_link(local_rank, spu_endpoints)
81
+ elif communicator is not None:
79
82
  if parties is None:
80
83
  raise ValueError("parties required when using communicator")
81
84
  return self._create_channels_link(
82
85
  local_rank, spu_world_size, communicator, parties
83
86
  )
84
- elif spu_endpoints:
85
- return self._create_brpc_link(local_rank, spu_endpoints)
86
87
  else:
87
88
  return self._create_mem_link(local_rank, spu_world_size)
88
89
 
@@ -104,13 +105,18 @@ class SPUState(DialectState):
104
105
  ) -> tuple[spu_api.Runtime, spu_api.Io]:
105
106
  """Get or create SPU Runtime and Io for the given configuration.
106
107
 
108
+ Link mode priority: spu_endpoints (BRPC) > communicator (Channels) > mem.
109
+ When ``spu_endpoints`` is provided it always takes precedence, even if
110
+ a ``communicator`` is also supplied.
111
+
107
112
  Args:
108
113
  local_rank: The local rank within the SPU device (0-indexed).
109
114
  spu_world_size: The number of parties in the SPU device.
110
115
  config: SPU configuration including protocol settings.
111
- spu_endpoints: Optional list of BRPC endpoints. If None, use mem link.
116
+ spu_endpoints: Optional list of BRPC endpoints. Takes highest
117
+ priority when provided.
112
118
  communicator: Optional v2 communicator (ThreadCommunicator/HttpCommunicator).
113
- If provided, use Channels mode to reuse existing communication.
119
+ Used only when ``spu_endpoints`` is not provided.
114
120
  parties: Optional list of global ranks for SPU parties.
115
121
  Required when communicator is provided.
116
122
 
@@ -120,10 +126,10 @@ class SPUState(DialectState):
120
126
  from mplang.backends.spu_impl import to_runtime_config
121
127
 
122
128
  # Determine link mode
123
- if communicator is not None:
124
- link_mode = "channels"
125
- elif spu_endpoints:
129
+ if spu_endpoints:
126
130
  link_mode = "brpc"
131
+ elif communicator is not None:
132
+ link_mode = "channels"
127
133
  else:
128
134
  link_mode = "mem"
129
135
 
@@ -133,6 +139,7 @@ class SPUState(DialectState):
133
139
  config.protocol,
134
140
  config.field,
135
141
  link_mode,
142
+ tuple(spu_endpoints) if spu_endpoints else None,
136
143
  )
137
144
 
138
145
  if cache_key in self._runtimes:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mplang-nightly
3
- Version: 0.1.dev331
3
+ Version: 0.1.dev332
4
4
  Summary: Multi-Party Programming Language
5
5
  Author-email: SecretFlow Team <secretflow-contact@service.alipay.com>
6
6
  License: Apache License
@@ -11,7 +11,7 @@ mplang/backends/func_impl.py,sha256=vhkSJnvgSzvQWXqOE40O8npqOmtNqLxefzv9ETuQODQ,
11
11
  mplang/backends/phe_impl.py,sha256=CefRpFrRJvbZm3X58OYOFAyNZXKDp081Q6CT8fhdreE,4118
12
12
  mplang/backends/simp_design.md,sha256=u4YeDLKk5avsueXhzPtt4OUBToBmurOVK_BWTKTJ7w0,5246
13
13
  mplang/backends/spu_impl.py,sha256=73JTdIFqWoKgVM5jR1lJm_PODlgb9BrQUwLSDcGWi20,11876
14
- mplang/backends/spu_state.py,sha256=kcXr2ITDsR0sT1RSXbUKGeI8yfNEQ9NPonv-9fiOik4,8315
14
+ mplang/backends/spu_state.py,sha256=XKquhcAND8afEUzzfJ3VFb1wQ3ptFuPptStxHt20JpA,8652
15
15
  mplang/backends/store_impl.py,sha256=IeoMxt9Ma21aYv-dKgF7COinvO6uc09aw5gGTp-5Ctg,1599
16
16
  mplang/backends/table_impl.py,sha256=g3fjXOdHUoEEE1w330C5n5FwKcM26cQSo0jPgxNQFsE,30104
17
17
  mplang/backends/tee_impl.py,sha256=5yed94Lr55hgSDT6j3FjdTboqzhl4HpJ9lGk1YGZBXQ,7026
@@ -111,8 +111,8 @@ mplang/tool/program.py,sha256=W3H8bpPirnoJ4ZrmyPYuMCPadJis20o__n_1MKqCsWU,11058
111
111
  mplang/utils/__init__.py,sha256=Hwrwti2nfPxWUXV8DN6T1QaqXH_Jsd27k8UMSdBGUns,1073
112
112
  mplang/utils/func_utils.py,sha256=Jdn_60jN3jcSE_oAqSMTLQjiE8CLyPpY-H1HmPIL5mw,5354
113
113
  mplang/utils/logging.py,sha256=9dMhwprVbx1WMGJrgoQbWmV50vyYuLU4NSPnetcl1Go,7237
114
- mplang_nightly-0.1.dev331.dist-info/METADATA,sha256=V7wLzFvw9Ke1EY_D2XYglJx1FGqbZL1Jzm9ld-IqkT8,16783
115
- mplang_nightly-0.1.dev331.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
116
- mplang_nightly-0.1.dev331.dist-info/entry_points.txt,sha256=mG1oJT-GAjQR834a62_QIWb7litzWPPyVnwFqm-rWuY,55
117
- mplang_nightly-0.1.dev331.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
118
- mplang_nightly-0.1.dev331.dist-info/RECORD,,
114
+ mplang_nightly-0.1.dev332.dist-info/METADATA,sha256=H4LyHhbLgPXLlYVKdf1sNzDai9gAqU_JMw20NA92NEo,16783
115
+ mplang_nightly-0.1.dev332.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
116
+ mplang_nightly-0.1.dev332.dist-info/entry_points.txt,sha256=mG1oJT-GAjQR834a62_QIWb7litzWPPyVnwFqm-rWuY,55
117
+ mplang_nightly-0.1.dev332.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
118
+ mplang_nightly-0.1.dev332.dist-info/RECORD,,