sia-script 1.5.2__tar.gz → 1.5.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.
@@ -0,0 +1,561 @@
1
+ Metadata-Version: 2.4
2
+ Name: sia-script
3
+ Version: 1.5.4
4
+ Summary: SIA: offline quantum simulator (hdqs_engine) with algorithm visuals and live browser players, HDQS server client, SiaNTT and SIA-ELS. One import: from sia import hdqs
5
+ Author-email: Sia Software Innovations Private Limited <info@siasoftwareinnovations.com>
6
+ License-Expression: LicenseRef-SIA-Proprietary AND MIT
7
+ Project-URL: Homepage, https://www.siasoftwareinnovations.com
8
+ Project-URL: Documentation, https://www.siasoftwareinnovations.com
9
+ Keywords: SIA,HDQS,hdqs-engine,quantum computing,quantum simulator,statevector,density matrix,stabilizer,matrix product state,quantum machine learning,OpenQASM,QKD,Grover,VQE,QAOA,Shor,quantum visualization,Bloch sphere,quantum education,algorithm animation,ABAP,Enterprise Logic Studio,SiaNTT
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Intended Audience :: Science/Research
20
+ Classifier: Intended Audience :: Education
21
+ Classifier: Topic :: Scientific/Engineering :: Physics
22
+ Classifier: Topic :: Scientific/Engineering :: Quantum Computing
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Topic :: Software Development :: Interpreters
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Classifier: Topic :: System :: Distributed Computing
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE.md
30
+ Requires-Dist: numpy>=1.24.0
31
+ Requires-Dist: requests>=2.31.0
32
+ Requires-Dist: matplotlib>=3.6
33
+ Requires-Dist: openqasm3[parser]>=1.0
34
+ Provides-Extra: torch
35
+ Requires-Dist: torch>=2.0; extra == "torch"
36
+ Provides-Extra: qasm
37
+ Provides-Extra: plot
38
+ Provides-Extra: scipy
39
+ Requires-Dist: scipy>=1.10; extra == "scipy"
40
+ Provides-Extra: interop
41
+ Requires-Dist: qiskit>=1.0; extra == "interop"
42
+ Requires-Dist: qiskit-aer>=0.14; extra == "interop"
43
+ Requires-Dist: pennylane>=0.35; extra == "interop"
44
+ Provides-Extra: full
45
+ Requires-Dist: torch>=2.0; extra == "full"
46
+ Requires-Dist: openqasm3[parser]>=1.0; extra == "full"
47
+ Requires-Dist: matplotlib>=3.6; extra == "full"
48
+ Requires-Dist: scipy>=1.10; extra == "full"
49
+ Provides-Extra: all
50
+ Requires-Dist: torch>=2.0; extra == "all"
51
+ Requires-Dist: openqasm3[parser]>=1.0; extra == "all"
52
+ Requires-Dist: matplotlib>=3.6; extra == "all"
53
+ Requires-Dist: scipy>=1.10; extra == "all"
54
+ Requires-Dist: qiskit>=1.0; extra == "all"
55
+ Requires-Dist: qiskit-aer>=0.14; extra == "all"
56
+ Requires-Dist: pennylane>=0.35; extra == "all"
57
+ Provides-Extra: client
58
+ Provides-Extra: engine
59
+ Dynamic: license-file
60
+
61
+ # SIA — Simplified Integrated Architecture
62
+
63
+ [![PyPI](https://img.shields.io/pypi/v/sia-script.svg)](https://pypi.org/project/sia-script/)
64
+ [![Python](https://img.shields.io/pypi/pyversions/sia-script.svg)](https://pypi.org/project/sia-script/)
65
+ [![License](https://img.shields.io/badge/license-Proprietary%20%2B%20MIT%20engine-blue.svg)](LICENSE.md)
66
+
67
+ **sia-script** is the Python library of Sia Software Innovations Private Limited.
68
+ It provides an offline quantum simulator, a client for the HDQS quantum server,
69
+ a declarative entity module, and an ABAP-style enterprise logic interpreter,
70
+ all behind short, chainable APIs.
71
+
72
+ ```python
73
+ from sia import hdqs
74
+
75
+ q = hdqs(2).h(0).cx(0, 1)
76
+ print(q.sample(1000)) # {'00': ~500, '11': ~500}
77
+ ```
78
+
79
+ One import is all a program needs.
80
+
81
+ ---
82
+
83
+ ## Contents
84
+
85
+ - [Installation](#installation)
86
+ - [Components](#components)
87
+ - [Quantum simulation: `hdqs`](#quantum-simulation-hdqs)
88
+ - [HDQS server client](#hdqs-server-client)
89
+ - [Entities: `ntt`](#entities-ntt)
90
+ - [Enterprise logic: `els`](#enterprise-logic-els)
91
+ - [Optional dependencies](#optional-dependencies)
92
+ - [Conventions](#conventions)
93
+ - [Licensing](#licensing)
94
+ - [Citation](#citation)
95
+ - [Support](#support)
96
+
97
+ ---
98
+
99
+ ## Installation
100
+
101
+ ```bash
102
+ pip install sia-script
103
+ ```
104
+
105
+ Requires Python 3.9 or newer. The install brings NumPy, Requests, Matplotlib
106
+ and openqasm3, so figures, animations, paper figures, worksheets and QASM work
107
+ straight away. Heavier features are extras:
108
+
109
+ ```bash
110
+ pip install "sia-script[torch]" # trainable quantum layers, CUDA acceleration
111
+ pip install "sia-script[full]" # torch and SciPy
112
+ pip install "sia-script[all]" # everything, including Qiskit/Aer/PennyLane adapters
113
+ ```
114
+
115
+ ## Components
116
+
117
+ | Import | What it is | Needs network |
118
+ |---|---|---|
119
+ | `from sia import hdqs` | Offline quantum simulator (`hdqs(n)`), plus the server client through the same name | No (simulator) |
120
+ | `from sia import ntt` | SiaNTT declarative entities with safe, AST-checked expressions | No |
121
+ | `from sia import els` | SIA Enterprise Logic Studio, an ABAP-style interpreter | No |
122
+
123
+ The simulator runs entirely on your machine. Importing `sia` makes no network
124
+ call; only the server client contacts the HDQS server, and only when you create
125
+ a client.
126
+
127
+ ## Quantum simulation: `hdqs`
128
+
129
+ ### Chainable circuits
130
+
131
+ Every gate returns the register, so programs stay short:
132
+
133
+ ```python
134
+ from sia import hdqs
135
+
136
+ q = hdqs(3).h(0).cx(0, 1).cx(1, 2) # GHZ state
137
+ q.show_state() # amplitude table
138
+ print(q.sample(1000)) # measurement counts
139
+ print(q.estimator("ZZI")["value"]) # <ZZI> = 1.0
140
+ print(q.resources()["depth"]) # 3
141
+ ```
142
+
143
+ Gates: `h x y z s sdg t tdg rx ry rz p u3 cx cy cz cp crx cry crz swap ccx
144
+ cswap mcx` (`cnot` and `toffoli` are aliases), the `cx_chain()` ladder, plus
145
+ `barrier`, `reset_qubit`, `measure` and custom `unitary`.
146
+
147
+ ### Noise
148
+
149
+ Density-matrix mode supports CPTP-verified channels:
150
+
151
+ ```python
152
+ from sia import hdqs
153
+
154
+ q = hdqs.dm(2).h(0).cx(0, 1).depolarizing(0, 0.05).amplitude_damping(1, 0.1)
155
+ print(q.purity(), q.concurrence())
156
+
157
+ noisy = hdqs(2).h(0).cx(0, 1).with_noise("depolarizing", 0.01) # replay with noise
158
+ ```
159
+
160
+ Channels: bit flip, phase flip, depolarizing, amplitude damping, phase damping,
161
+ generalized amplitude damping, thermal relaxation, coherent over-rotation,
162
+ amplitude–phase coupling, correlated two-qubit noise, and classical readout error.
163
+
164
+ ### Programs: replay, feed-forward, undo
165
+
166
+ The register remembers its own program, so the same object can be rerun,
167
+ drawn, optimized, exported or undone:
168
+
169
+ ```python
170
+ from sia import hdqs
171
+
172
+ q = hdqs(3).h(0).cx(0, 1).ry(2, 0.4)
173
+ print(q.run(500).counts) # rerun as a program
174
+ print(q.copy().compose(q.inverse()).probability_of("000")) # undo: 1.0
175
+
176
+ ff = hdqs(2).h(0).measure(0, key="m").if_x("m", 1) # mid-circuit feed-forward
177
+ print(ff.records, ff.run(1000).counts)
178
+ ```
179
+
180
+ `measure(qubit, key="m")` keeps the chain going and stores the outcome in
181
+ `q.records["m"]`; `if_x`, `if_z` and `if_gate` record their condition, so
182
+ `run()`, `draw()` and `to_qasm3()` reproduce the program exactly. Branch with
183
+ these, not with a Python `if`. Plain `measure(qubit)` still returns the outcome
184
+ as a string.
185
+
186
+ ### Large registers and simulation modes
187
+
188
+ A register too large for a full state (above the 1 GiB default budget) records
189
+ its program instead of failing, and can run on the stabilizer or MPS simulator:
190
+
191
+ ```python
192
+ from sia import hdqs
193
+
194
+ print(hdqs(200).h(0).cx_chain().stabilizer().sample(5)) # 200-qubit GHZ
195
+ print(hdqs(40).h(0).cx_chain().mps().summary()["max_bond_dimension"]) # 2
196
+ ```
197
+
198
+ | Mode | Call | Use for |
199
+ |---|---|---|
200
+ | statevector | `hdqs(n)` (default) | Exact pure-state simulation |
201
+ | density matrix | `hdqs.dm(n)` | Exact mixed states and noise |
202
+ | trajectory | `q.run(mode="trajectory", noise=...)` | Sampled noise at statevector memory cost |
203
+ | stabilizer | `q.stabilizer()` | Large Clifford-only circuits |
204
+ | MPS | `q.mps(max_bond_dim=...)` | Low-entanglement circuits |
205
+
206
+ For parameterized templates reused with different values, use
207
+ `hdqs.Circuit` with `hdqs.Parameter` and `run(bindings=...)` or `sweep(...)`.
208
+
209
+ ### Algorithms and protocols
210
+
211
+ ```python
212
+ from sia import hdqs
213
+
214
+ print(hdqs.grover(3, ["101"])["best"]) # '101'
215
+ print(hdqs.simon("110")["recovered"]) # '110'
216
+ print(sorted(hdqs.shor_demo(15)["factors"])) # [3, 5]
217
+ print(hdqs.teleport()["fidelity"]) # 1.0
218
+ print(hdqs.bb84(256, eavesdrop=True)["eavesdropping_suspected"]) # True
219
+ ```
220
+
221
+ Included: Deutsch, Deutsch–Jozsa, Bernstein–Vazirani, Grover, Simon, QFT (`qft_demo`),
222
+ phase estimation, order finding and a small Shor demonstration, teleportation,
223
+ superdense coding, VQE, QAOA, a repetition code, and the BB84, E91 and QSS
224
+ protocols (educational simulations, not production key distribution). Every
225
+ result can animate itself with `.draw()` (see Algorithm visuals).
226
+
227
+ ### Analysis and mitigation
228
+
229
+ Observables and Pauli sums, sampled estimates with standard errors, Trotter
230
+ evolution, entropy, concurrence, negativity, mutual information, state
231
+ tomography, readout-error mitigation, zero-noise extrapolation, and CRIA
232
+ interference accessibility (`interference_report`, `interference_profile`,
233
+ `recover_interference`).
234
+
235
+ ### Machine learning (requires `[torch]`)
236
+
237
+ ```python
238
+ import torch
239
+ from sia import hdqs
240
+
241
+ layer = hdqs.quantum_layer(4, layers=2) # an ordinary torch.nn.Module
242
+ out = layer(torch.rand(8, 4, dtype=torch.float64)) # (8, 4) Pauli-Z expectations
243
+ ```
244
+
245
+ `hdqs.quantum_layer(..., diff="parameter_shift")` gives hardware-style
246
+ gradients instead. The underlying classes are `BackpropQuantumLayer`,
247
+ `QuantumLayer`, `MidCircuitQuantumLayer`, `QASMQuantumLayer`, and
248
+ `CircuitQuantumLayer` (any `Circuit`, including exact gradients through
249
+ mid-circuit measurement).
250
+
251
+ ### Visuals: one call, letter codes
252
+
253
+ ```python
254
+ from sia import hdqs
255
+
256
+ q = hdqs(3).h(0).cx(0, 1).ry(2, 0.7).cx(1, 2)
257
+ q.draw("b") # Bloch spheres, shown inline or in a window
258
+ q.draw("b,a,e", "state.png") # several views in one figure
259
+ q.draw("all", "lesson.html") # offline interactive page with a gate-by-gate slider
260
+ q.draw("a,b", "steps.gif") # animation over the gates
261
+ q.draw("b,q,d", "model.glb") # 3D for Blender
262
+ q.draw("b", "bloch.3mf") # colour 3D print, with a print report
263
+ q.draw("c,b,a", "fig.pdf", preset="paper") # journal figure + caption
264
+ q.draw("c", "circuit.tex") # LaTeX (quantikz)
265
+ q.export_bundle("experiment.zip") # everything needed to publish or reproduce it
266
+ q.code() # the hdqs chain that rebuilds q
267
+ ```
268
+
269
+ | Code | View |
270
+ |---|---|
271
+ | `c` | Circuit diagram (controls, targets, angles, measurements, conditions) |
272
+ | `p` | Exact probabilities |
273
+ | `h` | Measured counts (`shots=`), with ±1σ error bars and the exact values |
274
+ | `a` | Amplitudes & phase: bar height = magnitude, colour and a clock hand = phase |
275
+ | `b` | Bloch sphere for every qubit, with coordinates and purity |
276
+ | `q` | Q-sphere: basis states by number of 1s, coloured by phase |
277
+ | `d` | Density matrix, real and imaginary parts (up to 5 qubits, or `qubits=[...]`) |
278
+ | `e` | Entanglement map: mutual information and concurrence for every qubit pair |
279
+ | `i` | CRIA interference profile with the best helper sets |
280
+ | `s` | Step-through: the state after every gate |
281
+ | `all` | Every 2D view (`c p h a b q d e i`) |
282
+
283
+ Codes combine with commas (`"b,a,e"`), and several outputs can be written at
284
+ once (`"x.png,x.html,x.glb"`). The file extension picks the output:
285
+
286
+ | Extension | Output | Needs |
287
+ |---|---|---|
288
+ | `.png .jpg .svg .pdf .webp` | Combined figure, light or dark (`theme="dark"`); `preset="paper"` for publications | — |
289
+ | `.gif` | Animation over the gates | — |
290
+ | `.html` | Interactive page: step slider, rotatable spheres, exact values on hover, table view, data download. One file, works offline and on phones | — |
291
+ | `.json` `.csv` | The numbers behind every view | — |
292
+ | `.tex` | The circuit as LaTeX quantikz (`standalone=False` for the bare environment) | — |
293
+ | `.glb` `.obj` | 3D scene for Blender, Maya, Unity or web viewers, with every part a named object | — |
294
+ | `.3mf` | Print-ready colour model in millimetres: one named, coloured part per piece, print report inside | — |
295
+ | `.stl` | Watertight, print-ready model in millimetres | — |
296
+
297
+ 3D files are produced only when a 3D extension is named, so `"all"` never
298
+ writes one by accident. The 3D views are `b`, `q` and `d`. `q.draw("bell.png")`
299
+ still draws the circuit, and `q.plot(...)` still returns a Matplotlib figure.
300
+
301
+ ### 3D printing
302
+
303
+ ```python
304
+ q = hdqs(2).h(0).cx(0, 1).ry(1, 0.4)
305
+ q.draw("b", "bell.3mf", diameter=60) # 60 mm spheres, FDM settings
306
+ q.draw("b", "bell.stl", preset="resin", wall=0.6) # finer resin print
307
+ q.last_print_report["min_feature_mm"]
308
+ ```
309
+
310
+ ```text
311
+ 3D print report — bell.3mf (3MF, preset fdm)
312
+ ✓ watertight / manifold
313
+ ✓ minimum feature: 1.2 mm (target wall 1.2 mm)
314
+ • size: 153 × 66 × 76.4 mm
315
+ • volume: ≤ 32.71 cm³ (overlapping parts are merged by the slicer)
316
+ • 34 parts, 49,456 triangles, 6 colours
317
+ • overhangs: 6.5% of surface — supports recommended
318
+ ```
319
+
320
+ | Option | Meaning |
321
+ |---|---|
322
+ | `diameter=` | Sphere diameter in mm (otherwise `scale=` × 60 mm) |
323
+ | `wall=` | Thinnest printed feature in mm; tubes and letters are thickened to it |
324
+ | `preset=` | `"fdm"` (wall 1.2 mm, medium detail, the default) or `"resin"` (0.5 mm, high detail) |
325
+ | `detail=` | `"low"`, `"medium"`, `"high"`: fewer or more triangles |
326
+ | `base=` | Stand with an embossed label plate (`False` for none) |
327
+ | `labels=` | `True` / `"embossed"` or `"none"`; labels too small for the wall are enlarged a little or left out with a note |
328
+ | `report=` | `False` to skip printing the report (it is still in `q.last_print_report`) |
329
+
330
+ 3MF keeps units, colours and part names (`bloch_q0_equator`, `bloch_q0_state_arrow`,
331
+ …), so multi-colour slicers can assign a filament per part. The report checks
332
+ each part for closed, consistently oriented edges and measures the thinnest
333
+ feature, size, volume and overhang share.
334
+
335
+ ### Publication figures
336
+
337
+ ```python
338
+ q.draw("c,b,a,e", "figure.pdf", preset="paper") # double column (7.16 in)
339
+ q.draw("a", "amps.png", preset="paper", column="single") # 3.5 in, 600 dpi
340
+ q.draw("a,d", "bw.pdf", preset="paper", palette="grayscale") # prints in black and white
341
+ print(q.last_caption) # also in figure.caption.txt
342
+ ```
343
+
344
+ The paper preset uses serif (STIX) type, removes the dashboard header, scales
345
+ lines and fonts to the real page size (never below 6 pt), uses a
346
+ colour-blind-safe palette by default and writes a caption generated from the
347
+ run: what is shown, the gates, exact versus sampled data and the version.
348
+
349
+ ### Research bundles
350
+
351
+ ```python
352
+ q = hdqs(2, seed=42).h(0).cx(0, 1)
353
+ q.export_bundle("bell_experiment") # a folder, or "bell.zip"
354
+ hdqs.grover(3, ["101"], seed=3).export_bundle("grover.zip")
355
+ ```
356
+
357
+ | File | Contents |
358
+ |---|---|
359
+ | `figure.pdf`, `figure.svg`, `figure.caption.txt` | Paper-preset figure and its caption |
360
+ | `data.json`, `data.csv` | State, probabilities, Bloch vectors, entanglement |
361
+ | `circuit.qasm`, `circuit.tex` | OpenQASM 3 and quantikz LaTeX |
362
+ | `experiment.py` | Rebuilds the run: the hdqs chain with its seed, or the one-line algorithm call |
363
+ | `explorer.html` / `player.html` | Offline interactive page |
364
+ | `metadata.json` | Engine version, seed, shots, mode, inputs, circuit hash, provenance of every file |
365
+ | `environment.txt`, `README.md` | Package versions; what each file is and how to cite it |
366
+
367
+ Algorithm bundles add `stages.pdf` and `summary.png`.
368
+
369
+ ### In notebooks
370
+
371
+ In Jupyter and VS Code a register or algorithm result shows itself: a summary
372
+ card with the interactive explorer (or live player) embedded, no `.draw()`
373
+ needed. `hdqs.rich_display(False)` switches it off.
374
+
375
+ ### Browser playground
376
+
377
+ ```python
378
+ hdqs.playground("playground.html") # an empty playground with examples
379
+ hdqs.playground("mine.html", q) # starts from q.code()
380
+ ```
381
+
382
+ One offline HTML file with an editor that runs hdqs chains in the browser:
383
+ gates, `measure`, `if_x`/`if_z`, `unitary`, `load_state`, `for` loops, lists,
384
+ complex numbers and `print`, up to 10 qubits. The circuit, amplitudes, Bloch
385
+ spheres, Q-sphere and entanglement update with a gate-by-gate slider, and
386
+ errors point at the line. The same code runs unchanged in Python. Algorithm
387
+ players have a **Playground** tab too: *Edit & run in the playground* loads
388
+ `r.code()`.
389
+
390
+ ### Algorithm visuals: how it works, not just the circuit
391
+
392
+ Every algorithm returns its usual result dictionary, which now also has
393
+ `.draw()`, `.code()` and `.circuit`. The animation explains the idea behind the
394
+ algorithm using the states recorded during that very run, so every picture
395
+ matches the returned numbers, and it changes with whatever inputs you give it.
396
+
397
+ ```python
398
+ from sia import hdqs
399
+
400
+ r = hdqs.grover(3, ["101"])
401
+ r.draw("grover.gif") # the circuit, then inversion about the mean and the rotation picture
402
+ r.draw("grover.html") # live player: change the inputs and re-run, right in the browser
403
+ r.draw("grover.png", summary=True) # one slide with the answer
404
+ r.code() # the hdqs chain that builds this run's circuit
405
+ r.draw("grover.tex") # the circuit in LaTeX, sections boxed
406
+ r.lesson("grover.html") # predict, then reveal: a question before each key stage
407
+ r.worksheet("grover.pdf") # printable worksheet with a solutions page
408
+ r.export_frames("frames", "svg") # every stage as a numbered image
409
+ ```
410
+
411
+ Each animation opens with **the circuit built for your input**, with the oracle
412
+ and other parts labelled. Grover, Deutsch–Jozsa and Simon use real gate-level
413
+ oracles (X gates around a multi-controlled Z; one Z per bit when f is linear;
414
+ CNOT copies for Simon). `r.code()` prints that circuit as a runnable
415
+ one-import chain (repeated Grover iterations become a loop), and `r.circuit`
416
+ is the program itself.
417
+
418
+ The last frame carries a **result banner** (`FOUND 101`, `15 = 3 × 5`,
419
+ `ABORT · QBER 25%`) and every panel says **where its numbers come from**:
420
+ EXACT (from the state), SAMPLED (measurement shots), CLASSICAL (ordinary
421
+ computation) or THEORY (a formula).
422
+
423
+ | Algorithm | What the animation shows |
424
+ |---|---|
425
+ | `grover` | Amplitudes reflected about the mean, the 2D rotation picture with its mirrors, success probability |
426
+ | `deutsch`, `deutsch_jozsa` | Phase kickback turning f(x) into signs, then interference deciding constant vs balanced |
427
+ | `bernstein_vazirani` | Each oracle CNOT flipping one qubit to \|−⟩; Hadamards turning the phases into the hidden bits |
428
+ | `simon` | Equations y·s = 0 accumulating while the candidate secrets are crossed out |
429
+ | `qft_demo` | Output qubits turning at ½, ¼, ⅛ … turn per +1, and the output phasors |
430
+ | `phase_estimation` | Kickback onto each counting qubit, the outcome distribution sharpening with precision |
431
+ | `order_finding`, `shor_demo` | The period of aˣ mod N, QPE peaks at s/r, continued fractions, gcd to the factors |
432
+ | `teleport` | Three Bloch spheres, entanglement links, two classical bits travelling, Bob's correction |
433
+ | `superdense` | Alice's operation choosing one of four Bell states, Bob decoding two bits |
434
+ | `vqe` | Energy converging towards the exact ground energy, the path over the energy landscape |
435
+ | `qaoa_maxcut` | The (γ, β) landscape search, sampled cut sizes, the best cut drawn on the graph |
436
+ | `bb84`, `e91`, `qss` | Bases and photons, sifting and the QBER alarm; the CHSH value passing 2; GHZ parity |
437
+ | `repetition_code_demo` | Encoding, a bit flip, the syndrome lighting up, correction and decoding |
438
+ | `interference_report` (CRIA) | Interference recovered as more helper qubits are read |
439
+
440
+ | Extension | Output | Needs |
441
+ |---|---|---|
442
+ | `.html` | **Live player**: plays the run; the reader can change the inputs and re-run the algorithm in the browser (a built-in simulator, no internet, no Python); Code and Playground tabs; light/dark; SVG and JSON download | — |
443
+ | `.gif` | Animation (`speed=`, `tween=` for in-between frames) | — |
444
+ | `.png .jpg .webp` | Storyboard of every stage, one stage with `scene=k`, or one slide with `summary=True` | — |
445
+ | `.pdf` | One page per stage | — |
446
+ | `.json` | The recorded stages as data | — |
447
+ | `.tex` | The executed circuit as LaTeX quantikz, sections as labelled boxes | — |
448
+ | `.mp4` | Video, when ffmpeg is installed | ffmpeg |
449
+
450
+ **Teaching.** `r.lesson("x.html")` turns the live player into a lesson: before
451
+ each key stage the student predicts what happens (multiple choice, built from
452
+ this run's numbers), reads why, and only then sees the stage; the inputs tab
453
+ unlocks at the end. `r.worksheet("x.pdf")` prints the same questions on A4 with
454
+ the stage before each one, answer space and a solutions section
455
+ (`solutions=False` for the student copy).
456
+
457
+ The recording costs only a few numbers per stage; the pictures are made when
458
+ `.draw()` is called. In the browser player, a seed gives a repeatable run, but
459
+ sampled results use the browser's own random numbers, not Python's.
460
+
461
+ ### Interoperability
462
+
463
+ OpenQASM 3 via `hdqs.from_qasm3(source)` and `q.to_qasm3()`.
464
+ Optional adapters: `hdqs.to_qiskit`, `hdqs.run_aer`, `hdqs.to_pennylane`.
465
+
466
+ ## HDQS server client
467
+
468
+ The same `hdqs` name reaches the HDQS quantum server. A whole number builds the
469
+ local simulator; any other call connects to the server:
470
+
471
+ ```python
472
+ from sia import hdqs
473
+
474
+ client = hdqs(api_key="YOUR_TOKEN")
475
+ client.qbt_create(num_qubits=2)
476
+ client.qbt_run(["h 0", "cnot 0 1"])
477
+ print(client.qbt_measure([0, 1]))
478
+ ```
479
+
480
+ An API token is issued by Sia Software Innovations. The server address can be
481
+ changed without reinstalling, using the `SIA_HDQS_HOST` and `SIA_HDQS_PORT`
482
+ environment variables. If the server is unreachable, client calls raise
483
+ `hdqs.HDQSError`; the offline simulator is unaffected.
484
+
485
+ ## Entities: `ntt`
486
+
487
+ ```python
488
+ from sia import ntt
489
+
490
+ Person = ntt("name", "age").computed("group", "if (1) > 17: adult | else: minor")
491
+ p = Person("Ravi", 20)
492
+ print(p.name, p.group) # Ravi adult
493
+ ```
494
+
495
+ Templates refer to attributes by position, `(0)`, `(1)`, and so on. Conditions
496
+ and validators are evaluated through a restricted expression checker, never
497
+ `eval`.
498
+
499
+ ## Enterprise logic: `els`
500
+
501
+ ```python
502
+ from sia import els
503
+
504
+ program = """
505
+ *sia
506
+ DATA total TYPE I.
507
+ total = 40 + 2.
508
+ WRITE total.
509
+ sia*
510
+ """
511
+ print(els(program)) # 42
512
+ ```
513
+
514
+ For multi-block programs, share state with `env = els.make_env()` and call
515
+ `els(block, env)`. An interactive prompt is available through `els.repl()`.
516
+
517
+ ## Optional dependencies
518
+
519
+ | Extra | Installs | Enables |
520
+ |---|---|---|
521
+ | `torch` | PyTorch | Trainable layers, CUDA acceleration |
522
+ | `scipy` | SciPy | Sparse observable matrices |
523
+ | `interop` | Qiskit, Qiskit Aer, PennyLane | Adapters |
524
+ | `full` | torch, scipy | Everything except the adapters |
525
+ | `all` | Everything above | Everything |
526
+
527
+ Matplotlib and openqasm3 are regular dependencies since 1.5.4; the old
528
+ `[plot]` and `[qasm]` extras still install without error.
529
+
530
+ A feature whose dependency is missing raises an `ImportError` naming the
531
+ package to install. `hdqs.capabilities()` reports what is available.
532
+
533
+ ## Conventions
534
+
535
+ - Qubit 0 is the most significant bit: in `'01'`, qubit 0 is `0`.
536
+ Qiskit uses the opposite order; the adapters convert automatically.
537
+ - `measure()` collapses the state; `sample()` and `probabilities()` do not.
538
+ - Memory grows exponentially with qubit count in the statevector and
539
+ density-matrix modes. Above the 1 GiB default budget a register becomes
540
+ program-only (`q.is_lazy`): use `q.stabilizer()` or `q.mps()`, or pass
541
+ `max_memory_mb=` to allow a larger full state.
542
+
543
+ ## Licensing
544
+
545
+ sia-script is proprietary software of Sia Software Innovations Private Limited,
546
+ with one exception: the quantum simulator, `sia/hdqs_engine.py`, is released
547
+ under the MIT License. See [LICENSE.md](LICENSE.md) for the full terms of both.
548
+
549
+ ## Citation
550
+
551
+ If you use the CRIA interference-accessibility tools in research, please cite:
552
+
553
+ > Seshabattara Venkata, N. S. D. N. *Cardinality-Resolved Interference
554
+ > Accessibility in Multipartite Quantum Systems.* Zenodo (2026).
555
+ > https://doi.org/10.5281/zenodo.23180889
556
+
557
+ ## Support
558
+
559
+ Sia Software Innovations Private Limited
560
+ Email: info@siasoftwareinnovations.com
561
+ Website: https://www.siasoftwareinnovations.com