sia-script 0.8.7__tar.gz → 1.0.2__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.
@@ -0,0 +1,3 @@
1
+ include src/*.cpp
2
+ include README.md LICENSE.md pyproject.toml setup.py
3
+ recursive-include sia *.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sia-script
3
- Version: 0.8.7
3
+ Version: 1.0.2
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
@@ -62,17 +62,17 @@ Classifier: Topic :: System :: Distributed Computing
62
62
  Requires-Python: >=3.8
63
63
  Description-Content-Type: text/markdown
64
64
  License-File: LICENSE.md
65
+ Requires-Dist: numpy>=1.24.0
66
+ Requires-Dist: requests>=2.31.0
65
67
  Provides-Extra: client
66
- Requires-Dist: requests>=2.31.0; extra == "client"
67
- Requires-Dist: numpy>=1.24.0; extra == "client"
68
68
  Provides-Extra: engine
69
- Requires-Dist: numpy>=1.24.0; extra == "engine"
70
69
  Provides-Extra: torch
71
70
  Requires-Dist: torch>=2.0; extra == "torch"
71
+ Provides-Extra: qasm
72
+ Requires-Dist: openqasm3[parser]>=1.0; extra == "qasm"
72
73
  Provides-Extra: full
73
- Requires-Dist: requests>=2.31.0; extra == "full"
74
- Requires-Dist: numpy>=1.24.0; extra == "full"
75
74
  Requires-Dist: torch>=2.0; extra == "full"
75
+ Requires-Dist: openqasm3[parser]>=1.0; extra == "full"
76
76
  Dynamic: license-file
77
77
 
78
78
  SIA — Simplified Integrated Architecture
@@ -1,10 +1,10 @@
1
1
  [build-system]
2
- requires = ["setuptools>=61.0", "wheel"]
2
+ requires = ["setuptools>=61.0", "wheel", "pybind11>=2.11"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sia-script"
7
- version = "0.8.7"
7
+ version = "1.0.2"
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" }
@@ -38,33 +38,42 @@ classifiers = [
38
38
  "Topic :: System :: Distributed Computing",
39
39
  ]
40
40
 
41
- # No hard dependencies: ntt and els run on the stdlib alone.
42
- # Opt into what you actually need via extras below.
43
- dependencies = []
41
+ # sia/__init__.py unconditionally does `from .hdqs import (...)`, and
42
+ # hdqs.py unconditionally imports both numpy and requests -- so both are
43
+ # real, required base dependencies, not optional. (v1.0.0 and v1.0.1 each
44
+ # had one of these two only under an optional extra, which broke a plain
45
+ # `pip install sia-script` with a ModuleNotFoundError on the very first
46
+ # `import sia` -- caught by testing in a clean venv both times.)
47
+ dependencies = [
48
+ "numpy>=1.24.0",
49
+ "requests>=2.31.0",
50
+ ]
44
51
 
45
52
  [project.urls]
46
53
  Homepage = "https://www.siasoftwareinnovations.com"
47
54
  Documentation = "https://www.siasoftwareinnovations.com"
48
55
 
49
56
  [project.optional-dependencies]
50
- # sia.hdqs — the server client. Needs a running HDQS server and an API token.
51
- client = [
52
- "requests>=2.31.0",
53
- "numpy>=1.24.0",
54
- ]
57
+ # sia.hdqs — the server client. Needs a running HDQS server and an API
58
+ # token. requests is now a base dependency; kept as an empty extra for
59
+ # backward compatibility with anyone depending on sia-script[client].
60
+ client = []
55
61
  # sia.hdqs_engine — offline statevector simulator. No server, no token.
56
- engine = [
57
- "numpy>=1.24.0",
58
- ]
62
+ # numpy is now a base dependency; kept as an empty extra for backward
63
+ # compatibility with anyone depending on sia-script[engine].
64
+ engine = []
59
65
  # sia.hdqs_engine.torch_layer — trainable QuantumLayer nn.Module.
60
66
  torch = [
61
67
  "torch>=2.0",
62
68
  ]
69
+ # sia.hdqs_engine OpenQASM 3 import/export (HDQS.from_qasm3/to_qasm3).
70
+ qasm = [
71
+ "openqasm3[parser]>=1.0",
72
+ ]
63
73
  # Everything above, combined.
64
74
  full = [
65
- "requests>=2.31.0",
66
- "numpy>=1.24.0",
67
75
  "torch>=2.0",
76
+ "openqasm3[parser]>=1.0",
68
77
  ]
69
78
 
70
79
  [tool.setuptools]
@@ -0,0 +1,48 @@
1
+ """
2
+ Adds the sia.hdqs_core native extension to the build. Everything else
3
+ (package metadata, dependencies, version) stays in pyproject.toml — this
4
+ file exists only because setuptools has no purely declarative way to
5
+ build a C++ extension from pyproject.toml alone.
6
+
7
+ `python -m build` picks this up automatically; no change to your
8
+ existing build/twine workflow.
9
+ """
10
+ import sys
11
+ from setuptools import setup
12
+ from pybind11.setup_helpers import Pybind11Extension, build_ext
13
+
14
+ # -O3 for standard optimization. -march=native is deliberately NOT used
15
+ # here: it would tie the compiled wheel to the exact CPU that builds it,
16
+ # and could crash with an "illegal instruction" fault on an end user's
17
+ # different (often older) CPU. This keeps published wheels portable —
18
+ # hdqs_engine.py falls back to a slower but fully portable code path
19
+ # automatically when the fast (AVX2/AVX-512) instructions aren't
20
+ # available at compile time, so nothing breaks, it's just not maximally
21
+ # fast on every machine. Building locally with -march=native (e.g. for
22
+ # your own benchmarking) is a separate, deliberate choice — see the
23
+ # session notes on this if you want that build instead.
24
+ extra_compile_args = ["-O3", "-std=c++17"]
25
+ extra_link_args = []
26
+
27
+ if sys.platform == "win32":
28
+ extra_compile_args = ["/O2", "/std:c++17", "/openmp"]
29
+ else:
30
+ extra_compile_args += ["-fopenmp"]
31
+ extra_link_args += ["-fopenmp"]
32
+
33
+ ext_modules = [
34
+ Pybind11Extension(
35
+ "sia.hdqs_core",
36
+ ["src/hdqs_core.cpp"],
37
+ cxx_std=17,
38
+ extra_compile_args=extra_compile_args,
39
+ extra_link_args=extra_link_args,
40
+ ),
41
+ ]
42
+
43
+ setup(
44
+ package_dir={"sia": "sia"},
45
+ ext_modules=ext_modules,
46
+ cmdclass={"build_ext": build_ext},
47
+ zip_safe=False,
48
+ )
@@ -18,12 +18,31 @@ Client-side package. Loads:
18
18
  Shor's algorithm, but no factoring routine is implemented.
19
19
  Runs entirely locally — no server, no API token, no network call.
20
20
  Requires NumPy; PyTorch optional for GPU acceleration.
21
- Two trainable PyTorch layers are included: QuantumLayer
21
+ Four trainable PyTorch layers are included: QuantumLayer
22
22
  (parameter-shift gradients — models what real hardware
23
- would report back) and BackpropQuantumLayer (ordinary
23
+ would report back), BackpropQuantumLayer (ordinary
24
24
  torch autograd through a batched statevector — no
25
25
  parameter-shift, simulator-only, ~5-10x faster
26
- forward+backward at typical batch sizes).
26
+ forward+backward at typical batch sizes),
27
+ MidCircuitQuantumLayer (batched mid-circuit measurement
28
+ with a classically-conditioned gate; see its docstring
29
+ for the gradient-approximation caveat), and
30
+ QASMQuantumLayer (binds OpenQASM 3 `input` parameters to
31
+ trainable weights).
32
+ OpenQASM 3 interoperability via HDQS.from_qasm3() and
33
+ HDQS.to_qasm3(), covering the standard gate set, gate
34
+ modifiers (inv@/pow@/ctrl@/negctrl@), user-defined `gate`
35
+ blocks (inlined), `const`, `for` loops (unrolled), `let`
36
+ aliases, register/slice broadcasting, reset/barrier/end,
37
+ and if/else and switch branching on measured bits.
38
+ Requires the `openqasm3[parser]` extra.
39
+ Optional native (C++) acceleration for the statevector
40
+ gate-application hot path, with hand-vectorized AVX2/
41
+ AVX-512 kernels where available and automatic fallback to
42
+ pure NumPy on platforms without a compiled extension for
43
+ this build (see `sia.hdqs_engine._NATIVE_AVAILABLE`) --
44
+ a pure performance path, validated to produce identical
45
+ results to the NumPy path.
27
46
  MIT-licensed (see the MIT_LICENSE string in sia/hdqs_engine.py),
28
47
  distinct from the proprietary license covering the rest of
29
48
  this package.
@@ -34,7 +53,7 @@ this client package. They live in the server deployment only. What you get
34
53
  here for local, offline quantum simulation is sia.hdqs_engine.
35
54
  """
36
55
 
37
- __version__ = "0.9.0"
56
+ __version__ = "1.0.0"
38
57
  __author__ = "Sia Software Innovations Private Limited"
39
58
  # NOTE: hardcoding a bare IP couples every released client to one host. If
40
59
  # the server ever moves, every installed copy breaks. Prefer a DNS name
@@ -229,6 +248,8 @@ try:
229
248
  # PyTorch integration with GPU support
230
249
  QuantumLayer,
231
250
  BackpropQuantumLayer,
251
+ MidCircuitQuantumLayer,
252
+ QASMQuantumLayer,
232
253
  )
233
254
 
234
255
  # Legacy alias for backward compatibility
@@ -292,6 +313,8 @@ except ImportError as _engine_import_error:
292
313
 
293
314
  QuantumLayer = None
294
315
  BackpropQuantumLayer = None
316
+ MidCircuitQuantumLayer = None
317
+ QASMQuantumLayer = None
295
318
 
296
319
  hdqs_engine = None
297
320
 
@@ -387,6 +410,8 @@ __all__ = [
387
410
  # PyTorch integration with GPU support
388
411
  "QuantumLayer",
389
412
  "BackpropQuantumLayer",
413
+ "MidCircuitQuantumLayer",
414
+ "QASMQuantumLayer",
390
415
 
391
416
  # Module reference
392
417
  "hdqs_engine",