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.
Files changed (64) hide show
  1. qasp/__init__.py +202 -0
  2. qasp/circuits/__init__.py +10 -0
  3. qasp/circuits/constructor.py +715 -0
  4. qasp/circuits/templates.py +562 -0
  5. qasp/circuits/tikz.py +1193 -0
  6. qasp/circuits/uqc.py +21 -0
  7. qasp/classifiers/__init__.py +65 -0
  8. qasp/classifiers/decoders.py +275 -0
  9. qasp/classifiers/factory.py +150 -0
  10. qasp/classifiers/losses.py +214 -0
  11. qasp/classifiers/metrics.py +441 -0
  12. qasp/classifiers/models.py +615 -0
  13. qasp/classifiers/training.py +140 -0
  14. qasp/devices.py +70 -0
  15. qasp/diagnostics/__init__.py +5 -0
  16. qasp/diagnostics/barren_plateau.py +828 -0
  17. qasp/feature_maps/__init__.py +4 -0
  18. qasp/feature_maps/templates.py +213 -0
  19. qasp/genlearn/__init__.py +17 -0
  20. qasp/genlearn/drawing.py +75 -0
  21. qasp/genlearn/factory.py +16 -0
  22. qasp/genlearn/losses.py +191 -0
  23. qasp/genlearn/models.py +762 -0
  24. qasp/initialization.py +410 -0
  25. qasp/optimization/__init__.py +42 -0
  26. qasp/optimization/drawing.py +300 -0
  27. qasp/optimization/optimizers.py +360 -0
  28. qasp/optimization/pce.py +465 -0
  29. qasp/optimization/problem.py +246 -0
  30. qasp/optimization/qaoa.py +784 -0
  31. qasp/optimization/recursive.py +262 -0
  32. qasp/optimization/results.py +72 -0
  33. qasp/qkernels/__init__.py +30 -0
  34. qasp/qkernels/factory.py +188 -0
  35. qasp/qkernels/kernels.py +79 -0
  36. qasp/qkernels/kta.py +208 -0
  37. qasp/qkernels/quantum_kernels.py +688 -0
  38. qasp/rl/__init__.py +55 -0
  39. qasp/rl/differentiable_pp_sim.py +4 -0
  40. qasp/rl/envs.py +197 -0
  41. qasp/rl/metrics.py +621 -0
  42. qasp/rl/model.py +246 -0
  43. qasp/rl/policies.py +1960 -0
  44. qasp/rl/pp_sim.py +773 -0
  45. qasp/rl/qfunctions/__init__.py +13 -0
  46. qasp/rl/qfunctions/drawing.py +85 -0
  47. qasp/rl/qfunctions/models.py +323 -0
  48. qasp/rl/qfunctions/observables.py +222 -0
  49. qasp/rl/torchrl.py +3107 -0
  50. qasp/rl/trl.py +165 -0
  51. qasp/simulators/__init__.py +12 -0
  52. qasp/simulators/_inference.py +114 -0
  53. qasp/simulators/_iqp_observables.py +160 -0
  54. qasp/simulators/_pauli_propagation.py +1062 -0
  55. qasp/simulators/_van_den_nest.py +488 -0
  56. qasp/simulators/iqp.py +295 -0
  57. qasp/simulators/iqp_tn.py +755 -0
  58. qasp/simulators/pauli_propagation.py +213 -0
  59. qasp/simulators/readout.py +127 -0
  60. qasp-0.1.0.dist-info/METADATA +2043 -0
  61. qasp-0.1.0.dist-info/RECORD +64 -0
  62. qasp-0.1.0.dist-info/WHEEL +5 -0
  63. qasp-0.1.0.dist-info/licenses/LICENSE +21 -0
  64. 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
+ ]