sia-script 0.8.2__tar.gz → 0.8.3__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.3
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.3"
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,21 @@ 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
+ is_tensor,
178
+
179
+ # Noise channel factories (CPTP-verified as of engine v0.4.0)
180
+ bit_flip_channel,
181
+ phase_flip_channel,
182
+ depolarizing_channel,
183
+ amplitude_damping_channel,
184
+ phase_damping_channel,
185
+ generalized_amplitude_damping_channel,
186
+ thermal_noise_channel,
187
+ coherent_noise_channel,
188
+ amplitude_phase_coupling_channel,
189
+ two_qubit_correlated_noise,
190
+ readout_error_channel,
161
191
 
162
192
  # GPU and backend detection
163
193
  _GPU_AVAILABLE,
@@ -197,14 +227,34 @@ try:
197
227
  # StatevectorEngine is still available as an alias to HDQS
198
228
  StatevectorEngine = HDQS
199
229
 
200
- except ImportError:
201
- # If hdqs_engine is not available, set all to None
230
+ except ImportError as _engine_import_error:
231
+ # Only swallow "hdqs_engine (or a dependency) isn't installed". A genuine
232
+ # error raised from *inside* the module (e.g. a broken NumPy) should not be
233
+ # silently turned into `HDQS = None` — that surfaces later as a confusing
234
+ # `TypeError: 'NoneType' object is not callable`.
235
+ import warnings as _warnings
236
+ _warnings.warn(f"sia.hdqs_engine unavailable: {_engine_import_error}",
237
+ ImportWarning)
202
238
  HDQS = None
203
239
  StatevectorEngine = None
204
240
  GATES = None
205
241
  controlled = None
206
242
  random_state = None
207
243
  partial_trace = None
244
+ to_numpy = None
245
+ is_tensor = None
246
+
247
+ bit_flip_channel = None
248
+ phase_flip_channel = None
249
+ depolarizing_channel = None
250
+ amplitude_damping_channel = None
251
+ phase_damping_channel = None
252
+ generalized_amplitude_damping_channel = None
253
+ thermal_noise_channel = None
254
+ coherent_noise_channel = None
255
+ amplitude_phase_coupling_channel = None
256
+ two_qubit_correlated_noise = None
257
+ readout_error_channel = None
208
258
 
209
259
  _GPU_AVAILABLE = False
210
260
  _TORCH_AVAILABLE = False
@@ -275,7 +325,14 @@ __all__ = [
275
325
  "run_file",
276
326
  "extract_sia_block",
277
327
  "TypedVariable",
278
- "RuntimeError",
328
+ # "RuntimeError" is deliberately NOT exported: it is a legacy v4.x alias
329
+ # left at None for backward attribute access (sia.RuntimeError), but
330
+ # listing it in __all__ made `from sia import *` REPLACE the builtin
331
+ # RuntimeError with None in the importer's namespace — breaking both
332
+ # `raise RuntimeError(...)` (TypeError: 'NoneType' object is not callable)
333
+ # and `except RuntimeError:` (TypeError: catching classes that do not
334
+ # inherit from BaseException is not allowed). The attribute is retained
335
+ # below; only the star-export is removed.
279
336
  "SystemVariables",
280
337
  "SelectionOption",
281
338
 
@@ -323,4 +380,26 @@ __all__ = [
323
380
 
324
381
  # Module reference
325
382
  "hdqs_engine",
326
- ]
383
+ ]
384
+
385
+
386
+ # =====================================================
387
+ # LEGACY ATTRIBUTE SHIM (PEP 562)
388
+ # =====================================================
389
+ # `sia.RuntimeError` was a v4.x ELS name that has been None since v5. Binding
390
+ # it at module scope shadowed the builtin here and — because it was listed in
391
+ # __all__ — in the namespace of anyone doing `from sia import *`. Serving it
392
+ # from __getattr__ keeps old attribute access working while leaving the
393
+ # builtin untouched.
394
+
395
+ _LEGACY_NONE_ATTRS = frozenset({"RuntimeError"})
396
+
397
+
398
+ def __getattr__(name):
399
+ if name in _LEGACY_NONE_ATTRS:
400
+ return None
401
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
402
+
403
+
404
+ def __dir__():
405
+ return sorted(set(globals()) | _LEGACY_NONE_ATTRS)