qasp 0.1.0__py3-none-any.whl
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.
- qasp/__init__.py +202 -0
- qasp/circuits/__init__.py +10 -0
- qasp/circuits/constructor.py +715 -0
- qasp/circuits/templates.py +562 -0
- qasp/circuits/tikz.py +1193 -0
- qasp/circuits/uqc.py +21 -0
- qasp/classifiers/__init__.py +65 -0
- qasp/classifiers/decoders.py +275 -0
- qasp/classifiers/factory.py +150 -0
- qasp/classifiers/losses.py +214 -0
- qasp/classifiers/metrics.py +441 -0
- qasp/classifiers/models.py +615 -0
- qasp/classifiers/training.py +140 -0
- qasp/devices.py +70 -0
- qasp/diagnostics/__init__.py +5 -0
- qasp/diagnostics/barren_plateau.py +828 -0
- qasp/feature_maps/__init__.py +4 -0
- qasp/feature_maps/templates.py +213 -0
- qasp/genlearn/__init__.py +17 -0
- qasp/genlearn/drawing.py +75 -0
- qasp/genlearn/factory.py +16 -0
- qasp/genlearn/losses.py +191 -0
- qasp/genlearn/models.py +762 -0
- qasp/initialization.py +410 -0
- qasp/optimization/__init__.py +42 -0
- qasp/optimization/drawing.py +300 -0
- qasp/optimization/optimizers.py +360 -0
- qasp/optimization/pce.py +465 -0
- qasp/optimization/problem.py +246 -0
- qasp/optimization/qaoa.py +784 -0
- qasp/optimization/recursive.py +262 -0
- qasp/optimization/results.py +72 -0
- qasp/qkernels/__init__.py +30 -0
- qasp/qkernels/factory.py +188 -0
- qasp/qkernels/kernels.py +79 -0
- qasp/qkernels/kta.py +208 -0
- qasp/qkernels/quantum_kernels.py +688 -0
- qasp/rl/__init__.py +55 -0
- qasp/rl/differentiable_pp_sim.py +4 -0
- qasp/rl/envs.py +197 -0
- qasp/rl/metrics.py +621 -0
- qasp/rl/model.py +246 -0
- qasp/rl/policies.py +1960 -0
- qasp/rl/pp_sim.py +773 -0
- qasp/rl/qfunctions/__init__.py +13 -0
- qasp/rl/qfunctions/drawing.py +85 -0
- qasp/rl/qfunctions/models.py +323 -0
- qasp/rl/qfunctions/observables.py +222 -0
- qasp/rl/torchrl.py +3107 -0
- qasp/rl/trl.py +165 -0
- qasp/simulators/__init__.py +12 -0
- qasp/simulators/_inference.py +114 -0
- qasp/simulators/_iqp_observables.py +160 -0
- qasp/simulators/_pauli_propagation.py +1062 -0
- qasp/simulators/_van_den_nest.py +488 -0
- qasp/simulators/iqp.py +295 -0
- qasp/simulators/iqp_tn.py +755 -0
- qasp/simulators/pauli_propagation.py +213 -0
- qasp/simulators/readout.py +127 -0
- qasp-0.1.0.dist-info/METADATA +2043 -0
- qasp-0.1.0.dist-info/RECORD +64 -0
- qasp-0.1.0.dist-info/WHEEL +5 -0
- qasp-0.1.0.dist-info/licenses/LICENSE +21 -0
- qasp-0.1.0.dist-info/top_level.txt +1 -0
qasp/__init__.py
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# qasp/__init__.py
|
|
2
|
+
|
|
3
|
+
# 1. Circuits
|
|
4
|
+
"""QASP: reusable quantum circuits and application-level learning models.
|
|
5
|
+
|
|
6
|
+
Subpackages cover encodings, circuits/drawing, classification, quantum kernels,
|
|
7
|
+
Born learning, optimization, reinforcement learning and diagnostics.
|
|
8
|
+
Optional application exports are loaded lazily; importing an export can still
|
|
9
|
+
require its optional dependency. See docs/package_guide.md for the API map and
|
|
10
|
+
implementation boundaries."""
|
|
11
|
+
from .initialization import (
|
|
12
|
+
Initializer, Normal, Uniform, Beta, TruncatedNormal, LogNormal,
|
|
13
|
+
Gamma, Exponential, Laplace, Rademacher, Constant, Zeros, Ones, Choice,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
from .circuits import (
|
|
17
|
+
AngleAnsatz,
|
|
18
|
+
CircuitBuilder,
|
|
19
|
+
IQPAnsatz,
|
|
20
|
+
UQC,
|
|
21
|
+
circuit_to_tikz,
|
|
22
|
+
save_tikz,
|
|
23
|
+
tape_to_tikz,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
# 2. Feature Maps (Note: ensure your folder is named 'feature_maps')
|
|
27
|
+
from .feature_maps import AngleEmbedding, NeuralEmbedding
|
|
28
|
+
|
|
29
|
+
# 3. Models / Generative Learning
|
|
30
|
+
from .genlearn import BornMachine, PQCBM, PauliMMD, create_qcbm, draw_qcbm
|
|
31
|
+
|
|
32
|
+
# 4. Kernels
|
|
33
|
+
from .qkernels import (
|
|
34
|
+
QFKernel,
|
|
35
|
+
FidelityKernel,
|
|
36
|
+
ProjectedKernel,
|
|
37
|
+
KernelTargetAlignment,
|
|
38
|
+
align_kernel,
|
|
39
|
+
create_kernel,
|
|
40
|
+
draw_kernel,
|
|
41
|
+
target_alignment,
|
|
42
|
+
target_matrix,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# 5. Quantum Classifiers
|
|
46
|
+
from .classifiers import (
|
|
47
|
+
ClassProbabilityDecoder,
|
|
48
|
+
ClassifierLoss,
|
|
49
|
+
ClassifierTrainer,
|
|
50
|
+
PQCClassifier,
|
|
51
|
+
ProbabilityDecoder,
|
|
52
|
+
QuantumClassifier,
|
|
53
|
+
accuracy_score,
|
|
54
|
+
average_precision_score,
|
|
55
|
+
balanced_accuracy_score,
|
|
56
|
+
binary_cross_entropy,
|
|
57
|
+
brier_score,
|
|
58
|
+
categorical_cross_entropy,
|
|
59
|
+
classification_loss,
|
|
60
|
+
classification_metrics,
|
|
61
|
+
confusion_matrix,
|
|
62
|
+
create_classifier,
|
|
63
|
+
draw_classifier,
|
|
64
|
+
f1_score,
|
|
65
|
+
hinge_loss,
|
|
66
|
+
log_loss,
|
|
67
|
+
mean_squared_error,
|
|
68
|
+
precision_score,
|
|
69
|
+
pr_auc_score,
|
|
70
|
+
recall_score,
|
|
71
|
+
roc_auc_score,
|
|
72
|
+
top_k_accuracy,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# 6. Combinatorial optimization
|
|
76
|
+
from .optimization import (
|
|
77
|
+
AVAILABLE_OPTIMIZERS,
|
|
78
|
+
PENNYLANE_OPTIMIZERS,
|
|
79
|
+
SCIPY_OPTIMIZERS,
|
|
80
|
+
TORCH_OPTIMIZERS,
|
|
81
|
+
ClassicalOptimizer,
|
|
82
|
+
LRQAOA,
|
|
83
|
+
LinearRampQAOA,
|
|
84
|
+
OptimizationResult,
|
|
85
|
+
PCE,
|
|
86
|
+
PauliCorrelationEncoding,
|
|
87
|
+
PauliTerm,
|
|
88
|
+
QAOA,
|
|
89
|
+
QUBO,
|
|
90
|
+
RQAOA,
|
|
91
|
+
RecursiveQAOA,
|
|
92
|
+
RecursiveQAOAResult,
|
|
93
|
+
WarmStartQAOA,
|
|
94
|
+
build_pauli_correlation_encoding,
|
|
95
|
+
create_optimizer,
|
|
96
|
+
draw_optimization,
|
|
97
|
+
draw_pce,
|
|
98
|
+
draw_qaoa,
|
|
99
|
+
draw_recursive_qaoa,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# 7. RL, Training, and Simulation
|
|
103
|
+
#
|
|
104
|
+
# Import these on first access so circuit, kernel, and generative workflows do
|
|
105
|
+
# not require the complete RL dependency stack merely to import QASP.
|
|
106
|
+
_RL_EXPORTS = {
|
|
107
|
+
"policy_variance",
|
|
108
|
+
"compute_DLA_generators",
|
|
109
|
+
"fourier_analysis",
|
|
110
|
+
"hadamard_decomposition",
|
|
111
|
+
"cz_decomposition",
|
|
112
|
+
"cnot_decomposition",
|
|
113
|
+
"_policy_expressivity",
|
|
114
|
+
"_sample_worker_batch",
|
|
115
|
+
"create_model",
|
|
116
|
+
"draw_model",
|
|
117
|
+
"PQCBorn",
|
|
118
|
+
"PQCSoftmax",
|
|
119
|
+
"PQDQN",
|
|
120
|
+
"create_qfunction",
|
|
121
|
+
"draw_qfunction",
|
|
122
|
+
"DeepQLearning",
|
|
123
|
+
"PQCBornVariance",
|
|
124
|
+
"LearnablePQCBorn",
|
|
125
|
+
"FastTruncatedPauliProp",
|
|
126
|
+
"PQCBornWrapper",
|
|
127
|
+
"TorchRLTrainer",
|
|
128
|
+
"REINFORCE",
|
|
129
|
+
"BanditAWRConfig",
|
|
130
|
+
"ContextualBanditTrainer",
|
|
131
|
+
"PQCWrapper",
|
|
132
|
+
"WindyTargetNavigationEnv",
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
_LAZY_EXPORTS = {
|
|
136
|
+
"barren_plateau_diagnoser": (
|
|
137
|
+
".diagnostics",
|
|
138
|
+
"barren_plateau_diagnoser",
|
|
139
|
+
),
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def __getattr__(name):
|
|
144
|
+
"""Import and cache a supported lazy public export; raise AttributeError for unknown names."""
|
|
145
|
+
if name in _LAZY_EXPORTS:
|
|
146
|
+
from importlib import import_module
|
|
147
|
+
|
|
148
|
+
module_name, attribute = _LAZY_EXPORTS[name]
|
|
149
|
+
value = getattr(import_module(module_name, __name__), attribute)
|
|
150
|
+
globals()[name] = value
|
|
151
|
+
return value
|
|
152
|
+
if name in _RL_EXPORTS:
|
|
153
|
+
from importlib import import_module
|
|
154
|
+
|
|
155
|
+
value = getattr(import_module(".rl", __name__), name)
|
|
156
|
+
globals()[name] = value
|
|
157
|
+
return value
|
|
158
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
159
|
+
|
|
160
|
+
__all__ = [
|
|
161
|
+
"Initializer", "Normal", "Uniform", "Beta", "TruncatedNormal", "LogNormal",
|
|
162
|
+
"Gamma", "Exponential", "Laplace", "Rademacher", "Constant", "Zeros", "Ones", "Choice",
|
|
163
|
+
"CircuitBuilder", "IQPAnsatz", "AngleAnsatz", "UQC",
|
|
164
|
+
"circuit_to_tikz", "save_tikz", "tape_to_tikz",
|
|
165
|
+
"AngleEmbedding", "NeuralEmbedding",
|
|
166
|
+
"BornMachine", "PQCBM", "PauliMMD", "create_qcbm", "draw_qcbm",
|
|
167
|
+
"QFKernel", "FidelityKernel", "ProjectedKernel",
|
|
168
|
+
"create_kernel", "draw_kernel", "KernelTargetAlignment",
|
|
169
|
+
"target_alignment", "target_matrix", "align_kernel",
|
|
170
|
+
"PQCClassifier", "QuantumClassifier", "ClassifierTrainer",
|
|
171
|
+
"ClassProbabilityDecoder", "ProbabilityDecoder", "create_classifier",
|
|
172
|
+
"draw_classifier",
|
|
173
|
+
"ClassifierLoss", "classification_loss", "mean_squared_error",
|
|
174
|
+
"hinge_loss", "binary_cross_entropy", "categorical_cross_entropy",
|
|
175
|
+
"accuracy_score", "balanced_accuracy_score", "precision_score",
|
|
176
|
+
"recall_score", "f1_score", "confusion_matrix", "roc_auc_score",
|
|
177
|
+
"pr_auc_score", "average_precision_score",
|
|
178
|
+
"classification_metrics", "top_k_accuracy", "log_loss", "brier_score",
|
|
179
|
+
"barren_plateau_diagnoser",
|
|
180
|
+
"QUBO", "PauliTerm", "QAOA", "WarmStartQAOA", "RQAOA",
|
|
181
|
+
"RecursiveQAOA", "LRQAOA", "LinearRampQAOA", "PCE",
|
|
182
|
+
"PauliCorrelationEncoding", "OptimizationResult", "RecursiveQAOAResult",
|
|
183
|
+
"build_pauli_correlation_encoding", "ClassicalOptimizer",
|
|
184
|
+
"create_optimizer", "AVAILABLE_OPTIMIZERS",
|
|
185
|
+
"SCIPY_OPTIMIZERS", "PENNYLANE_OPTIMIZERS", "TORCH_OPTIMIZERS",
|
|
186
|
+
"draw_optimization", "draw_qaoa", "draw_pce", "draw_recursive_qaoa",
|
|
187
|
+
"policy_variance", "compute_DLA_generators", "fourier_analysis",
|
|
188
|
+
"hadamard_decomposition", "cz_decomposition", "cnot_decomposition",
|
|
189
|
+
"_policy_expressivity", "_sample_worker_batch", "create_model",
|
|
190
|
+
"PQDQN", "create_qfunction", "draw_qfunction", "DeepQLearning",
|
|
191
|
+
"draw_model", "PQCBorn", "PQCSoftmax", "PQCBornVariance",
|
|
192
|
+
"LearnablePQCBorn", "FastTruncatedPauliProp", "DifferentiablePauliProp",
|
|
193
|
+
"PQCBornWrapper",
|
|
194
|
+
"TorchRLTrainer", "REINFORCE", "BanditAWRConfig",
|
|
195
|
+
"ContextualBanditTrainer", "PQCWrapper", "WindyTargetNavigationEnv"
|
|
196
|
+
]
|
|
197
|
+
|
|
198
|
+
from .simulators import IQPSimulator, IQPOptions, IQPReport, IQPTNSimulator, IQPTNOptions, DecoderSpec, action_probs
|
|
199
|
+
__all__ += ["IQPSimulator", "IQPOptions", "IQPReport", "IQPTNSimulator", "IQPTNOptions", "DecoderSpec", "action_probs"]
|
|
200
|
+
|
|
201
|
+
from .simulators import PauliPropagationSimulator, PauliPropagationOptions, DifferentiablePauliProp
|
|
202
|
+
__all__ += ["PauliPropagationSimulator", "PauliPropagationOptions"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Circuit templates, mutable circuit construction and Quantikz/TikZ rendering exports."""
|
|
2
|
+
from .constructor import CircuitBuilder
|
|
3
|
+
from .templates import IQPAnsatz, AngleAnsatz
|
|
4
|
+
from .tikz import circuit_to_tikz, save_tikz, tape_to_tikz
|
|
5
|
+
from .uqc import UQC
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
'CircuitBuilder', 'IQPAnsatz', 'AngleAnsatz', 'UQC',
|
|
9
|
+
'circuit_to_tikz', 'save_tikz', 'tape_to_tikz',
|
|
10
|
+
]
|