sia-script 0.8.2__tar.gz → 0.8.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sia-script
3
- Version: 0.8.2
3
+ Version: 0.8.4
4
4
  Summary: SIA — Simplified Integrated Architecture: SiaNTT, SIA-ELS (ABAP interpreter), the HDQS server client, and hdqs_engine (offline statevector quantum simulator — no server or API token required)
5
5
  Author-email: Sia Software Innovations Private Limited <info@siasoftwareinnovations.com>
6
6
  License: # PROPRIETARY SOFTWARE LICENSE
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sia-script"
7
- version = "0.8.2"
7
+ version = "0.8.4"
8
8
  description = "SIA — Simplified Integrated Architecture: SiaNTT, SIA-ELS (ABAP interpreter), the HDQS server client, and hdqs_engine (offline statevector quantum simulator — no server or API token required)"
9
9
  authors = [
10
10
  { name = "Sia Software Innovations Private Limited", email = "info@siasoftwareinnovations.com" }
@@ -11,12 +11,16 @@ Client-side package. Loads:
11
11
  Pure Python, no deps. (proprietary)
12
12
  4. hdqs_engine — offline quantum simulator: statevector/density matrix,
13
13
  GPU acceleration via PyTorch, advanced noise channels,
14
- canonical algorithms (Deutsch, Grover, Shor-adjacent primitives,
15
- VQE, QAOA, ...) and QKD protocols (BB84, E91, QSS).
14
+ canonical algorithms (Deutsch, Deutsch-Jozsa,
15
+ Bernstein-Vazirani, Grover, Simon, QFT, teleportation,
16
+ superdense coding, VQE, QAOA) and QKD protocols
17
+ (BB84, E91, QSS). Note: the QFT is a building block of
18
+ Shor's algorithm, but no factoring routine is implemented.
16
19
  Runs entirely locally — no server, no API token, no network call.
17
20
  Requires NumPy; PyTorch optional for GPU acceleration.
18
- MIT-licensed (see sia/hdqs_engine/LICENSE), distinct from the
19
- proprietary license covering the rest of this package.
21
+ MIT-licensed (see the MIT_LICENSE string in sia/hdqs_engine.py),
22
+ distinct from the proprietary license covering the rest of
23
+ this package.
20
24
 
21
25
  Note: the proprietary HDQS server internals (qbt, vqram — the simulator core
22
26
  and hyper-dimensional virtual memory that the server runs) are NOT part of
@@ -24,8 +28,12 @@ this client package. They live in the server deployment only. What you get
24
28
  here for local, offline quantum simulation is sia.hdqs_engine.
25
29
  """
26
30
 
27
- __version__ = "0.8.0"
31
+ __version__ = "0.8.1"
28
32
  __author__ = "Sia Software Innovations Private Limited"
33
+ # NOTE: hardcoding a bare IP couples every released client to one host. If
34
+ # the server ever moves, every installed copy breaks. Prefer a DNS name
35
+ # (e.g. "hdqs.siasoftwareinnovations.com") and allow an environment override:
36
+ # __server_ip__ = os.environ.get("SIA_HDQS_HOST", "hdqs.siasoftwareinnovations.com")
29
37
  __server_ip__ = "31.97.239.213"
30
38
  __server_port__ = 8000
31
39
  __default_url__ = f"http://{__server_ip__}:{__server_port__}"
@@ -71,7 +79,9 @@ RuntimeEnv = None
71
79
  run_file = None
72
80
  extract_sia_block = None
73
81
  TypedVariable = None
74
- RuntimeError = None
82
+ # NOTE: do NOT bind the name `RuntimeError` at module scope — inside this
83
+ # module it would shadow the builtin for every subsequent `raise`/`except`.
84
+ # The legacy alias is served by __getattr__ at the bottom of this file.
75
85
  SystemVariables = None
76
86
  SelectionOption = None
77
87
 
@@ -106,7 +116,6 @@ try:
106
116
  run_file = None # no file-based runner in v5; use els_run(open(...).read())
107
117
  extract_sia_block = None # internal detail, not re-exported
108
118
  TypedVariable = None # removed in v5 refactor
109
- RuntimeError = None # no longer shadows built-in
110
119
  SystemVariables = None # internal, not public
111
120
  SelectionOption = None # internal, not public
112
121
 
@@ -135,10 +144,16 @@ except ImportError:
135
144
  # sia/hdqs_engine.py), distinct from the proprietary license covering
136
145
  # the rest of sia-script.
137
146
  #
138
- # UPDATED v0.3.0: Now includes:
147
+ # UPDATED for hdqs_engine v0.4.0 — correctness rewrite validated against
148
+ # Qiskit quantum_info and Qiskit Aer. Breaking changes vs v0.3.0:
149
+ # * use_gpu now defaults to 'auto' (CUDA when present, else NumPy).
150
+ # * readout_error(q, p0_to_1, p1_to_0) is a CLASSICAL confusion matrix
151
+ # applied at measure()/sample(); it no longer alters the state.
152
+ # * Non-CPTP Kraus sets now raise instead of being renormalized.
153
+ # Includes:
139
154
  # - HDQS class (renamed from StatevectorEngine for cleaner API)
140
155
  # - Density matrix support (off by default, enable with use_density_matrix=True)
141
- # - GPU acceleration via PyTorch (enable with use_gpu=True)
156
+ # - Automatic GPU acceleration via PyTorch (use_gpu='auto' by default)
142
157
  # - Advanced noise channels:
143
158
  # * Basic: bit_flip, phase_flip, depolarizing, amplitude_damping, phase_damping
144
159
  # * Advanced: thermal, coherent, amplitude_phase_coupling,
@@ -158,6 +173,22 @@ try:
158
173
  controlled,
159
174
  random_state,
160
175
  partial_trace, # Partial trace utility
176
+ to_numpy, # backend array -> numpy (works without PyTorch)
177
+ to_tensor, # numpy/list -> torch tensor on a given device
178
+ is_tensor,
179
+
180
+ # Noise channel factories (CPTP-verified as of engine v0.4.0)
181
+ bit_flip_channel,
182
+ phase_flip_channel,
183
+ depolarizing_channel,
184
+ amplitude_damping_channel,
185
+ phase_damping_channel,
186
+ generalized_amplitude_damping_channel,
187
+ thermal_noise_channel,
188
+ coherent_noise_channel,
189
+ amplitude_phase_coupling_channel,
190
+ two_qubit_correlated_noise,
191
+ readout_error_channel,
161
192
 
162
193
  # GPU and backend detection
163
194
  _GPU_AVAILABLE,
@@ -197,14 +228,34 @@ try:
197
228
  # StatevectorEngine is still available as an alias to HDQS
198
229
  StatevectorEngine = HDQS
199
230
 
200
- except ImportError:
201
- # If hdqs_engine is not available, set all to None
231
+ except ImportError as _engine_import_error:
232
+ # Only swallow "hdqs_engine (or a dependency) isn't installed". A genuine
233
+ # error raised from *inside* the module (e.g. a broken NumPy) should not be
234
+ # silently turned into `HDQS = None` — that surfaces later as a confusing
235
+ # `TypeError: 'NoneType' object is not callable`.
236
+ import warnings as _warnings
237
+ _warnings.warn(f"sia.hdqs_engine unavailable: {_engine_import_error}",
238
+ ImportWarning)
202
239
  HDQS = None
203
240
  StatevectorEngine = None
204
241
  GATES = None
205
242
  controlled = None
206
243
  random_state = None
207
244
  partial_trace = None
245
+ to_numpy = None
246
+ is_tensor = None
247
+
248
+ bit_flip_channel = None
249
+ phase_flip_channel = None
250
+ depolarizing_channel = None
251
+ amplitude_damping_channel = None
252
+ phase_damping_channel = None
253
+ generalized_amplitude_damping_channel = None
254
+ thermal_noise_channel = None
255
+ coherent_noise_channel = None
256
+ amplitude_phase_coupling_channel = None
257
+ two_qubit_correlated_noise = None
258
+ readout_error_channel = None
208
259
 
209
260
  _GPU_AVAILABLE = False
210
261
  _TORCH_AVAILABLE = False
@@ -275,7 +326,14 @@ __all__ = [
275
326
  "run_file",
276
327
  "extract_sia_block",
277
328
  "TypedVariable",
278
- "RuntimeError",
329
+ # "RuntimeError" is deliberately NOT exported: it is a legacy v4.x alias
330
+ # left at None for backward attribute access (sia.RuntimeError), but
331
+ # listing it in __all__ made `from sia import *` REPLACE the builtin
332
+ # RuntimeError with None in the importer's namespace — breaking both
333
+ # `raise RuntimeError(...)` (TypeError: 'NoneType' object is not callable)
334
+ # and `except RuntimeError:` (TypeError: catching classes that do not
335
+ # inherit from BaseException is not allowed). The attribute is retained
336
+ # below; only the star-export is removed.
279
337
  "SystemVariables",
280
338
  "SelectionOption",
281
339
 
@@ -323,4 +381,26 @@ __all__ = [
323
381
 
324
382
  # Module reference
325
383
  "hdqs_engine",
326
- ]
384
+ ]
385
+
386
+
387
+ # =====================================================
388
+ # LEGACY ATTRIBUTE SHIM (PEP 562)
389
+ # =====================================================
390
+ # `sia.RuntimeError` was a v4.x ELS name that has been None since v5. Binding
391
+ # it at module scope shadowed the builtin here and — because it was listed in
392
+ # __all__ — in the namespace of anyone doing `from sia import *`. Serving it
393
+ # from __getattr__ keeps old attribute access working while leaving the
394
+ # builtin untouched.
395
+
396
+ _LEGACY_NONE_ATTRS = frozenset({"RuntimeError"})
397
+
398
+
399
+ def __getattr__(name):
400
+ if name in _LEGACY_NONE_ATTRS:
401
+ return None
402
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
403
+
404
+
405
+ def __dir__():
406
+ return sorted(set(globals()) | _LEGACY_NONE_ATTRS)