qomputing 0.1.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.
Files changed (33) hide show
  1. qomputing-0.1.3/PKG-INFO +360 -0
  2. qomputing-0.1.3/README.md +337 -0
  3. qomputing-0.1.3/examples/library_usage.py +45 -0
  4. qomputing-0.1.3/pyproject.toml +43 -0
  5. qomputing-0.1.3/qomputing/__init__.py +27 -0
  6. qomputing-0.1.3/qomputing/backend.py +64 -0
  7. qomputing-0.1.3/qomputing/circuit.py +266 -0
  8. qomputing-0.1.3/qomputing/circuit_builders.py +185 -0
  9. qomputing-0.1.3/qomputing/cli.py +121 -0
  10. qomputing-0.1.3/qomputing/engine/__init__.py +7 -0
  11. qomputing-0.1.3/qomputing/engine/measurements.py +43 -0
  12. qomputing-0.1.3/qomputing/engine/registry.py +32 -0
  13. qomputing-0.1.3/qomputing/engine/result.py +31 -0
  14. qomputing-0.1.3/qomputing/engine/statevector.py +54 -0
  15. qomputing-0.1.3/qomputing/examples/__init__.py +2 -0
  16. qomputing-0.1.3/qomputing/examples/demo_circuits.py +126 -0
  17. qomputing-0.1.3/qomputing/gates/__init__.py +27 -0
  18. qomputing-0.1.3/qomputing/gates/multi_qubit.py +60 -0
  19. qomputing-0.1.3/qomputing/gates/single_qubit.py +204 -0
  20. qomputing-0.1.3/qomputing/gates/two_qubit.py +196 -0
  21. qomputing-0.1.3/qomputing/linalg.py +62 -0
  22. qomputing-0.1.3/qomputing/run.py +85 -0
  23. qomputing-0.1.3/qomputing/simulator.py +6 -0
  24. qomputing-0.1.3/qomputing/xeb.py +77 -0
  25. qomputing-0.1.3/qomputing.egg-info/PKG-INFO +360 -0
  26. qomputing-0.1.3/qomputing.egg-info/SOURCES.txt +31 -0
  27. qomputing-0.1.3/qomputing.egg-info/dependency_links.txt +1 -0
  28. qomputing-0.1.3/qomputing.egg-info/entry_points.txt +2 -0
  29. qomputing-0.1.3/qomputing.egg-info/requires.txt +8 -0
  30. qomputing-0.1.3/qomputing.egg-info/top_level.txt +7 -0
  31. qomputing-0.1.3/setup.cfg +4 -0
  32. qomputing-0.1.3/tests/test_parity.py +125 -0
  33. qomputing-0.1.3/tools/cirq_comparison.py +419 -0
@@ -0,0 +1,360 @@
1
+ Metadata-Version: 2.4
2
+ Name: qomputing
3
+ Version: 0.1.3
4
+ Summary: Quantum computing state vector simulator with linear XEB benchmarking
5
+ Author: Qomputing Simulator Maintainers
6
+ License-Expression: MIT
7
+ Keywords: quantum,simulation,state vector,xeb
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Scientific/Engineering :: Physics
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: numpy<3.0,>=1.24
18
+ Requires-Dist: cirq<2.0,>=1.6
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest>=7.0; extra == "dev"
21
+ Provides-Extra: build
22
+ Requires-Dist: build>=1.0; extra == "build"
23
+
24
+ # Qomputing Simulator
25
+
26
+ Qomputing Simulator is a lightweight, pure Python toolkit for simulating quantum state vectors and running linear cross-entropy benchmarking (XEB) experiments end-to-end.
27
+
28
+ **Install:** `pip install qomputing`
29
+ (Or from source: `pip install .` in the repo, or `pip install git+https://github.com/d2Anubis/state-vector-simulator.git`)
30
+
31
+ ---
32
+
33
+ ## Use it after install
34
+
35
+ Once `pip install qomputing` is done, people can use it in two ways.
36
+
37
+ ### 1. From the command line (CLI)
38
+
39
+ **Run these in a terminal (bash/shell), not inside Python or IPython.**
40
+
41
+ ```bash
42
+ # Random circuit + XEB benchmark
43
+ qomputing-sim random-circuit --qubits 3 --depth 5 --shots 1000
44
+
45
+ # Simulate a circuit from a JSON file (use a real path to your circuit file)
46
+ qomputing-sim simulate --circuit circuits/example.json --shots 512 --seed 42
47
+ ```
48
+
49
+ ### 2. From Python (library)
50
+
51
+ **Run this code in a Python script or notebook (e.g. IPython/Jupyter).**
52
+
53
+ **Backend API (recommended):** Import `QomputingSimulator`, get a backend, then `backend.run(qc, shots=...)` and `result.get_counts()`:
54
+
55
+ ```python
56
+ from qomputing import QomputingSimulator, QuantumCircuit
57
+
58
+ backend = QomputingSimulator.get_backend("state_vector")
59
+
60
+ # Circuit with 4 qubits and 4 classical bits; measure qubits 0,1,2 into classical 0,1,2
61
+ qc = QuantumCircuit(4, 4)
62
+ qc.h(0).cx(0, 1)
63
+ qc.measure(range(3), range(3))
64
+
65
+ result = backend.run(qc, shots=1024)
66
+ counts = result.get_counts()
67
+ print(counts)
68
+ # Optional: result.get_statevector(), result.get_probabilities()
69
+ ```
70
+
71
+ **Simple API (no backend):** Build a circuit and use `run()` for a quick result:
72
+
73
+ ```python
74
+ from qomputing import run, QuantumCircuit, run_xeb, random_circuit
75
+
76
+ circuit = QuantumCircuit(2)
77
+ circuit.h(0).cx(0, 1) # Bell state
78
+ result = run(circuit, shots=1000, seed=42)
79
+ print(result.final_state, result.probabilities, result.counts)
80
+
81
+ circuit = random_circuit(num_qubits=3, depth=5, seed=7)
82
+ xeb = run_xeb(circuit, shots=1000, seed=7)
83
+ print(xeb.fidelity, xeb.sample_probabilities)
84
+ ```
85
+
86
+ ### 3. Run on Google Colab
87
+
88
+ 1. Open [Google Colab](https://colab.research.google.com/) and create a new notebook.
89
+ 2. **First cell** (install):
90
+ ```python
91
+ !pip install qomputing -q
92
+ ```
93
+ 3. **Next cell** (use the library; the CLI is for terminals only):
94
+ ```python
95
+ from qomputing import QomputingSimulator, QuantumCircuit
96
+
97
+ backend = QomputingSimulator.get_backend("state_vector")
98
+ qc = QuantumCircuit(2)
99
+ qc.h(0).cx(0, 1)
100
+ result = backend.run(qc, shots=1000, seed=42)
101
+ print("Counts:", result.get_counts())
102
+ ```
103
+
104
+ ---
105
+
106
+ ## How people install (step-by-step)
107
+
108
+ 1. **Install**
109
+ ```bash
110
+ pip install qomputing
111
+ ```
112
+ Optional: use a virtual environment first (`python3 -m venv .venv` then `source .venv/bin/activate` on macOS/Linux).
113
+
114
+ 2. **Optional extras:** `pip install qomputing[dev]` (adds pytest), `pip install qomputing[build]` (adds build tool).
115
+
116
+ ---
117
+
118
+ ## Where you push and how to publish (maintainer)
119
+
120
+ ### 1. Push code to GitHub (or GitLab, etc.)
121
+
122
+ - **Where:** Your Git remote (e.g. GitHub).
123
+ - Create a repo if needed, then from your project folder:
124
+
125
+ ```bash
126
+ git remote add origin https://github.com/YOUR_USERNAME/qomputing.git
127
+ git add .
128
+ git commit -m "Rename to qomputing"
129
+ git push -u origin main
130
+ ```
131
+
132
+ **GitHub permission (browser redirect + passcode):** If `git push` asks for login, use GitHub’s web flow so you’re redirected to GitHub to approve:
133
+
134
+ ```bash
135
+ ./scripts/github-auth.sh
136
+ ```
137
+
138
+ That script uses the [GitHub CLI](https://cli.github.com/) (`gh`). It will open your browser → you log in on GitHub → GitHub shows a one-time code → you paste the code back in the terminal. After that, `git push origin main` works without a password.
139
+ If you don’t have `gh`: install it (e.g. `brew install gh` on macOS), then run `./scripts/github-auth.sh` again.
140
+
141
+ - People can clone and install from source: `git clone https://github.com/YOUR_USERNAME/qomputing.git` then `pip install .` in the repo.
142
+
143
+ ### 2. Publish to PyPI (so anyone can `pip install qomputing`)
144
+
145
+ PyPI is the default place pip installs from. Steps:
146
+
147
+ 1. **Create accounts**
148
+ - [pypi.org](https://pypi.org/) (for real releases)
149
+ - [test.pypi.org](https://test.pypi.org/) (optional, for testing uploads)
150
+
151
+ 2. **Install build tools**
152
+ ```bash
153
+ pip install build twine
154
+ ```
155
+
156
+ 3. **Build the package**
157
+ ```bash
158
+ cd /path/to/simulator
159
+ python -m build
160
+ ```
161
+ This creates `dist/qomputing-0.1.0-py3-none-any.whl` and `dist/qomputing-0.1.0.tar.gz`.
162
+
163
+ 4. **Upload to Test PyPI (optional)**
164
+ ```bash
165
+ twine upload --repository testpypi dist/*
166
+ ```
167
+ When prompted, use your Test PyPI username and password (or token). Test install with:
168
+ `pip install --index-url https://test.pypi.org/simple/ qomputing`
169
+
170
+ 5. **Upload to PyPI (real release)**
171
+ ```bash
172
+ twine upload dist/*
173
+ ```
174
+ Use your PyPI username and password, or an [API token](https://pypi.org/manage/account/token/).
175
+
176
+ 6. **Later releases:** Bump `version` in `pyproject.toml`, run `python -m build` again, then `twine upload dist/*`. You cannot reuse the same version number on PyPI.
177
+
178
+ After step 5, anyone can run `pip install qomputing` without cloning the repo.
179
+
180
+ ---
181
+
182
+ ## Quick Start (development / from source)
183
+
184
+ ### Install from source (development or local)
185
+
186
+ ```bash
187
+ git clone https://github.com/YOUR_USERNAME/qomputing.git
188
+ cd qomputing
189
+ python3 -m venv .venv
190
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
191
+ pip install --upgrade pip
192
+ pip install -e ".[dev]"
193
+ ```
194
+
195
+ - `pip install -e .` installs the simulator and Cirq; the optional `[dev]` extra adds `pytest`.
196
+ - To install as a normal (non-editable) library: `pip install .` (no `-e`).
197
+
198
+ ### Build wheels only (for offline or custom install)
199
+
200
+ From the project root:
201
+
202
+ ```bash
203
+ pip install build
204
+ python -m build
205
+ ```
206
+
207
+ Install the wheel anywhere: `pip install dist/qomputing-*.whl`
208
+
209
+ ### Offline / no wheel build
210
+
211
+ If you cannot use pip to fetch the package:
212
+
213
+ ```bash
214
+ export PYTHONPATH="$PWD"
215
+ python -m qomputing.cli random-circuit --qubits 3 --depth 5 --shots 1000
216
+ ```
217
+
218
+ ## Repository Layout
219
+
220
+ ```
221
+ qomputing/
222
+ ├── circuit.py # QuantumCircuit builder, JSON (de)serialization
223
+ ├── gates/ # Single-, two-, and multi-qubit gate handlers
224
+ ├── engine/ # StateVectorSimulator core, result dataclass, sampling
225
+ ├── linalg.py # Shared tensor/linear algebra helpers
226
+ ├── cli.py # CLI entry point (`qomputing-sim`)
227
+ ├── xeb.py # Linear XEB fidelity helpers
228
+ ├── tools/cirq_comparison.py # Parity harness against Cirq
229
+ └── tests/ # Pytest parity checks for representative gates
230
+ ```
231
+
232
+ ## CLI Usage
233
+
234
+ - Run a random-circuit XEB benchmark:
235
+
236
+ ```bash
237
+ qomputing-sim random-circuit --qubits 3 --depth 5 --shots 1000
238
+ ```
239
+
240
+ Use `--single-qubit-gates/--two-qubit-gates/--multi-qubit-gates` to override the default gate pools (`["h","rx","ry","rz","s","t"]`, `["cx","cz","swap"]`, none).
241
+
242
+ - Simulate a circuit defined in JSON:
243
+
244
+ ```bash
245
+ qomputing-sim simulate --circuit circuits/example.json --shots 512 --seed 123
246
+ ```
247
+
248
+ ## Library usage
249
+
250
+ You can run the simulator from Python:
251
+
252
+ ```python
253
+ from qomputing import (
254
+ QuantumCircuit,
255
+ load_circuit,
256
+ run,
257
+ run_xeb,
258
+ random_circuit,
259
+ )
260
+
261
+ # Build a circuit and run (state vector only if shots=0)
262
+ circuit = QuantumCircuit(2)
263
+ circuit.h(0).cx(0, 1)
264
+ result = run(circuit, shots=1000, seed=42)
265
+ print(result.final_state, result.probabilities, result.counts)
266
+
267
+ # Load from JSON
268
+ circuit = load_circuit("circuits/example.json")
269
+ result = run(circuit, shots=512)
270
+
271
+ # Random circuit and linear XEB
272
+ circuit = random_circuit(num_qubits=3, depth=5, seed=7)
273
+ xeb_result = run_xeb(circuit, shots=1000, seed=7)
274
+ print(xeb_result.fidelity, xeb_result.sample_probabilities)
275
+ ```
276
+
277
+ See `examples/library_usage.py` for a runnable example.
278
+
279
+ ## Example Circuits
280
+
281
+ Ready-made demonstrations live in `qomputing/examples/demo_circuits.py`. After activating your environment, run them as a module from the project root:
282
+
283
+ ```bash
284
+ python -m qomputing.examples.demo_circuits --example bell
285
+ python -m qomputing.examples.demo_circuits --example deutsch-jozsa --oracle balanced --shots 1024 --seed 7
286
+ python -m qomputing.examples.demo_circuits --example ghz --shots 1000 --seed 123
287
+ ```
288
+
289
+ Each command prints the final state vector, measurement probabilities, and (when `--shots > 0`) sampled counts. Use `--example bell|deutsch-jozsa|ghz` and, for Deutsch–Jozsa, pick `--oracle constant|balanced`.
290
+
291
+ ## Circuit Specification
292
+
293
+ Circuits are defined as JSON documents of the following structure:
294
+
295
+ ```json
296
+ {
297
+ "num_qubits": 2,
298
+ "gates": [
299
+ {"name": "h", "targets": [0]},
300
+ {"name": "cx", "controls": [0], "targets": [1]},
301
+ {"name": "rz", "targets": [0], "params": {"theta": 1.5708}}
302
+ ]
303
+ }
304
+ ```
305
+
306
+ Supported gate names (and their parameters):
307
+
308
+ - Single-qubit: `id`, `x`, `y`, `z`, `h`, `s`, `sdg`, `t`, `tdg`, `sx`, `sxdg`, `rx(θ)`, `ry(θ)`, `rz(θ)`, `u1(λ)`, `u2(φ,λ)`, `u3(θ,φ,λ)`
309
+ - Two-qubit: `cx`, `cy`, `cz`, `cp(φ)`, `csx`, `swap`, `iswap`, `sqrtiswap`, `rxx(θ)`, `ryy(θ)`, `rzz(θ)`
310
+ - Multi-qubit: `ccx`, `ccz`, `cswap`
311
+
312
+ ## Testing & Validation
313
+
314
+ 1. **Unit tests (Pytest)**
315
+
316
+ ```bash
317
+ pytest
318
+ ```
319
+
320
+ The tests execute representative single-, two-, and three-qubit circuits and assert that our simulator matches Cirq to ≤1e-7 after global phase alignment.
321
+
322
+ 2. **Parity harness against Cirq**
323
+
324
+ ```bash
325
+ export PYTHONPATH="$PWD" # only needed if not pip-installed
326
+ python tools/cirq_comparison.py \
327
+ --min-qubits 1 --max-qubits 5 \
328
+ --depths 3 5 \
329
+ --circuits-per-config 3 \
330
+ --shots 256 \
331
+ --seed 7
332
+ ```
333
+
334
+ The summary at the end reports maximum amplitude/probability/XEB deviations. Pass `--help` to explore gate-pool overrides or larger qubit ranges. For qubits ≥20, allocate ample RAM (≥16 GB) and expect runtimes of multiple minutes.
335
+
336
+ 3. **Large-scale sweep (optional)**
337
+
338
+ ```bash
339
+ python tools/cirq_comparison.py \
340
+ --min-qubits 5 --max-qubits 25 \
341
+ --depths 5 \
342
+ --circuits-per-config 1 \
343
+ --shots 0 \
344
+ --seed 42 \
345
+ > comparison_results_25q.txt
346
+ ```
347
+
348
+ This tests state-vector parity without sampling. Inspect the resulting file for per-configuration error logs and the summary block.
349
+
350
+ ## Development Workflow
351
+
352
+ - Run `pytest` before committing.
353
+ - Use `qomputing-sim random-circuit` to generate sample workloads or JSONs for reproducible scenarios.
354
+ - Benchmark changes with `tools/cirq_comparison.py` to confirm parity with Cirq remains within tolerance.
355
+ - Generated artifacts (`comparison_results*.txt`, `__pycache__/`, virtual environments) are ignored via `.gitignore`.
356
+
357
+ ## License
358
+
359
+ MIT
360
+
@@ -0,0 +1,337 @@
1
+ # Qomputing Simulator
2
+
3
+ Qomputing Simulator is a lightweight, pure Python toolkit for simulating quantum state vectors and running linear cross-entropy benchmarking (XEB) experiments end-to-end.
4
+
5
+ **Install:** `pip install qomputing`
6
+ (Or from source: `pip install .` in the repo, or `pip install git+https://github.com/d2Anubis/state-vector-simulator.git`)
7
+
8
+ ---
9
+
10
+ ## Use it after install
11
+
12
+ Once `pip install qomputing` is done, people can use it in two ways.
13
+
14
+ ### 1. From the command line (CLI)
15
+
16
+ **Run these in a terminal (bash/shell), not inside Python or IPython.**
17
+
18
+ ```bash
19
+ # Random circuit + XEB benchmark
20
+ qomputing-sim random-circuit --qubits 3 --depth 5 --shots 1000
21
+
22
+ # Simulate a circuit from a JSON file (use a real path to your circuit file)
23
+ qomputing-sim simulate --circuit circuits/example.json --shots 512 --seed 42
24
+ ```
25
+
26
+ ### 2. From Python (library)
27
+
28
+ **Run this code in a Python script or notebook (e.g. IPython/Jupyter).**
29
+
30
+ **Backend API (recommended):** Import `QomputingSimulator`, get a backend, then `backend.run(qc, shots=...)` and `result.get_counts()`:
31
+
32
+ ```python
33
+ from qomputing import QomputingSimulator, QuantumCircuit
34
+
35
+ backend = QomputingSimulator.get_backend("state_vector")
36
+
37
+ # Circuit with 4 qubits and 4 classical bits; measure qubits 0,1,2 into classical 0,1,2
38
+ qc = QuantumCircuit(4, 4)
39
+ qc.h(0).cx(0, 1)
40
+ qc.measure(range(3), range(3))
41
+
42
+ result = backend.run(qc, shots=1024)
43
+ counts = result.get_counts()
44
+ print(counts)
45
+ # Optional: result.get_statevector(), result.get_probabilities()
46
+ ```
47
+
48
+ **Simple API (no backend):** Build a circuit and use `run()` for a quick result:
49
+
50
+ ```python
51
+ from qomputing import run, QuantumCircuit, run_xeb, random_circuit
52
+
53
+ circuit = QuantumCircuit(2)
54
+ circuit.h(0).cx(0, 1) # Bell state
55
+ result = run(circuit, shots=1000, seed=42)
56
+ print(result.final_state, result.probabilities, result.counts)
57
+
58
+ circuit = random_circuit(num_qubits=3, depth=5, seed=7)
59
+ xeb = run_xeb(circuit, shots=1000, seed=7)
60
+ print(xeb.fidelity, xeb.sample_probabilities)
61
+ ```
62
+
63
+ ### 3. Run on Google Colab
64
+
65
+ 1. Open [Google Colab](https://colab.research.google.com/) and create a new notebook.
66
+ 2. **First cell** (install):
67
+ ```python
68
+ !pip install qomputing -q
69
+ ```
70
+ 3. **Next cell** (use the library; the CLI is for terminals only):
71
+ ```python
72
+ from qomputing import QomputingSimulator, QuantumCircuit
73
+
74
+ backend = QomputingSimulator.get_backend("state_vector")
75
+ qc = QuantumCircuit(2)
76
+ qc.h(0).cx(0, 1)
77
+ result = backend.run(qc, shots=1000, seed=42)
78
+ print("Counts:", result.get_counts())
79
+ ```
80
+
81
+ ---
82
+
83
+ ## How people install (step-by-step)
84
+
85
+ 1. **Install**
86
+ ```bash
87
+ pip install qomputing
88
+ ```
89
+ Optional: use a virtual environment first (`python3 -m venv .venv` then `source .venv/bin/activate` on macOS/Linux).
90
+
91
+ 2. **Optional extras:** `pip install qomputing[dev]` (adds pytest), `pip install qomputing[build]` (adds build tool).
92
+
93
+ ---
94
+
95
+ ## Where you push and how to publish (maintainer)
96
+
97
+ ### 1. Push code to GitHub (or GitLab, etc.)
98
+
99
+ - **Where:** Your Git remote (e.g. GitHub).
100
+ - Create a repo if needed, then from your project folder:
101
+
102
+ ```bash
103
+ git remote add origin https://github.com/YOUR_USERNAME/qomputing.git
104
+ git add .
105
+ git commit -m "Rename to qomputing"
106
+ git push -u origin main
107
+ ```
108
+
109
+ **GitHub permission (browser redirect + passcode):** If `git push` asks for login, use GitHub’s web flow so you’re redirected to GitHub to approve:
110
+
111
+ ```bash
112
+ ./scripts/github-auth.sh
113
+ ```
114
+
115
+ That script uses the [GitHub CLI](https://cli.github.com/) (`gh`). It will open your browser → you log in on GitHub → GitHub shows a one-time code → you paste the code back in the terminal. After that, `git push origin main` works without a password.
116
+ If you don’t have `gh`: install it (e.g. `brew install gh` on macOS), then run `./scripts/github-auth.sh` again.
117
+
118
+ - People can clone and install from source: `git clone https://github.com/YOUR_USERNAME/qomputing.git` then `pip install .` in the repo.
119
+
120
+ ### 2. Publish to PyPI (so anyone can `pip install qomputing`)
121
+
122
+ PyPI is the default place pip installs from. Steps:
123
+
124
+ 1. **Create accounts**
125
+ - [pypi.org](https://pypi.org/) (for real releases)
126
+ - [test.pypi.org](https://test.pypi.org/) (optional, for testing uploads)
127
+
128
+ 2. **Install build tools**
129
+ ```bash
130
+ pip install build twine
131
+ ```
132
+
133
+ 3. **Build the package**
134
+ ```bash
135
+ cd /path/to/simulator
136
+ python -m build
137
+ ```
138
+ This creates `dist/qomputing-0.1.0-py3-none-any.whl` and `dist/qomputing-0.1.0.tar.gz`.
139
+
140
+ 4. **Upload to Test PyPI (optional)**
141
+ ```bash
142
+ twine upload --repository testpypi dist/*
143
+ ```
144
+ When prompted, use your Test PyPI username and password (or token). Test install with:
145
+ `pip install --index-url https://test.pypi.org/simple/ qomputing`
146
+
147
+ 5. **Upload to PyPI (real release)**
148
+ ```bash
149
+ twine upload dist/*
150
+ ```
151
+ Use your PyPI username and password, or an [API token](https://pypi.org/manage/account/token/).
152
+
153
+ 6. **Later releases:** Bump `version` in `pyproject.toml`, run `python -m build` again, then `twine upload dist/*`. You cannot reuse the same version number on PyPI.
154
+
155
+ After step 5, anyone can run `pip install qomputing` without cloning the repo.
156
+
157
+ ---
158
+
159
+ ## Quick Start (development / from source)
160
+
161
+ ### Install from source (development or local)
162
+
163
+ ```bash
164
+ git clone https://github.com/YOUR_USERNAME/qomputing.git
165
+ cd qomputing
166
+ python3 -m venv .venv
167
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
168
+ pip install --upgrade pip
169
+ pip install -e ".[dev]"
170
+ ```
171
+
172
+ - `pip install -e .` installs the simulator and Cirq; the optional `[dev]` extra adds `pytest`.
173
+ - To install as a normal (non-editable) library: `pip install .` (no `-e`).
174
+
175
+ ### Build wheels only (for offline or custom install)
176
+
177
+ From the project root:
178
+
179
+ ```bash
180
+ pip install build
181
+ python -m build
182
+ ```
183
+
184
+ Install the wheel anywhere: `pip install dist/qomputing-*.whl`
185
+
186
+ ### Offline / no wheel build
187
+
188
+ If you cannot use pip to fetch the package:
189
+
190
+ ```bash
191
+ export PYTHONPATH="$PWD"
192
+ python -m qomputing.cli random-circuit --qubits 3 --depth 5 --shots 1000
193
+ ```
194
+
195
+ ## Repository Layout
196
+
197
+ ```
198
+ qomputing/
199
+ ├── circuit.py # QuantumCircuit builder, JSON (de)serialization
200
+ ├── gates/ # Single-, two-, and multi-qubit gate handlers
201
+ ├── engine/ # StateVectorSimulator core, result dataclass, sampling
202
+ ├── linalg.py # Shared tensor/linear algebra helpers
203
+ ├── cli.py # CLI entry point (`qomputing-sim`)
204
+ ├── xeb.py # Linear XEB fidelity helpers
205
+ ├── tools/cirq_comparison.py # Parity harness against Cirq
206
+ └── tests/ # Pytest parity checks for representative gates
207
+ ```
208
+
209
+ ## CLI Usage
210
+
211
+ - Run a random-circuit XEB benchmark:
212
+
213
+ ```bash
214
+ qomputing-sim random-circuit --qubits 3 --depth 5 --shots 1000
215
+ ```
216
+
217
+ Use `--single-qubit-gates/--two-qubit-gates/--multi-qubit-gates` to override the default gate pools (`["h","rx","ry","rz","s","t"]`, `["cx","cz","swap"]`, none).
218
+
219
+ - Simulate a circuit defined in JSON:
220
+
221
+ ```bash
222
+ qomputing-sim simulate --circuit circuits/example.json --shots 512 --seed 123
223
+ ```
224
+
225
+ ## Library usage
226
+
227
+ You can run the simulator from Python:
228
+
229
+ ```python
230
+ from qomputing import (
231
+ QuantumCircuit,
232
+ load_circuit,
233
+ run,
234
+ run_xeb,
235
+ random_circuit,
236
+ )
237
+
238
+ # Build a circuit and run (state vector only if shots=0)
239
+ circuit = QuantumCircuit(2)
240
+ circuit.h(0).cx(0, 1)
241
+ result = run(circuit, shots=1000, seed=42)
242
+ print(result.final_state, result.probabilities, result.counts)
243
+
244
+ # Load from JSON
245
+ circuit = load_circuit("circuits/example.json")
246
+ result = run(circuit, shots=512)
247
+
248
+ # Random circuit and linear XEB
249
+ circuit = random_circuit(num_qubits=3, depth=5, seed=7)
250
+ xeb_result = run_xeb(circuit, shots=1000, seed=7)
251
+ print(xeb_result.fidelity, xeb_result.sample_probabilities)
252
+ ```
253
+
254
+ See `examples/library_usage.py` for a runnable example.
255
+
256
+ ## Example Circuits
257
+
258
+ Ready-made demonstrations live in `qomputing/examples/demo_circuits.py`. After activating your environment, run them as a module from the project root:
259
+
260
+ ```bash
261
+ python -m qomputing.examples.demo_circuits --example bell
262
+ python -m qomputing.examples.demo_circuits --example deutsch-jozsa --oracle balanced --shots 1024 --seed 7
263
+ python -m qomputing.examples.demo_circuits --example ghz --shots 1000 --seed 123
264
+ ```
265
+
266
+ Each command prints the final state vector, measurement probabilities, and (when `--shots > 0`) sampled counts. Use `--example bell|deutsch-jozsa|ghz` and, for Deutsch–Jozsa, pick `--oracle constant|balanced`.
267
+
268
+ ## Circuit Specification
269
+
270
+ Circuits are defined as JSON documents of the following structure:
271
+
272
+ ```json
273
+ {
274
+ "num_qubits": 2,
275
+ "gates": [
276
+ {"name": "h", "targets": [0]},
277
+ {"name": "cx", "controls": [0], "targets": [1]},
278
+ {"name": "rz", "targets": [0], "params": {"theta": 1.5708}}
279
+ ]
280
+ }
281
+ ```
282
+
283
+ Supported gate names (and their parameters):
284
+
285
+ - Single-qubit: `id`, `x`, `y`, `z`, `h`, `s`, `sdg`, `t`, `tdg`, `sx`, `sxdg`, `rx(θ)`, `ry(θ)`, `rz(θ)`, `u1(λ)`, `u2(φ,λ)`, `u3(θ,φ,λ)`
286
+ - Two-qubit: `cx`, `cy`, `cz`, `cp(φ)`, `csx`, `swap`, `iswap`, `sqrtiswap`, `rxx(θ)`, `ryy(θ)`, `rzz(θ)`
287
+ - Multi-qubit: `ccx`, `ccz`, `cswap`
288
+
289
+ ## Testing & Validation
290
+
291
+ 1. **Unit tests (Pytest)**
292
+
293
+ ```bash
294
+ pytest
295
+ ```
296
+
297
+ The tests execute representative single-, two-, and three-qubit circuits and assert that our simulator matches Cirq to ≤1e-7 after global phase alignment.
298
+
299
+ 2. **Parity harness against Cirq**
300
+
301
+ ```bash
302
+ export PYTHONPATH="$PWD" # only needed if not pip-installed
303
+ python tools/cirq_comparison.py \
304
+ --min-qubits 1 --max-qubits 5 \
305
+ --depths 3 5 \
306
+ --circuits-per-config 3 \
307
+ --shots 256 \
308
+ --seed 7
309
+ ```
310
+
311
+ The summary at the end reports maximum amplitude/probability/XEB deviations. Pass `--help` to explore gate-pool overrides or larger qubit ranges. For qubits ≥20, allocate ample RAM (≥16 GB) and expect runtimes of multiple minutes.
312
+
313
+ 3. **Large-scale sweep (optional)**
314
+
315
+ ```bash
316
+ python tools/cirq_comparison.py \
317
+ --min-qubits 5 --max-qubits 25 \
318
+ --depths 5 \
319
+ --circuits-per-config 1 \
320
+ --shots 0 \
321
+ --seed 42 \
322
+ > comparison_results_25q.txt
323
+ ```
324
+
325
+ This tests state-vector parity without sampling. Inspect the resulting file for per-configuration error logs and the summary block.
326
+
327
+ ## Development Workflow
328
+
329
+ - Run `pytest` before committing.
330
+ - Use `qomputing-sim random-circuit` to generate sample workloads or JSONs for reproducible scenarios.
331
+ - Benchmark changes with `tools/cirq_comparison.py` to confirm parity with Cirq remains within tolerance.
332
+ - Generated artifacts (`comparison_results*.txt`, `__pycache__/`, virtual environments) are ignored via `.gitignore`.
333
+
334
+ ## License
335
+
336
+ MIT
337
+