Metadata-Version: 2.4
Name: sia-script
Version: 1.5.2
Summary: SIA: offline quantum simulator (hdqs_engine), HDQS server client, SiaNTT and SIA-ELS. One import: from sia import hdqs
Author-email: Sia Software Innovations Private Limited <info@siasoftwareinnovations.com>
License-Expression: LicenseRef-SIA-Proprietary AND MIT
Project-URL: Homepage, https://www.siasoftwareinnovations.com
Project-URL: Documentation, https://www.siasoftwareinnovations.com
Keywords: SIA,HDQS,hdqs-engine,quantum computing,quantum simulator,statevector,density matrix,stabilizer,matrix product state,quantum machine learning,OpenQASM,QKD,Grover,VQE,QAOA,ABAP,Enterprise Logic Studio,SiaNTT
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Education
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Scientific/Engineering :: Quantum Computing
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Interpreters
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Distributed Computing
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: numpy>=1.24.0
Requires-Dist: requests>=2.31.0
Provides-Extra: torch
Requires-Dist: torch>=2.0; extra == "torch"
Provides-Extra: qasm
Requires-Dist: openqasm3[parser]>=1.0; extra == "qasm"
Provides-Extra: plot
Requires-Dist: matplotlib>=3.6; extra == "plot"
Provides-Extra: scipy
Requires-Dist: scipy>=1.10; extra == "scipy"
Provides-Extra: interop
Requires-Dist: qiskit>=1.0; extra == "interop"
Requires-Dist: qiskit-aer>=0.14; extra == "interop"
Requires-Dist: pennylane>=0.35; extra == "interop"
Provides-Extra: full
Requires-Dist: torch>=2.0; extra == "full"
Requires-Dist: openqasm3[parser]>=1.0; extra == "full"
Requires-Dist: matplotlib>=3.6; extra == "full"
Requires-Dist: scipy>=1.10; extra == "full"
Provides-Extra: all
Requires-Dist: torch>=2.0; extra == "all"
Requires-Dist: openqasm3[parser]>=1.0; extra == "all"
Requires-Dist: matplotlib>=3.6; extra == "all"
Requires-Dist: scipy>=1.10; extra == "all"
Requires-Dist: qiskit>=1.0; extra == "all"
Requires-Dist: qiskit-aer>=0.14; extra == "all"
Requires-Dist: pennylane>=0.35; extra == "all"
Provides-Extra: client
Provides-Extra: engine
Dynamic: license-file

# SIA — Simplified Integrated Architecture

[![PyPI](https://img.shields.io/pypi/v/sia-script.svg)](https://pypi.org/project/sia-script/)
[![Python](https://img.shields.io/pypi/pyversions/sia-script.svg)](https://pypi.org/project/sia-script/)
[![License](https://img.shields.io/badge/license-Proprietary%20%2B%20MIT%20engine-blue.svg)](LICENSE.md)

**sia-script** is the Python library of Sia Software Innovations Private Limited.
It provides an offline quantum simulator, a client for the HDQS quantum server,
a declarative entity module, and an ABAP-style enterprise logic interpreter,
all behind short, chainable APIs.

```python
from sia import hdqs

q = hdqs(2).h(0).cnot(0, 1)
print(q.sample(1000))          # {'00': ~500, '11': ~500}
```

One import is all a program needs.

---

## Contents

- [Installation](#installation)
- [Components](#components)
- [Quantum simulation: `hdqs`](#quantum-simulation-hdqs)
- [HDQS server client](#hdqs-server-client)
- [Entities: `ntt`](#entities-ntt)
- [Enterprise logic: `els`](#enterprise-logic-els)
- [Optional dependencies](#optional-dependencies)
- [Conventions](#conventions)
- [Licensing](#licensing)
- [Citation](#citation)
- [Support](#support)

---

## Installation

```bash
pip install sia-script
```

Requires Python 3.9 or newer. The base install needs only NumPy and Requests.
Optional features are installed as extras:

```bash
pip install "sia-script[torch]"     # trainable quantum layers, CUDA acceleration
pip install "sia-script[qasm]"      # OpenQASM 3 import and export
pip install "sia-script[plot]"      # circuit diagrams and state plots
pip install "sia-script[full]"      # all of the above, plus SciPy
pip install "sia-script[all]"       # everything, including Qiskit/Aer/PennyLane adapters
```

## Components

| Import | What it is | Needs network |
|---|---|---|
| `from sia import hdqs` | Offline quantum simulator (`hdqs(n)`), plus the server client through the same name | No (simulator) |
| `from sia import ntt` | SiaNTT declarative entities with safe, AST-checked expressions | No |
| `from sia import els` | SIA Enterprise Logic Studio, an ABAP-style interpreter | No |

The simulator runs entirely on your machine. Importing `sia` makes no network
call; only the server client contacts the HDQS server, and only when you create
a client.

## Quantum simulation: `hdqs`

### Chainable circuits

Every gate returns the register, so programs stay short:

```python
from sia import hdqs

q = hdqs(3).h(0).cnot(0, 1).cnot(1, 2)          # GHZ state
q.show_state()                                    # amplitude table
print(q.sample(1000))                             # measurement counts
print(q.estimator("ZZI")["value"])                # <ZZI> = 1.0
print(q.resources()["depth"])                     # 3
```

Gates: `h x y z s sdg t tdg rx ry rz p u3 cnot/cx cy cz cp crx cry crz swap
ccx cswap mcx`, plus `barrier`, `reset_qubit`, `measure` and custom `unitary`.

### Noise

Density-matrix mode supports CPTP-verified channels:

```python
from sia import hdqs

q = hdqs.dm(2).h(0).cnot(0, 1).depolarizing(0, 0.05).amplitude_damping(1, 0.1)
print(q.purity(), q.concurrence())

noisy = hdqs(2).h(0).cnot(0, 1).with_noise("depolarizing", 0.01)   # replay with noise
```

Channels: bit flip, phase flip, depolarizing, amplitude damping, phase damping,
generalized amplitude damping, thermal relaxation, coherent over-rotation,
amplitude–phase coupling, correlated two-qubit noise, and classical readout error.

### Reusable circuits and simulation modes

```python
from sia import hdqs

theta = hdqs.Parameter("theta")
c = hdqs.Circuit(3).ry(0, theta).cx(0, 1).measure(0, "m").if_x("m", 2)
result = c.run(shots=500, bindings={"theta": 0.7}, seed=1)
print(result.counts)

big = hdqs.Circuit(100).h(0)
for i in range(99):
    big.cx(i, i + 1)
print(big.simulate(mode="stabilizer").sample(5))     # 100-qubit Clifford circuit
```

| Mode | Use for |
|---|---|
| `statevector` | Exact pure-state simulation (default) |
| `density_matrix` | Exact mixed states and noise |
| `trajectory` | Sampled noise with statevector memory cost |
| `stabilizer` | Large Clifford-only circuits |
| `mps` | Low-entanglement circuits, with optional bond-dimension truncation |

### Algorithms and protocols

```python
from sia import hdqs

print(hdqs.grover(3, ["101"])["best"])          # '101'
print(hdqs.simon("110")["recovered"])           # '110'
print(sorted(hdqs.shor_demo(15)["factors"]))    # [3, 5]
print(hdqs.teleport()["fidelity"])              # 1.0
print(hdqs.bb84(256, eavesdrop=True)["eavesdropping_suspected"])   # True
```

Included: Deutsch, Deutsch–Jozsa, Bernstein–Vazirani, Grover, Simon, QFT,
phase estimation, order finding and a small Shor demonstration, teleportation,
superdense coding, VQE, QAOA, a repetition code, and the BB84, E91 and QSS
protocols (educational simulations, not production key distribution).

### Analysis and mitigation

Observables and Pauli sums, sampled estimates with standard errors, Trotter
evolution, entropy, concurrence, negativity, mutual information, state
tomography, readout-error mitigation, zero-noise extrapolation, and CRIA
interference accessibility (`interference_report`, `interference_profile`,
`recover_interference`).

### Machine learning (requires `[torch]`)

```python
import torch
from sia import hdqs

layer = hdqs.BackpropQuantumLayer(num_qubits=4, layers=2)
out = layer(torch.rand(8, 4, dtype=torch.float64))     # (8, 4) Pauli-Z expectations
```

Layers: `QuantumLayer` (parameter-shift gradients), `BackpropQuantumLayer`
(autograd), `MidCircuitQuantumLayer`, `QASMQuantumLayer`, and
`CircuitQuantumLayer` (any `Circuit`, including exact gradients through
mid-circuit measurement).

### Circuit diagrams (requires `[plot]`)

```python
from sia import hdqs

hdqs(3).h(0).cnot(0, 1).cnot(1, 2).draw("ghz.png", title="GHZ State")
hdqs.Circuit(2).h(0).measure(0, "m").if_x("m", 1).draw("feedforward.svg", theme="dark")
```

Diagrams export to PNG, SVG or PDF, in light or dark theme, and show controls,
targets, angles, measurements, resets, barriers and classical conditions.

### Interoperability

OpenQASM 3 via `hdqs.from_qasm3(source)` and `q.to_qasm3()` (requires `[qasm]`).
Optional adapters: `hdqs.to_qiskit`, `hdqs.run_aer`, `hdqs.to_pennylane`.

## HDQS server client

The same `hdqs` name reaches the HDQS quantum server. A whole number builds the
local simulator; any other call connects to the server:

```python
from sia import hdqs

client = hdqs(api_key="YOUR_TOKEN")
client.qbt_create(num_qubits=2)
client.qbt_run(["h 0", "cnot 0 1"])
print(client.qbt_measure([0, 1]))
```

An API token is issued by Sia Software Innovations. The server address can be
changed without reinstalling, using the `SIA_HDQS_HOST` and `SIA_HDQS_PORT`
environment variables. If the server is unreachable, client calls raise
`hdqs.HDQSError`; the offline simulator is unaffected.

## Entities: `ntt`

```python
from sia import ntt

Person = ntt("name", "age").computed("group", "if (1) > 17: adult | else: minor")
p = Person("Ravi", 20)
print(p.name, p.group)          # Ravi adult
```

Templates refer to attributes by position, `(0)`, `(1)`, and so on. Conditions
and validators are evaluated through a restricted expression checker, never
`eval`.

## Enterprise logic: `els`

```python
from sia import els

program = """
*sia
  DATA total TYPE I.
  total = 40 + 2.
  WRITE total.
sia*
"""
print(els(program))             # 42
```

For multi-block programs, share state with `env = els.make_env()` and call
`els(block, env)`. An interactive prompt is available through `els.repl()`.

## Optional dependencies

| Extra | Installs | Enables |
|---|---|---|
| `torch` | PyTorch | Trainable layers, CUDA acceleration |
| `qasm` | openqasm3[parser] | OpenQASM 3 import and export |
| `plot` | Matplotlib | `draw()` and `plot()` |
| `scipy` | SciPy | Sparse observable matrices |
| `interop` | Qiskit, Qiskit Aer, PennyLane | Adapters |
| `full` | torch, qasm, plot, scipy | Everything except the adapters |
| `all` | Everything above | Everything |

A feature whose dependency is missing raises an `ImportError` naming the
package to install. `hdqs.capabilities()` reports what is available.

## Conventions

- Qubit 0 is the most significant bit: in `'01'`, qubit 0 is `0`.
  Qiskit uses the opposite order; the adapters convert automatically.
- `measure()` collapses the state; `sample()` and `probabilities()` do not.
- Memory grows exponentially with qubit count in the statevector and
  density-matrix modes. A default 1 GiB budget refuses allocations that would
  exceed it.

## Licensing

sia-script is proprietary software of Sia Software Innovations Private Limited,
with one exception: the quantum simulator, `sia/hdqs_engine.py`, is released
under the MIT License. See [LICENSE.md](LICENSE.md) for the full terms of both.

## Citation

If you use the CRIA interference-accessibility tools in research, please cite:

> Seshabattara Venkata, N. S. D. N. *Cardinality-Resolved Interference
> Accessibility in Multipartite Quantum Systems.* Zenodo (2026).
> https://doi.org/10.5281/zenodo.23180889

## Support

Sia Software Innovations Private Limited  
Email: info@siasoftwareinnovations.com  
Website: https://www.siasoftwareinnovations.com
