quantum-cq 0.1.0__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.
- quantum_cq-0.1.0/LICENSE +21 -0
- quantum_cq-0.1.0/MANIFEST.in +19 -0
- quantum_cq-0.1.0/PKG-INFO +168 -0
- quantum_cq-0.1.0/README.md +119 -0
- quantum_cq-0.1.0/pyproject.toml +66 -0
- quantum_cq-0.1.0/setup.cfg +4 -0
- quantum_cq-0.1.0/setup.py +16 -0
- quantum_cq-0.1.0/src/quantum_cq/__init__.py +166 -0
- quantum_cq-0.1.0/src/quantum_cq/_algorithms/__init__.py +0 -0
- quantum_cq-0.1.0/src/quantum_cq/_algorithms/standard.py +607 -0
- quantum_cq-0.1.0/src/quantum_cq/_circuits/__init__.py +0 -0
- quantum_cq-0.1.0/src/quantum_cq/_circuits/adapters.py +141 -0
- quantum_cq-0.1.0/src/quantum_cq/_circuits/compact.py +650 -0
- quantum_cq-0.1.0/src/quantum_cq/_circuits/oracles.py +214 -0
- quantum_cq-0.1.0/src/quantum_cq/_circuits/primitives.py +244 -0
- quantum_cq-0.1.0/src/quantum_cq/_core/__init__.py +0 -0
- quantum_cq-0.1.0/src/quantum_cq/_core/data.py +12 -0
- quantum_cq-0.1.0/src/quantum_cq/_core/environment.py +122 -0
- quantum_cq-0.1.0/src/quantum_cq/_core/facade.py +658 -0
- quantum_cq-0.1.0/src/quantum_cq/_core/handlers.py +275 -0
- quantum_cq-0.1.0/src/quantum_cq/_core/interfaces.py +291 -0
- quantum_cq-0.1.0/src/quantum_cq/_core/logging_config.py +41 -0
- quantum_cq-0.1.0/src/quantum_cq/_core/metrics.py +134 -0
- quantum_cq-0.1.0/src/quantum_cq/_core/results.py +111 -0
- quantum_cq-0.1.0/src/quantum_cq/_core/selectors.py +133 -0
- quantum_cq-0.1.0/src/quantum_cq/_core/settings.py +191 -0
- quantum_cq-0.1.0/src/quantum_cq/_encodings/__init__.py +0 -0
- quantum_cq-0.1.0/src/quantum_cq/_encodings/state.py +530 -0
- quantum_cq-0.1.0/src/quantum_cq/_navigation/__init__.py +0 -0
- quantum_cq-0.1.0/src/quantum_cq/_navigation/memory.py +559 -0
- quantum_cq-0.1.0/src/quantum_cq/_navigation/walks.py +113 -0
- quantum_cq-0.1.0/src/quantum_cq/_runtime/__init__.py +0 -0
- quantum_cq-0.1.0/src/quantum_cq/_runtime/config.py +33 -0
- quantum_cq-0.1.0/src/quantum_cq/_runtime/experiment.py +599 -0
- quantum_cq-0.1.0/src/quantum_cq/_runtime/pipeline.py +822 -0
- quantum_cq-0.1.0/src/quantum_cq/_runtime/runtime.py +511 -0
- quantum_cq-0.1.0/src/quantum_cq/_tools/__init__.py +0 -0
- quantum_cq-0.1.0/src/quantum_cq/_tools/cq_embedded.py +911 -0
- quantum_cq-0.1.0/src/quantum_cq/adapters.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/algorithms.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/compact.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/config.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/core.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/cq_embedded.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/data.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/encodings.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/environment.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/experiment.py +10 -0
- quantum_cq-0.1.0/src/quantum_cq/handlers.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/interfaces.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/logging_config.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/metrics.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/navigation.py +2 -0
- quantum_cq-0.1.0/src/quantum_cq/oracles.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/pipeline.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/primitives.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/results.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/runtime.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/selectors.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/settings.py +9 -0
- quantum_cq-0.1.0/src/quantum_cq/walks.py +9 -0
- quantum_cq-0.1.0/tests/test_algorithms.py +276 -0
- quantum_cq-0.1.0/tests/test_circuit_layer.py +103 -0
- quantum_cq-0.1.0/tests/test_deutsch_algorithm.py +108 -0
- quantum_cq-0.1.0/tests/test_encodings.py +326 -0
- quantum_cq-0.1.0/tests/test_experiment_pipeline.py +338 -0
- quantum_cq-0.1.0/tests/test_handlers.py +163 -0
- quantum_cq-0.1.0/tests/test_ibm_real_smoke.py +75 -0
- quantum_cq-0.1.0/tests/test_import_contract.py +114 -0
- quantum_cq-0.1.0/tests/test_metrics.py +58 -0
- quantum_cq-0.1.0/tests/test_navigation_addressed.py +123 -0
- quantum_cq-0.1.0/tests/test_navigation_graph.py +84 -0
- quantum_cq-0.1.0/tests/test_navigation_selector.py +60 -0
- quantum_cq-0.1.0/tests/test_operator_layer.py +116 -0
- quantum_cq-0.1.0/tests/test_oracle_operator_algorithms.py +112 -0
- quantum_cq-0.1.0/tests/test_oracles_primitives.py +169 -0
- quantum_cq-0.1.0/tests/test_pipeline.py +200 -0
- quantum_cq-0.1.0/tests/test_project_structure.py +547 -0
- quantum_cq-0.1.0/tests/test_quantum_walk_mvp.py +51 -0
- quantum_cq-0.1.0/tests/test_selector.py +128 -0
- quantum_cq-0.1.0/tests/test_simple_api.py +146 -0
- quantum_cq-0.1.0/tests/test_tdd_contract_placeholders.py +14 -0
quantum_cq-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 José Yrikes de Oliveira Feitosa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
prune .pytest_cache
|
|
2
|
+
prune .vscode
|
|
3
|
+
prune logs
|
|
4
|
+
prune results
|
|
5
|
+
prune notebooks/experiments
|
|
6
|
+
prune build
|
|
7
|
+
prune dist
|
|
8
|
+
prune src/quantum_cq.egg-info
|
|
9
|
+
recursive-exclude src/quantum_cq.egg-info *
|
|
10
|
+
exclude src/quantum_cq.egg-info/SOURCES.txt
|
|
11
|
+
global-exclude __pycache__
|
|
12
|
+
global-exclude *.py[cod]
|
|
13
|
+
global-exclude *.pyo
|
|
14
|
+
global-exclude *.log
|
|
15
|
+
global-exclude *.executed.ipynb
|
|
16
|
+
global-exclude .env
|
|
17
|
+
global-exclude *.env
|
|
18
|
+
global-exclude .env.*
|
|
19
|
+
global-exclude .pypirc
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: quantum-cq
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Compact quantum circuit helpers, encodings, algorithms, navigation and Qiskit interop.
|
|
5
|
+
Author: José Yrikes de Oliveira Feitosa
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/jyrikes/quantum-cq
|
|
8
|
+
Project-URL: Repository, https://github.com/jyrikes/quantum-cq
|
|
9
|
+
Project-URL: Issues, https://github.com/jyrikes/quantum-cq/issues
|
|
10
|
+
Keywords: quantum,qiskit,encoding,quantum-circuits,education
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: qiskit
|
|
26
|
+
Requires-Dist: numpy
|
|
27
|
+
Requires-Dist: packaging
|
|
28
|
+
Provides-Extra: aer
|
|
29
|
+
Requires-Dist: qiskit-aer; extra == "aer"
|
|
30
|
+
Provides-Extra: ibm
|
|
31
|
+
Requires-Dist: qiskit-ibm-runtime; extra == "ibm"
|
|
32
|
+
Provides-Extra: notebook
|
|
33
|
+
Requires-Dist: pandas; extra == "notebook"
|
|
34
|
+
Requires-Dist: matplotlib; extra == "notebook"
|
|
35
|
+
Requires-Dist: ipython; extra == "notebook"
|
|
36
|
+
Requires-Dist: ipywidgets; extra == "notebook"
|
|
37
|
+
Provides-Extra: dev
|
|
38
|
+
Requires-Dist: pytest; extra == "dev"
|
|
39
|
+
Requires-Dist: build; extra == "dev"
|
|
40
|
+
Requires-Dist: twine; extra == "dev"
|
|
41
|
+
Provides-Extra: all
|
|
42
|
+
Requires-Dist: qiskit-aer; extra == "all"
|
|
43
|
+
Requires-Dist: qiskit-ibm-runtime; extra == "all"
|
|
44
|
+
Requires-Dist: pandas; extra == "all"
|
|
45
|
+
Requires-Dist: matplotlib; extra == "all"
|
|
46
|
+
Requires-Dist: ipython; extra == "all"
|
|
47
|
+
Requires-Dist: ipywidgets; extra == "all"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
# quantum_cq
|
|
51
|
+
|
|
52
|
+
Biblioteca Python extraida de um notebook de computacao quantica, com uma
|
|
53
|
+
camada compacta de circuitos (`QC`), encoders classicos, algoritmos basicos e
|
|
54
|
+
interop com Qiskit.
|
|
55
|
+
|
|
56
|
+
## Instalacao
|
|
57
|
+
|
|
58
|
+
```powershell
|
|
59
|
+
pip install quantum-cq
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Extras opcionais:
|
|
63
|
+
|
|
64
|
+
```powershell
|
|
65
|
+
pip install "quantum-cq[aer]" # simuladores Aer
|
|
66
|
+
pip install "quantum-cq[ibm]" # IBM Quantum Runtime
|
|
67
|
+
pip install "quantum-cq[notebook]" # pandas, matplotlib, IPython e widgets
|
|
68
|
+
pip install "quantum-cq[all]" # todos os extras opcionais
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Uso rapido
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from quantum_cq import CQ
|
|
75
|
+
|
|
76
|
+
encoded_basis = CQ.encode([1, 0, 1])
|
|
77
|
+
encoded_angle = CQ.encode([0.1, 0.2])
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
deutsch = CQ.algorithm("deutsch").with_case(2).build()
|
|
82
|
+
bv = CQ.algorithm("bernstein_vazirani").with_secret("1011").build()
|
|
83
|
+
dj = CQ.algorithm("deutsch_jozsa").with_num_qubits(3).with_kind("balanced").build()
|
|
84
|
+
grover = CQ.algorithm("grover").with_marked_state("11").build()
|
|
85
|
+
qpe = CQ.algorithm("phase_estimation").with_phase(0.25).with_precision(3).build()
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
qft = CQ.primitive("qft").build(num_qubits=3)
|
|
90
|
+
diffuser = CQ.primitive("standard_diffuser").build(num_qubits=3)
|
|
91
|
+
phase_rotation = CQ.operator("phase_rotation").with_phase(0.25).build()
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
memory = CQ.memory([3, 5, 7, 9])
|
|
96
|
+
nav = CQ.encode(memory, role="navigation")
|
|
97
|
+
qram_like = CQ.encode(memory, role="navigation", engine="qram_like")
|
|
98
|
+
print(CQ.metrics(nav))
|
|
99
|
+
print(CQ.to_qiskit(nav).draw())
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
graph = CQ.graph(edges=[(0, 1), (1, 2), (2, 3)], num_vertices=4)
|
|
104
|
+
neighbor_oracle = CQ.encode(graph, role="navigation")
|
|
105
|
+
|
|
106
|
+
cycle = CQ.graph(edges=[(0, 1), (1, 2), (2, 3), (3, 0)], num_vertices=4)
|
|
107
|
+
walk = CQ.primitive("coined_quantum_walk").build(cycle, steps=1)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## QC como circuito oficial
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from quantum_cq import CQ
|
|
114
|
+
from quantum_cq.algorithms import twobit_block
|
|
115
|
+
from quantum_cq.compact import QC, m, obs, sep
|
|
116
|
+
|
|
117
|
+
uf0 = twobit_block(2)
|
|
118
|
+
qc = QC(
|
|
119
|
+
"Deutsch",
|
|
120
|
+
[
|
|
121
|
+
[0, "-", "H", obs("pre_oracle"), uf0, sep("after_oracle"), "H", m(0)],
|
|
122
|
+
[0, "X", "H", obs("pre_oracle"), uf0, "-", "-", "-"],
|
|
123
|
+
],
|
|
124
|
+
c=1,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
same_qc = CQ.from_qc(qc)
|
|
128
|
+
qiskit_circuit = CQ.to_qiskit(qc)
|
|
129
|
+
metrics = CQ.metrics(qc)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Exportacao
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
qiskit_circuit = CQ.export(qc, target="qiskit")
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Exportadores futuros como `mqt` e `openqasm` ainda levantam
|
|
139
|
+
`NotImplementedError`; eles nao fingem implementacao parcial.
|
|
140
|
+
|
|
141
|
+
## Encodings generalizados
|
|
142
|
+
|
|
143
|
+
A arquitetura separa os papeis:
|
|
144
|
+
|
|
145
|
+
- `StateEncoding`: dados classicos para estado quantico.
|
|
146
|
+
- `OracleEncoding`: funcao ou predicado para oraculo.
|
|
147
|
+
- `OperatorEncoding`: operador ou unitario reutilizavel.
|
|
148
|
+
- `NavigationEncoding`: memoria enderecada ou grafo para acesso coerente.
|
|
149
|
+
- `QuantumWalk`: dinamica unitaria sobre uma estrutura navegavel.
|
|
150
|
+
|
|
151
|
+
`engine="qram_like"` simula a semantica logica de acesso QRAM-like, mas nao e
|
|
152
|
+
QRAM fisico. A metadata marca `physical_qram=False`.
|
|
153
|
+
|
|
154
|
+
## Logging
|
|
155
|
+
|
|
156
|
+
A biblioteca escreve eventos operacionais no terminal por padrao.
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from quantum_cq import configure_logging
|
|
160
|
+
|
|
161
|
+
configure_logging(level="INFO")
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Testes
|
|
165
|
+
|
|
166
|
+
```powershell
|
|
167
|
+
python -m pytest -q
|
|
168
|
+
```
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# quantum_cq
|
|
2
|
+
|
|
3
|
+
Biblioteca Python extraida de um notebook de computacao quantica, com uma
|
|
4
|
+
camada compacta de circuitos (`QC`), encoders classicos, algoritmos basicos e
|
|
5
|
+
interop com Qiskit.
|
|
6
|
+
|
|
7
|
+
## Instalacao
|
|
8
|
+
|
|
9
|
+
```powershell
|
|
10
|
+
pip install quantum-cq
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Extras opcionais:
|
|
14
|
+
|
|
15
|
+
```powershell
|
|
16
|
+
pip install "quantum-cq[aer]" # simuladores Aer
|
|
17
|
+
pip install "quantum-cq[ibm]" # IBM Quantum Runtime
|
|
18
|
+
pip install "quantum-cq[notebook]" # pandas, matplotlib, IPython e widgets
|
|
19
|
+
pip install "quantum-cq[all]" # todos os extras opcionais
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Uso rapido
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from quantum_cq import CQ
|
|
26
|
+
|
|
27
|
+
encoded_basis = CQ.encode([1, 0, 1])
|
|
28
|
+
encoded_angle = CQ.encode([0.1, 0.2])
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
deutsch = CQ.algorithm("deutsch").with_case(2).build()
|
|
33
|
+
bv = CQ.algorithm("bernstein_vazirani").with_secret("1011").build()
|
|
34
|
+
dj = CQ.algorithm("deutsch_jozsa").with_num_qubits(3).with_kind("balanced").build()
|
|
35
|
+
grover = CQ.algorithm("grover").with_marked_state("11").build()
|
|
36
|
+
qpe = CQ.algorithm("phase_estimation").with_phase(0.25).with_precision(3).build()
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
qft = CQ.primitive("qft").build(num_qubits=3)
|
|
41
|
+
diffuser = CQ.primitive("standard_diffuser").build(num_qubits=3)
|
|
42
|
+
phase_rotation = CQ.operator("phase_rotation").with_phase(0.25).build()
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
memory = CQ.memory([3, 5, 7, 9])
|
|
47
|
+
nav = CQ.encode(memory, role="navigation")
|
|
48
|
+
qram_like = CQ.encode(memory, role="navigation", engine="qram_like")
|
|
49
|
+
print(CQ.metrics(nav))
|
|
50
|
+
print(CQ.to_qiskit(nav).draw())
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
graph = CQ.graph(edges=[(0, 1), (1, 2), (2, 3)], num_vertices=4)
|
|
55
|
+
neighbor_oracle = CQ.encode(graph, role="navigation")
|
|
56
|
+
|
|
57
|
+
cycle = CQ.graph(edges=[(0, 1), (1, 2), (2, 3), (3, 0)], num_vertices=4)
|
|
58
|
+
walk = CQ.primitive("coined_quantum_walk").build(cycle, steps=1)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## QC como circuito oficial
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from quantum_cq import CQ
|
|
65
|
+
from quantum_cq.algorithms import twobit_block
|
|
66
|
+
from quantum_cq.compact import QC, m, obs, sep
|
|
67
|
+
|
|
68
|
+
uf0 = twobit_block(2)
|
|
69
|
+
qc = QC(
|
|
70
|
+
"Deutsch",
|
|
71
|
+
[
|
|
72
|
+
[0, "-", "H", obs("pre_oracle"), uf0, sep("after_oracle"), "H", m(0)],
|
|
73
|
+
[0, "X", "H", obs("pre_oracle"), uf0, "-", "-", "-"],
|
|
74
|
+
],
|
|
75
|
+
c=1,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
same_qc = CQ.from_qc(qc)
|
|
79
|
+
qiskit_circuit = CQ.to_qiskit(qc)
|
|
80
|
+
metrics = CQ.metrics(qc)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Exportacao
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
qiskit_circuit = CQ.export(qc, target="qiskit")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Exportadores futuros como `mqt` e `openqasm` ainda levantam
|
|
90
|
+
`NotImplementedError`; eles nao fingem implementacao parcial.
|
|
91
|
+
|
|
92
|
+
## Encodings generalizados
|
|
93
|
+
|
|
94
|
+
A arquitetura separa os papeis:
|
|
95
|
+
|
|
96
|
+
- `StateEncoding`: dados classicos para estado quantico.
|
|
97
|
+
- `OracleEncoding`: funcao ou predicado para oraculo.
|
|
98
|
+
- `OperatorEncoding`: operador ou unitario reutilizavel.
|
|
99
|
+
- `NavigationEncoding`: memoria enderecada ou grafo para acesso coerente.
|
|
100
|
+
- `QuantumWalk`: dinamica unitaria sobre uma estrutura navegavel.
|
|
101
|
+
|
|
102
|
+
`engine="qram_like"` simula a semantica logica de acesso QRAM-like, mas nao e
|
|
103
|
+
QRAM fisico. A metadata marca `physical_qram=False`.
|
|
104
|
+
|
|
105
|
+
## Logging
|
|
106
|
+
|
|
107
|
+
A biblioteca escreve eventos operacionais no terminal por padrao.
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from quantum_cq import configure_logging
|
|
111
|
+
|
|
112
|
+
configure_logging(level="INFO")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Testes
|
|
116
|
+
|
|
117
|
+
```powershell
|
|
118
|
+
python -m pytest -q
|
|
119
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "quantum-cq"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Compact quantum circuit helpers, encodings, algorithms, navigation and Qiskit interop."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "José Yrikes de Oliveira Feitosa" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["quantum", "qiskit", "encoding", "quantum-circuits", "education"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Intended Audience :: Education",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Topic :: Scientific/Engineering",
|
|
27
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
28
|
+
]
|
|
29
|
+
dependencies = [
|
|
30
|
+
"qiskit",
|
|
31
|
+
"numpy",
|
|
32
|
+
"packaging",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
aer = ["qiskit-aer"]
|
|
37
|
+
ibm = ["qiskit-ibm-runtime"]
|
|
38
|
+
notebook = ["pandas", "matplotlib", "ipython", "ipywidgets"]
|
|
39
|
+
dev = ["pytest", "build", "twine"]
|
|
40
|
+
all = [
|
|
41
|
+
"qiskit-aer",
|
|
42
|
+
"qiskit-ibm-runtime",
|
|
43
|
+
"pandas",
|
|
44
|
+
"matplotlib",
|
|
45
|
+
"ipython",
|
|
46
|
+
"ipywidgets",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://github.com/jyrikes/quantum-cq"
|
|
51
|
+
Repository = "https://github.com/jyrikes/quantum-cq"
|
|
52
|
+
Issues = "https://github.com/jyrikes/quantum-cq/issues"
|
|
53
|
+
|
|
54
|
+
[tool.setuptools]
|
|
55
|
+
include-package-data = false
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.packages.find]
|
|
58
|
+
where = ["src"]
|
|
59
|
+
|
|
60
|
+
[tool.pytest.ini_options]
|
|
61
|
+
pythonpath = ["src"]
|
|
62
|
+
testpaths = ["tests"]
|
|
63
|
+
markers = [
|
|
64
|
+
"real_hardware: tests that submit jobs to IBM Quantum hardware",
|
|
65
|
+
"ibm_real: opt-in integration tests that submit jobs to IBM Quantum hardware",
|
|
66
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import shutil
|
|
3
|
+
|
|
4
|
+
from setuptools import setup
|
|
5
|
+
from setuptools.command.sdist import sdist as _sdist
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class sdist(_sdist):
|
|
9
|
+
def make_release_tree(self, base_dir, files):
|
|
10
|
+
super().make_release_tree(base_dir, files)
|
|
11
|
+
egg_info = Path(base_dir) / "src" / "quantum_cq.egg-info"
|
|
12
|
+
if egg_info.exists():
|
|
13
|
+
shutil.rmtree(egg_info)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
setup(cmdclass={"sdist": sdist})
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""quantum_cq package."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from quantum_cq._core.facade import CQ
|
|
6
|
+
from quantum_cq._core.data import QuantumData
|
|
7
|
+
from quantum_cq._core.interfaces import (
|
|
8
|
+
AlgorithmBuilderProtocol,
|
|
9
|
+
AlgorithmHandler,
|
|
10
|
+
AlgorithmProtocol,
|
|
11
|
+
ArithmeticOracleProtocol,
|
|
12
|
+
BackendAdapter,
|
|
13
|
+
BackendAdapterProtocol,
|
|
14
|
+
BlockEncodingProtocol,
|
|
15
|
+
CircuitBuilderProtocol,
|
|
16
|
+
CircuitExporterProtocol,
|
|
17
|
+
CircuitFactoryProtocol,
|
|
18
|
+
CircuitLikeProtocol,
|
|
19
|
+
CompilerAdapterProtocol,
|
|
20
|
+
ControlledUnitaryProtocol,
|
|
21
|
+
DiffuserProtocol,
|
|
22
|
+
EncodingHandler,
|
|
23
|
+
EncodingProtocol,
|
|
24
|
+
EncodingSelectorProtocol,
|
|
25
|
+
FourierTransformProtocol,
|
|
26
|
+
GraphNavigationProtocol,
|
|
27
|
+
HamiltonianEncodingProtocol,
|
|
28
|
+
LinearSystemProblemProtocol,
|
|
29
|
+
NavigationEncodingProtocol,
|
|
30
|
+
MetricsCollectorProtocol,
|
|
31
|
+
OperatorProtocol,
|
|
32
|
+
OperatorEncodingProtocol,
|
|
33
|
+
OracleProtocol,
|
|
34
|
+
OracleEncodingProtocol,
|
|
35
|
+
PhaseOracleProtocol,
|
|
36
|
+
PipelineBuilderProtocol,
|
|
37
|
+
PowerableUnitaryProtocol,
|
|
38
|
+
PrimitiveProtocol,
|
|
39
|
+
PredicateOracleProtocol,
|
|
40
|
+
RegistryProtocol,
|
|
41
|
+
ResultHandler,
|
|
42
|
+
StateEncodingProtocol,
|
|
43
|
+
StatePreparationProtocol,
|
|
44
|
+
UnitaryProtocol,
|
|
45
|
+
AddressedEncodingProtocol,
|
|
46
|
+
)
|
|
47
|
+
from quantum_cq._core.logging_config import configure_logging
|
|
48
|
+
from quantum_cq._navigation.memory import (
|
|
49
|
+
AddressedMemory,
|
|
50
|
+
AddressedMemoryEncoding,
|
|
51
|
+
GraphData,
|
|
52
|
+
GraphNavigationEncoding,
|
|
53
|
+
)
|
|
54
|
+
from quantum_cq._core.results import (
|
|
55
|
+
AlgorithmCircuit,
|
|
56
|
+
AlgorithmSpec,
|
|
57
|
+
CompilerResult,
|
|
58
|
+
EncodedCircuit,
|
|
59
|
+
NavigationCircuit,
|
|
60
|
+
OperatorCircuit,
|
|
61
|
+
OracleCircuit,
|
|
62
|
+
QuantumResult,
|
|
63
|
+
)
|
|
64
|
+
from quantum_cq._core.settings import (
|
|
65
|
+
PipelineSettings,
|
|
66
|
+
RuntimeSettings,
|
|
67
|
+
get_pipeline_settings,
|
|
68
|
+
get_runtime_settings,
|
|
69
|
+
)
|
|
70
|
+
from quantum_cq._runtime.runtime import IBMRuntimeConfig
|
|
71
|
+
|
|
72
|
+
if TYPE_CHECKING:
|
|
73
|
+
from quantum_cq._runtime.experiment import (
|
|
74
|
+
ExperimentPlan,
|
|
75
|
+
ExperimentResult,
|
|
76
|
+
ExperimentSpec,
|
|
77
|
+
PipelineResult,
|
|
78
|
+
)
|
|
79
|
+
from quantum_cq._runtime.pipeline import BenchmarkingPipeline
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
_LAZY_EXPORTS = {
|
|
83
|
+
"ExperimentPlan": ("quantum_cq._runtime.experiment", "ExperimentPlan"),
|
|
84
|
+
"ExperimentSpec": ("quantum_cq._runtime.experiment", "ExperimentSpec"),
|
|
85
|
+
"ExperimentResult": ("quantum_cq._runtime.experiment", "ExperimentResult"),
|
|
86
|
+
"PipelineResult": ("quantum_cq._runtime.experiment", "PipelineResult"),
|
|
87
|
+
"BenchmarkingPipeline": ("quantum_cq._runtime.pipeline", "BenchmarkingPipeline"),
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def __getattr__(name):
|
|
92
|
+
if name in _LAZY_EXPORTS:
|
|
93
|
+
from importlib import import_module
|
|
94
|
+
|
|
95
|
+
module_name, attr_name = _LAZY_EXPORTS[name]
|
|
96
|
+
value = getattr(import_module(module_name), attr_name)
|
|
97
|
+
globals()[name] = value
|
|
98
|
+
return value
|
|
99
|
+
|
|
100
|
+
raise AttributeError(f"module 'quantum_cq' has no attribute {name!r}")
|
|
101
|
+
|
|
102
|
+
__all__ = [
|
|
103
|
+
"CQ",
|
|
104
|
+
"QuantumData",
|
|
105
|
+
"QuantumResult",
|
|
106
|
+
"EncodedCircuit",
|
|
107
|
+
"AlgorithmCircuit",
|
|
108
|
+
"AlgorithmSpec",
|
|
109
|
+
"CompilerResult",
|
|
110
|
+
"OperatorCircuit",
|
|
111
|
+
"OracleCircuit",
|
|
112
|
+
"NavigationCircuit",
|
|
113
|
+
"AddressedMemory",
|
|
114
|
+
"AddressedMemoryEncoding",
|
|
115
|
+
"GraphData",
|
|
116
|
+
"GraphNavigationEncoding",
|
|
117
|
+
"ExperimentPlan",
|
|
118
|
+
"ExperimentSpec",
|
|
119
|
+
"ExperimentResult",
|
|
120
|
+
"PipelineResult",
|
|
121
|
+
"BenchmarkingPipeline",
|
|
122
|
+
"IBMRuntimeConfig",
|
|
123
|
+
"EncodingHandler",
|
|
124
|
+
"EncodingProtocol",
|
|
125
|
+
"StateEncodingProtocol",
|
|
126
|
+
"OracleEncodingProtocol",
|
|
127
|
+
"OperatorEncodingProtocol",
|
|
128
|
+
"NavigationEncodingProtocol",
|
|
129
|
+
"AddressedEncodingProtocol",
|
|
130
|
+
"GraphNavigationProtocol",
|
|
131
|
+
"AlgorithmBuilderProtocol",
|
|
132
|
+
"AlgorithmHandler",
|
|
133
|
+
"AlgorithmProtocol",
|
|
134
|
+
"ArithmeticOracleProtocol",
|
|
135
|
+
"BackendAdapter",
|
|
136
|
+
"BackendAdapterProtocol",
|
|
137
|
+
"BlockEncodingProtocol",
|
|
138
|
+
"CircuitBuilderProtocol",
|
|
139
|
+
"CircuitExporterProtocol",
|
|
140
|
+
"CircuitFactoryProtocol",
|
|
141
|
+
"CircuitLikeProtocol",
|
|
142
|
+
"CompilerAdapterProtocol",
|
|
143
|
+
"ControlledUnitaryProtocol",
|
|
144
|
+
"DiffuserProtocol",
|
|
145
|
+
"EncodingSelectorProtocol",
|
|
146
|
+
"FourierTransformProtocol",
|
|
147
|
+
"HamiltonianEncodingProtocol",
|
|
148
|
+
"LinearSystemProblemProtocol",
|
|
149
|
+
"RegistryProtocol",
|
|
150
|
+
"PipelineBuilderProtocol",
|
|
151
|
+
"MetricsCollectorProtocol",
|
|
152
|
+
"OperatorProtocol",
|
|
153
|
+
"PrimitiveProtocol",
|
|
154
|
+
"OracleProtocol",
|
|
155
|
+
"PhaseOracleProtocol",
|
|
156
|
+
"PowerableUnitaryProtocol",
|
|
157
|
+
"PredicateOracleProtocol",
|
|
158
|
+
"ResultHandler",
|
|
159
|
+
"StatePreparationProtocol",
|
|
160
|
+
"UnitaryProtocol",
|
|
161
|
+
"configure_logging",
|
|
162
|
+
"PipelineSettings",
|
|
163
|
+
"RuntimeSettings",
|
|
164
|
+
"get_pipeline_settings",
|
|
165
|
+
"get_runtime_settings",
|
|
166
|
+
]
|
|
File without changes
|