squlearn 0.5.2__tar.gz → 0.7.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.
- {squlearn-0.5.2 → squlearn-0.7.0}/.gitignore +4 -4
- {squlearn-0.5.2 → squlearn-0.7.0}/PKG-INFO +14 -3
- {squlearn-0.5.2 → squlearn-0.7.0}/README.md +11 -1
- squlearn-0.7.0/docs/_static/schematic.png +0 -0
- squlearn-0.7.0/docs/_static/util/executor.png +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/modules/classes.rst +18 -2
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/user_guide/encoding_circuits.rst +1 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/user_guide/executor.rst +98 -42
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/user_guide/kernel_methods.rst +4 -5
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/user_guide/observables.rst +1 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/user_guide/quantum_neural_networks.rst +1 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/encoding_circuits/various_encoding_circuit.ipynb +1 -0
- squlearn-0.5.2/examples/executor/example_executor.ipynb → squlearn-0.7.0/examples/executor/example_executor_qiskit.ipynb +15 -15
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/integration/mlflow.ipynb +8 -8
- squlearn-0.7.0/examples/kernel/example_fidelity_kernel.ipynb +189 -0
- squlearn-0.7.0/examples/kernel/example_projected_kernel.ipynb +697 -0
- squlearn-0.7.0/examples/kernel/example_regularization_mitigation.ipynb +387 -0
- squlearn-0.7.0/examples/kernel/qgpc_workflow.ipynb +579 -0
- squlearn-0.7.0/examples/kernel/qgpr_optimization_workflow.ipynb +196 -0
- squlearn-0.7.0/examples/kernel/qgpr_workflow.ipynb +181 -0
- squlearn-0.7.0/examples/qnn/classification_example.ipynb +336 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/qnn/example_adam.ipynb +28 -12
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/qnn/example_minibatch.ipynb +21 -13
- squlearn-0.7.0/examples/qnn/example_qcnn_encoding_circuit.ipynb +549 -0
- squlearn-0.7.0/examples/qnn/regression_example.ipynb +385 -0
- squlearn-0.7.0/examples/qnn/regression_with_variance.ipynb +396 -0
- squlearn-0.7.0/examples/tutorials/kernel_digit_classification.ipynb +1061 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/tutorials/kernel_grid_search.ipynb +427 -31
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/tutorials/kernel_regression.ipynb +10 -7
- squlearn-0.7.0/examples/tutorials/quantum_bayesian_optimization.ipynb +533 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/pyproject.toml +3 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/__init__.py +2 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/__init__.py +2 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/circuit_library/chebyshev_pqc.py +44 -32
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/circuit_library/chebyshev_rx.py +32 -20
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/circuit_library/chebyshev_tower.py +8 -8
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/circuit_library/highdim_encoding_circuit.py +31 -30
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/circuit_library/hubregtsen_encoding_circuit.py +12 -13
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/circuit_library/multi_control_encoding_circuit.py +19 -16
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/circuit_library/param_z_feature_map.py +4 -3
- squlearn-0.7.0/src/squlearn/encoding_circuit/circuit_library/qcnn_encoding_circuit.py +709 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/circuit_library/yz_cx_encoding_circuit.py +26 -13
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/layered_encoding_circuit.py +12 -6
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/pruned_encoding_circuit.py +0 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/transpiled_encoding_circuit.py +1 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/matrix/fidelity_kernel.py +92 -34
- squlearn-0.7.0/src/squlearn/kernel/matrix/fidelity_kernel_pennylane.py +310 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/matrix/projected_quantum_kernel.py +19 -12
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/ml/qgpc.py +2 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/ml/qgpr.py +3 -2
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/ml/qkrr.py +2 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/ml/qsvc.py +1 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/ml/qsvr.py +1 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/optimization/kernel_optimizer.py +2 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/optimization/negative_log_likelihood.py +1 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/optimization/target_alignment.py +1 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/observables/observable_base.py +2 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/observables/observable_derivatives.py +25 -4
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/observables/observable_implemented/custom_observable.py +2 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/observables/observable_implemented/ising_hamiltonian.py +2 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/observables/observable_implemented/single_pauli.py +2 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/observables/observable_implemented/single_probability.py +3 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/observables/observable_implemented/summed_paulis.py +2 -3
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/observables/observable_implemented/summed_probabilities.py +2 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/optimizers/__init__.py +1 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/optimizers/optimizers_wrapper.py +2 -2
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/qnn/__init__.py +1 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/qnn/barren_plateau_analysis.py +8 -7
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/qnn/base_qnn.py +61 -7
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/qnn/loss.py +1 -0
- squlearn-0.7.0/src/squlearn/qnn/lowlevel_qnn.py +45 -0
- squlearn-0.7.0/src/squlearn/qnn/lowlevel_qnn_base.py +156 -0
- squlearn-0.7.0/src/squlearn/qnn/lowlevel_qnn_pennylane.py +987 -0
- squlearn-0.5.2/src/squlearn/qnn/qnn.py → squlearn-0.7.0/src/squlearn/qnn/lowlevel_qnn_qiskit.py +175 -128
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/qnn/qnnc.py +6 -3
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/qnn/qnnr.py +5 -2
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/qnn/training.py +12 -12
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/util/data_preprocessing.py +46 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/util/executor.py +580 -122
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/util/optree/optree.py +2 -2
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/util/optree/optree_derivative.py +4 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/util/optree/optree_evaluate.py +134 -39
- squlearn-0.7.0/src/squlearn/util/pennylane/__init__.py +4 -0
- squlearn-0.7.0/src/squlearn/util/pennylane/pennylane_circuit.py +583 -0
- squlearn-0.7.0/src/squlearn/util/pennylane/pennylane_gates.py +93 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/util/qfi.py +1 -1
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/encoding_circuit/test_layered_encoding_circuit.py +12 -16
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/kernel/ml/test_qgpc.py +6 -5
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/kernel/ml/test_qgpr.py +3 -2
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/kernel/ml/test_qkrr.py +3 -2
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/kernel/ml/test_qsvc.py +3 -2
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/kernel/ml/test_qsvr.py +3 -2
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/qnn/test_base_qnn.py +9 -8
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/qnn/test_qnnc.py +3 -2
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/qnn/test_qnnr.py +3 -2
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/qnn/test_training.py +8 -7
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/util/optree/test_optree_evaluate.py +1 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/util/test_executor.py +78 -7
- squlearn-0.5.2/docs/_static/schematic.png +0 -0
- squlearn-0.5.2/docs/_static/util/executor.png +0 -0
- squlearn-0.5.2/examples/kernel/example_fidelity_kernel.ipynb +0 -191
- squlearn-0.5.2/examples/kernel/example_projected_kernel.ipynb +0 -280
- squlearn-0.5.2/examples/kernel/example_regularization_mitigation.ipynb +0 -469
- squlearn-0.5.2/examples/kernel/qgpc_workflow.ipynb +0 -168
- squlearn-0.5.2/examples/kernel/qgpr_optimization_workflow.ipynb +0 -198
- squlearn-0.5.2/examples/kernel/qgpr_workflow.ipynb +0 -181
- squlearn-0.5.2/examples/qnn/classification_example.ipynb +0 -330
- squlearn-0.5.2/examples/qnn/regression_example.ipynb +0 -386
- squlearn-0.5.2/examples/qnn/regression_with_variance.ipynb +0 -399
- squlearn-0.5.2/examples/tutorials/kernel_digit_classification.ipynb +0 -663
- squlearn-0.5.2/examples/tutorials/quantum_bayesian_optimization.ipynb +0 -530
- {squlearn-0.5.2 → squlearn-0.7.0}/.github/CODE_OF_CONDUCT.md +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/.github/CONTRIBUTING.md +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/.github/workflows/doc_checks.yml +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/.github/workflows/format.yml +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/.github/workflows/publish.yml +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/.github/workflows/publish_docs.yml +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/.github/workflows/tests.yaml +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/CITATION.cff +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/LICENSE.txt +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/Makefile +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/README.md +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/_static/css/custom.css +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/_static/favicon.png +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/_static/logo.png +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/_static/qnn/qnn.svg +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/_templates/class.rst +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/_templates/class_with_call.rst +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/_templates/function.rst +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/conf.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/examples/example_kernel_digit_classification.nblink +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/examples/example_kernel_grid_search.nblink +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/examples/example_qnn_backend_mitigation.nblink +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/examples/example_quantum_bayesian_optimization.nblink +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/examples/examples_index.rst +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/index.rst +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/install/install.rst +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/make.bat +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/qiskit_settings.conf +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/requirements.txt +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/spelling_wordlist.txt +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/docs/user_guide/user_guide_index.rst +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/encoding_circuits/layered_encoding_circuit.ipynb +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/encoding_circuits/pruning_example.ipynb +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/tutorials/images/encoding_circuit.png +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/tutorials/images/pipeline.png +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/tutorials/images/projected_quantum_kernel.png +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/tutorials/images/quantum_bo.png +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/examples/tutorials/qnn_backend_mitigation.ipynb +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/circuit_library/__init__.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/circuit_library/qiskit_encoding_circuit.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/encoding_circuit_base.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/encoding_circuit/encoding_circuit_derivatives.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/__init__.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/matrix/__init__.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/matrix/kernel_matrix_base.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/matrix/kernel_util.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/matrix/regularization.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/ml/__init__.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/optimization/__init__.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/optimization/kernel_loss_base.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/kernel/optimization/kernel_optimization_base.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/observables/__init__.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/observables/observable_implemented/__init__.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/optimizers/adam.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/optimizers/approximated_gradients.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/optimizers/optimizer_base.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/util/__init__.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/src/squlearn/util/optree/__init__.py +0 -0
- {squlearn-0.5.2 → squlearn-0.7.0}/tests/util/optree/test_optree_derivative.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: squlearn
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: A library for quantum machine learning following the scikit-learnstandard.
|
|
5
5
|
Keywords: quantum,machine learning,qml
|
|
6
6
|
Author-email: David Kreplin <david.kreplin@ipa.fraunhofer.de>, Frederic Rapp <frederic.rapp@ipa.fraunhofer.de>, Marco Roth <marco.roth@ipa.fraunhofer.de>, Jan Schnabel <jan.schnabel@ipa.fraunhofer.de>, Moritz Willmann <moritz.willmann@ipa.fraunhofer.de>
|
|
@@ -14,8 +14,10 @@ Requires-Dist: dill>=0.3
|
|
|
14
14
|
Requires-Dist: numpy>=1.17
|
|
15
15
|
Requires-Dist: qiskit>=0.43.0
|
|
16
16
|
Requires-Dist: qiskit-aer>=0.12.0
|
|
17
|
-
Requires-Dist: qiskit-
|
|
17
|
+
Requires-Dist: qiskit-algorithms>=0.3.0
|
|
18
|
+
Requires-Dist: qiskit-ibm-runtime>=0.15.1
|
|
18
19
|
Requires-Dist: qiskit-machine-learning>=0.6.1
|
|
20
|
+
Requires-Dist: pennylane>=0.34.0
|
|
19
21
|
Requires-Dist: scipy>=1.5
|
|
20
22
|
Requires-Dist: scikit-learn>=1.0
|
|
21
23
|
Requires-Dist: tqdm>=4.0
|
|
@@ -48,7 +50,7 @@ Provides-Extra: examples
|
|
|
48
50
|
|
|
49
51
|
sQUlearn is a user-friendly, NISQ-ready Python library for quantum machine learning (QML), designed for seamless integration with classical machine learning tools like scikit-learn. The library's dual-layer architecture serves both QML researchers and practitioners, enabling efficient prototyping, experimentation, and pipelining. sQUlearn provides a comprehensive toolset that includes both quantum kernel methods and quantum neural networks, along with features like customizable data encoding strategies, automated execution handling, and specialized kernel regularization techniques. By focusing on NISQ-compatibility and end-to-end automation, sQUlearn aims to bridge the gap between current quantum computing capabilities and practical machine learning applications.
|
|
50
52
|
|
|
51
|
-
sQUlearn offers scikit-learn compatible high-level interfaces for various kernel methods and QNNs. They build on top of the low-level interfaces of the QNN engine and the quantum kernel engine. The executor is used to run experiments on simulated and real backends
|
|
53
|
+
sQUlearn offers scikit-learn compatible high-level interfaces for various kernel methods and QNNs. They build on top of the low-level interfaces of the QNN engine and the quantum kernel engine. The executor is used to run experiments on simulated and real backends of the Qiskit or PennyLane frameworks.
|
|
52
54
|
|
|
53
55
|
<p align="center">
|
|
54
56
|
<img width=500px alt="sQUlearn schematic" src="https://raw.githubusercontent.com/sQUlearn/squlearn/main/docs/_static/schematic.png" />
|
|
@@ -103,4 +105,13 @@ This project is maintained by the quantum computing group at the Fraunhofer Inst
|
|
|
103
105
|
For general questions regarding sQUlearn, use the [GitHub Discussions](https://github.com/sQUlearn/squlearn/discussions) or feel free to contact [sQUlearn@gmail.com](mailto:sQUlearn@gmail.com).
|
|
104
106
|
|
|
105
107
|
---
|
|
108
|
+
## Acknowledgements
|
|
106
109
|
|
|
110
|
+
This project was supported by the German Federal Ministry
|
|
111
|
+
of Economic Affairs and Climate Action through the
|
|
112
|
+
projects AutoQML (grant no. 01MQ22002A) and AQUAS
|
|
113
|
+
(grant no. 01MQ22003D), as well as the German Federal
|
|
114
|
+
Ministry of Education and Research through the project
|
|
115
|
+
H2Giga Degrad-EL3 (grant no. 03HY110D).
|
|
116
|
+
|
|
117
|
+
---
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
sQUlearn is a user-friendly, NISQ-ready Python library for quantum machine learning (QML), designed for seamless integration with classical machine learning tools like scikit-learn. The library's dual-layer architecture serves both QML researchers and practitioners, enabling efficient prototyping, experimentation, and pipelining. sQUlearn provides a comprehensive toolset that includes both quantum kernel methods and quantum neural networks, along with features like customizable data encoding strategies, automated execution handling, and specialized kernel regularization techniques. By focusing on NISQ-compatibility and end-to-end automation, sQUlearn aims to bridge the gap between current quantum computing capabilities and practical machine learning applications.
|
|
6
6
|
|
|
7
|
-
sQUlearn offers scikit-learn compatible high-level interfaces for various kernel methods and QNNs. They build on top of the low-level interfaces of the QNN engine and the quantum kernel engine. The executor is used to run experiments on simulated and real backends
|
|
7
|
+
sQUlearn offers scikit-learn compatible high-level interfaces for various kernel methods and QNNs. They build on top of the low-level interfaces of the QNN engine and the quantum kernel engine. The executor is used to run experiments on simulated and real backends of the Qiskit or PennyLane frameworks.
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<img width=500px alt="sQUlearn schematic" src="https://raw.githubusercontent.com/sQUlearn/squlearn/main/docs/_static/schematic.png" />
|
|
@@ -59,3 +59,13 @@ This project is maintained by the quantum computing group at the Fraunhofer Inst
|
|
|
59
59
|
For general questions regarding sQUlearn, use the [GitHub Discussions](https://github.com/sQUlearn/squlearn/discussions) or feel free to contact [sQUlearn@gmail.com](mailto:sQUlearn@gmail.com).
|
|
60
60
|
|
|
61
61
|
---
|
|
62
|
+
## Acknowledgements
|
|
63
|
+
|
|
64
|
+
This project was supported by the German Federal Ministry
|
|
65
|
+
of Economic Affairs and Climate Action through the
|
|
66
|
+
projects AutoQML (grant no. 01MQ22002A) and AQUAS
|
|
67
|
+
(grant no. 01MQ22003D), as well as the German Federal
|
|
68
|
+
Ministry of Education and Research through the project
|
|
69
|
+
H2Giga Degrad-EL3 (grant no. 03HY110D).
|
|
70
|
+
|
|
71
|
+
---
|
|
Binary file
|
|
Binary file
|
|
@@ -65,6 +65,7 @@ Encoding Circuits
|
|
|
65
65
|
encoding_circuit.ChebyshevRx
|
|
66
66
|
encoding_circuit.ParamZFeatureMap
|
|
67
67
|
encoding_circuit.QiskitEncodingCircuit
|
|
68
|
+
encoding_circuit.QCNNEncodingCircuit
|
|
68
69
|
|
|
69
70
|
Encoding Circuit Tools
|
|
70
71
|
------------------------------------
|
|
@@ -190,8 +191,11 @@ QNN Core
|
|
|
190
191
|
:toctree: generated/
|
|
191
192
|
:template: class.rst
|
|
192
193
|
|
|
193
|
-
qnn.
|
|
194
|
-
qnn.
|
|
194
|
+
qnn.lowlevel_qnn.LowLevelQNN
|
|
195
|
+
qnn.lowlevel_qnn_qiskit.LowLevelQNNQiskit
|
|
196
|
+
qnn.lowlevel_qnn_qiskit.Expec
|
|
197
|
+
qnn.lowlevel_qnn_pennylane.LowLevelQNNPennyLane
|
|
198
|
+
qnn.lowlevel_qnn_base.LowLevelQNNBase
|
|
195
199
|
qnn.loss.SquaredLoss
|
|
196
200
|
qnn.loss.VarianceLoss
|
|
197
201
|
qnn.loss.ParameterRegularizationLoss
|
|
@@ -249,6 +253,18 @@ OpTree Data Structure
|
|
|
249
253
|
util.optree.OpTreeContainer
|
|
250
254
|
util.optree.OpTreeValue
|
|
251
255
|
|
|
256
|
+
PennyLane interface
|
|
257
|
+
------------------------------------
|
|
258
|
+
|
|
259
|
+
.. currentmodule:: squlearn
|
|
260
|
+
|
|
261
|
+
.. autosummary::
|
|
262
|
+
:nosignatures:
|
|
263
|
+
:toctree: generated/
|
|
264
|
+
:template: class.rst
|
|
265
|
+
|
|
266
|
+
util.pennylane.PennyLaneCircuit
|
|
267
|
+
|
|
252
268
|
|
|
253
269
|
Base Classes
|
|
254
270
|
------------------------------------
|
|
@@ -210,7 +210,7 @@ where it is employed internally.
|
|
|
210
210
|
.. jupyter-execute::
|
|
211
211
|
|
|
212
212
|
from squlearn.encoding_circuit import TranspiledEncodingCircuit,ChebyshevRx
|
|
213
|
-
from
|
|
213
|
+
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
|
|
214
214
|
|
|
215
215
|
fm = TranspiledEncodingCircuit(ChebyshevRx(3,1),backend=FakeManilaV2(),initial_layout=[0,1,4])
|
|
216
216
|
fm.draw(output="mpl")
|
|
@@ -11,13 +11,12 @@ Overview
|
|
|
11
11
|
|
|
12
12
|
The :class:`Executor <squlearn.Executor>` class is the central component of sQUlearn, responsible
|
|
13
13
|
for running all quantum jobs.
|
|
14
|
-
Both high- and low-level methods utilize the Executor class to execute circuits or other
|
|
14
|
+
Both high- and low-level methods utilize the Executor class to execute circuits or to run other
|
|
15
15
|
quantum jobs.
|
|
16
|
-
The class provides a high-level interface to the
|
|
17
|
-
Quantum
|
|
18
|
-
It features a variety of comfort features, such as
|
|
19
|
-
restarts
|
|
20
|
-
required in the sub-program.
|
|
16
|
+
The class provides a high-level interface to the simulators of PennyLane and Qiskit,
|
|
17
|
+
as well as manages access to real QC hardware as for example IBM Quantum.
|
|
18
|
+
It features a variety of comfort features, such as result caching,
|
|
19
|
+
automatic restarts of failed jobs, logging of all actions, and Qiskit Session handling.
|
|
21
20
|
The Executor class is also responsible for handling the execution environment, and can be
|
|
22
21
|
initialized with a variety of objects that specify the execution environment (see figure below).
|
|
23
22
|
The following figure summarizes the structure of the Executor class; ingoing arrows indicate
|
|
@@ -33,13 +32,11 @@ Key Features of the Executor
|
|
|
33
32
|
|
|
34
33
|
The Executor class provides the following key comfort features when executing a quantum job:
|
|
35
34
|
|
|
36
|
-
- **Session handling:** Automatically manages the creation and handling of Qiskit sessions.
|
|
37
|
-
If Sessions are time out, the Executor automatically creates a new session and re-executes the
|
|
38
|
-
job.
|
|
39
35
|
- **Result caching:** Enables caching of results to avoid redundant job executions, and enable
|
|
40
|
-
restarts of failed executions. Caching is enabled as default
|
|
36
|
+
restarts of failed executions. Caching is enabled as default for remote executions, but can also
|
|
37
|
+
be manually activated for local execution.
|
|
41
38
|
The cached files are named after the hash out of different properties of the quantum job,
|
|
42
|
-
that include the backend name, the circuit, the options
|
|
39
|
+
that include the backend name, the circuit, the execution options, etc.
|
|
43
40
|
Before running a job, the Executor checks if a cached result exists and returns it if it does.
|
|
44
41
|
The caching can be disabled by setting the ``caching`` argument to ``False``; the folder for
|
|
45
42
|
the cached results can be specified by the ``cache_dir`` argument,
|
|
@@ -50,46 +47,99 @@ The Executor class provides the following key comfort features when executing a
|
|
|
50
47
|
between restarts can be adjusted by the ``wait_restart`` argument.
|
|
51
48
|
- **Logging:** The executor automatically logs all actions to a log file that ca be specified
|
|
52
49
|
via the ``log_file`` argument.
|
|
50
|
+
- **Random Seeds for shot-based simulators:** A random seeds can be specified for the PennyLane
|
|
51
|
+
and Qiskit shot-based simulators to make the computations utilizing this Executor object
|
|
52
|
+
reproducible. The random seeds can be set manually by specifying the ``seed`` argument.
|
|
53
53
|
- **Modified Qiskit Primitives:** The Executor allows the creation of modified Qiskit Primitives
|
|
54
|
-
that function
|
|
54
|
+
that function exactly as the Qiskit primitives but leverage the comfort features mentioned above.
|
|
55
55
|
The primitives can be obtained utilizing the :meth:`get_estimator` and
|
|
56
56
|
:meth:`get_sampler` methods. The modified primitives route all executions through the Executor
|
|
57
57
|
class, and thus benefit from all comfort features. The primitives are fully compatible with
|
|
58
58
|
the Qiskit framework, and can be used in the same way as regular primitives.
|
|
59
59
|
The Executor primitives are automatically utilized in the sQUlearn
|
|
60
60
|
sub-programs.
|
|
61
|
+
- **Qiskit Session handling:** Automatically manages the creation and handling of Qiskit sessions.
|
|
62
|
+
If Sessions are time out, the Executor automatically creates a new session and re-executes the
|
|
63
|
+
job.
|
|
61
64
|
|
|
62
65
|
Initialization of the Executor class
|
|
63
66
|
------------------------------------
|
|
64
67
|
|
|
65
|
-
The Estimator can be initialized with various inputs (``execution=``) that specify the
|
|
68
|
+
The Estimator can be initialized with various inputs (``execution=``) that specify the
|
|
66
69
|
execution environment:
|
|
67
70
|
|
|
68
|
-
-
|
|
69
|
-
|
|
71
|
+
- Default initialization with no backend specified: If no backend is specified, the Executor
|
|
72
|
+
class is initialized utilizing the fast PennyLane simulators.
|
|
73
|
+
If no shots are specified (``shots=None``) the statevector simulator being utilized,
|
|
74
|
+
which is the default. If shots are specified, the shot-based simulator is utilized.
|
|
70
75
|
|
|
71
|
-
..
|
|
76
|
+
.. jupyter-execute::
|
|
72
77
|
|
|
73
78
|
from squlearn import Executor
|
|
74
|
-
|
|
79
|
+
# Initialize the Executor with the PennyLane statevector simulator
|
|
80
|
+
# as default, shots=None (statevector simulator)
|
|
81
|
+
executor = Executor()
|
|
82
|
+
|
|
83
|
+
# Initialize the Executor with the PennyLane shot-based simulator
|
|
84
|
+
executor = Executor(shots=1234)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
- A string specifying the local simulator backend: Qiskit simulators are available by ``"qiskit"``,
|
|
88
|
+
``"statevector_simulator"`` and ``"qasm_simulator"``; PennyLane simulators can be initialized by
|
|
89
|
+
``"pennylane"`` or ``"default.qubit"``.
|
|
90
|
+
|
|
91
|
+
.. jupyter-execute::
|
|
92
|
+
|
|
93
|
+
from squlearn import Executor
|
|
94
|
+
# Initialize the Executor with the statevector simulator
|
|
95
|
+
executor = Executor("statevector_simulator")
|
|
96
|
+
|
|
97
|
+
# Initialize the Executor with the qasm simulator
|
|
98
|
+
executor = Executor("qasm_simulator", shots=1234)
|
|
99
|
+
|
|
100
|
+
# Initialize the Executor with qiksit is equivalent to "statevector_simulator"
|
|
101
|
+
executor = Executor("qiskit")
|
|
102
|
+
|
|
103
|
+
# Initialize the Executor with the PennyLane statevector simulator
|
|
104
|
+
executor = Executor("pennylane")
|
|
75
105
|
|
|
76
|
-
|
|
77
|
-
|
|
106
|
+
# Initialize the Executor with the PennyLane shot-based simulator
|
|
107
|
+
executor = Executor("default.qubit", shots=1234)
|
|
78
108
|
|
|
79
109
|
- A backend following the Qiskit backend standard, e.g. a Qiskit Aer backend, a fake backend,
|
|
80
|
-
a real IBM Quantum backend. This allows
|
|
81
|
-
of other quantum computing backends
|
|
110
|
+
a real IBM Quantum backend. This allows also the utilization
|
|
111
|
+
of other quantum computing backends, as long as they provide a Qiskit backend
|
|
82
112
|
class.
|
|
83
113
|
|
|
114
|
+
.. jupyter-execute::
|
|
115
|
+
|
|
116
|
+
from squlearn import Executor
|
|
117
|
+
from qiskit_aer import Aer
|
|
118
|
+
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
|
|
119
|
+
|
|
120
|
+
# Executor with the Aer statevector simulator
|
|
121
|
+
executor = Executor(Aer.get_backend("aer_simulator"))
|
|
122
|
+
|
|
123
|
+
# Executor with the FakeManilaV2 backend
|
|
124
|
+
executor = Executor(FakeManilaV2())
|
|
125
|
+
|
|
126
|
+
- A PennyLane device of a quantum computing backend. In the following example, the Executor is
|
|
127
|
+
initialized with a AWS device. Note that this example requires the PennyLane AWS plugin to be
|
|
128
|
+
installed (``pip install amazon-braket-pennylane-plugin``) and the AWS credentials to be
|
|
129
|
+
configured.
|
|
130
|
+
|
|
84
131
|
.. code-block:: python
|
|
85
132
|
|
|
86
133
|
from squlearn import Executor
|
|
87
|
-
|
|
134
|
+
import pennylane as qml
|
|
135
|
+
|
|
136
|
+
# Initialize the Executor with the PennyLane default.qubit device
|
|
137
|
+
dev = qml.device("braket.aws.qubit", device_arn="arn:aws:braket:::device/quantum-simulator/amazon/sv1", wires=2)
|
|
138
|
+
executor = Executor(dev, shots = 1234)
|
|
88
139
|
|
|
89
|
-
executor = Executor(Aer.get_backend("qasm_simulator"))
|
|
90
140
|
|
|
91
141
|
- A backend from the Qiskit Runtime Service, which utilizes the execution of quantum jobs on
|
|
92
|
-
IBM Quantum
|
|
142
|
+
IBM Quantum. Sessions and Primitives are automatically created and managed by the Executor class.
|
|
93
143
|
|
|
94
144
|
.. code-block:: python
|
|
95
145
|
|
|
@@ -97,7 +147,7 @@ execution environment:
|
|
|
97
147
|
from qiskit_ibm_runtime import QiskitRuntimeService
|
|
98
148
|
|
|
99
149
|
service = QiskitRuntimeService(channel="ibm_quantum", token="INSERT_YOUR_TOKEN_HERE")
|
|
100
|
-
executor = Executor(service.get_backend('
|
|
150
|
+
executor = Executor(service.get_backend('ibm_kyoto'))
|
|
101
151
|
|
|
102
152
|
- A pre-initialized Session object, which can be used to execute quantum jobs on the Qiskit
|
|
103
153
|
Runtime Service
|
|
@@ -108,7 +158,7 @@ execution environment:
|
|
|
108
158
|
from qiskit_ibm_runtime import QiskitRuntimeService
|
|
109
159
|
|
|
110
160
|
service = QiskitRuntimeService(channel="ibm_quantum", token="INSERT_YOUR_TOKEN_HERE")
|
|
111
|
-
session = service.create_session()
|
|
161
|
+
session = service.create_session(backend = service.get_backend('ibm_kyoto'))
|
|
112
162
|
executor = Executor(session)
|
|
113
163
|
|
|
114
164
|
- Pre-configured Primitive with options for transpiling and error mitigation. The Executor class
|
|
@@ -128,12 +178,13 @@ execution environment:
|
|
|
128
178
|
options.optimization_level = 0 # No optimization in transpilation
|
|
129
179
|
options.resilience_level = 2 # ZNE
|
|
130
180
|
|
|
131
|
-
|
|
181
|
+
session = service.create_session(backend = service.get_backend('ibm_kyoto'))
|
|
182
|
+
estimator = Estimator(session=session, options_estimator=options)
|
|
132
183
|
executor = Executor(estimator)
|
|
133
184
|
|
|
134
185
|
- If only the ``backend.run`` execution is wanted, this can be achieved by utilizing the
|
|
135
|
-
Qiskit IBM Provider package. However, most sQUlearn algorithms a build upon primitives
|
|
136
|
-
|
|
186
|
+
Qiskit IBM Provider package. However, most sQUlearn algorithms a build upon primitives,
|
|
187
|
+
and therefore, this access is not recommended, since it is likely to be deprecated in the future.
|
|
137
188
|
|
|
138
189
|
.. code-block:: python
|
|
139
190
|
|
|
@@ -144,8 +195,8 @@ execution environment:
|
|
|
144
195
|
provider = IBMProvider(instance="hub/group/project")
|
|
145
196
|
executor = Executor(provider.get_backend("ibmq_qasm_simulator"))
|
|
146
197
|
|
|
147
|
-
|
|
148
|
-
and setting options for caching, logging and restarts:
|
|
198
|
+
The following code shows an example for configuring the Executor class with a
|
|
199
|
+
backend from the Qiskit Runtime Service and setting options for caching, logging and restarts:
|
|
149
200
|
|
|
150
201
|
.. code-block:: python
|
|
151
202
|
|
|
@@ -159,7 +210,7 @@ and setting options for caching, logging and restarts:
|
|
|
159
210
|
options.optimization_level = 0 # No optimization in transpilation
|
|
160
211
|
options.resilience_level = 2 # ZNE
|
|
161
212
|
|
|
162
|
-
|
|
213
|
+
executor = Executor(service.get_backend('ibm_kyoto'), # Specify the backend
|
|
163
214
|
cache_dir='cache' # Set cache folder to "cache"
|
|
164
215
|
caching=True, # Enable caching default for remote executions
|
|
165
216
|
log_file="executor.log", # Set-up logging file
|
|
@@ -168,24 +219,28 @@ and setting options for caching, logging and restarts:
|
|
|
168
219
|
options_estimator=options # Set options for the Estimator primitive
|
|
169
220
|
)
|
|
170
221
|
|
|
222
|
+
executor.set_shots(1234) # Shots an be adjusted after initialization
|
|
223
|
+
|
|
171
224
|
|
|
172
225
|
Utilizing Executor Primitives in Qiskit Routines
|
|
173
226
|
-------------------------------------------------
|
|
174
227
|
|
|
175
228
|
The Executor class provides an Estimator and Sampler primitive that are compatible with the
|
|
176
|
-
Qiskit framework.
|
|
177
|
-
|
|
178
|
-
|
|
229
|
+
Qiskit framework. This is only possible, in case the Executor class is initialized with a backend
|
|
230
|
+
compatible with Qiskit (and not PennyLane). The primitives can be obtained by the
|
|
231
|
+
:meth:`get_estimator` and :meth:`get_sampler` methods of the Executor class.
|
|
232
|
+
The primitives automatically utilized the parent Executor class for all executions,
|
|
233
|
+
and thus benefit from all comfort features of the Executor.
|
|
179
234
|
|
|
180
235
|
The following example shows, how to evaluate the Quantum Fisher Information utilizing the
|
|
181
|
-
Executor primitive (see `QFI in Qiskit <https://qiskit.
|
|
236
|
+
Executor primitive (see `QFI in Qiskit <https://qiskit-community.github.io/qiskit-algorithms/stubs/qiskit_algorithms.gradients.QFI.html>`_)
|
|
182
237
|
|
|
183
238
|
.. jupyter-execute::
|
|
184
239
|
|
|
185
240
|
from squlearn import Executor
|
|
186
|
-
from
|
|
241
|
+
from qiskit_algorithms.gradients import LinCombQGT, QFI
|
|
187
242
|
from qiskit.quantum_info import Pauli
|
|
188
|
-
# Executor
|
|
243
|
+
# Executor initialization (other ways are possible, see above)
|
|
189
244
|
executor = Executor(execution="statevector_simulator")
|
|
190
245
|
# This creates the QFI primitive that utilizes the Estimator of the Executor class
|
|
191
246
|
qfi = QFI(LinCombQGT(executor.get_estimator()))
|
|
@@ -199,8 +254,8 @@ not creating or referring to the Executor primitives! Instead they refer to the
|
|
|
199
254
|
Qiskit Primitives used internally that do not utilize any caching, restarts, etc.
|
|
200
255
|
|
|
201
256
|
|
|
202
|
-
Setting Options for Primitives
|
|
203
|
-
|
|
257
|
+
Setting Options for Qiskit Primitives
|
|
258
|
+
--------------------------------------
|
|
204
259
|
|
|
205
260
|
Options for the Primitives can be provided through the ``options_estimator`` and
|
|
206
261
|
``options_sampler`` arguments, but they are also automatically copied from inputted primitives.
|
|
@@ -217,7 +272,7 @@ Options for the Primitives can be provided through the ``options_estimator`` and
|
|
|
217
272
|
options.execution.shots = 5000
|
|
218
273
|
options.resilience_level = 0 # No Mitigation
|
|
219
274
|
|
|
220
|
-
executor = Executor(service.get_backend("
|
|
275
|
+
executor = Executor(service.get_backend("ibm_kyoto"),options_estimator=options)
|
|
221
276
|
|
|
222
277
|
Options can be adjusted by the :meth:`set_options` method of the Primitives that are created by the
|
|
223
278
|
Executor class.
|
|
@@ -229,7 +284,7 @@ Executor class.
|
|
|
229
284
|
|
|
230
285
|
service = QiskitRuntimeService(channel="ibm_quantum", token="INSERT_YOUR_TOKEN_HERE")
|
|
231
286
|
|
|
232
|
-
executor = Executor(service.get_backend("
|
|
287
|
+
executor = Executor(service.get_backend("ibm_kyoto"))
|
|
233
288
|
estimator = executor.get_estimator()
|
|
234
289
|
estimator.set_options(resilience_level=2)
|
|
235
290
|
|
|
@@ -238,3 +293,4 @@ Executor class.
|
|
|
238
293
|
* :class:`Executor <squlearn.Executor>`
|
|
239
294
|
* `Qiskit Runtime <https://quantum-computing.ibm.com/lab/docs/iql/runtime>`_
|
|
240
295
|
* `Qsikit Primitives <https://qiskit.org/documentation/apidoc/primitives.html>`_
|
|
296
|
+
* `PennyLane Devices <https://docs.pennylane.ai/en/stable/code/api/pennylane.device.html>`_
|
|
@@ -199,7 +199,7 @@ the following example:
|
|
|
199
199
|
enc_circ = ChebyshevPQC(num_qubits=4, num_features= 1, num_layers=2)
|
|
200
200
|
pqk_instance = ProjectedQuantumKernel(
|
|
201
201
|
encoding_circuit=enc_circ,
|
|
202
|
-
executor=Executor(
|
|
202
|
+
executor=Executor(),
|
|
203
203
|
measurement='XYZ',
|
|
204
204
|
outer_kernel='gaussian'
|
|
205
205
|
)
|
|
@@ -242,7 +242,7 @@ training and test data and shows how to optimize kernels.
|
|
|
242
242
|
enc_circ = ChebyshevPQC(num_qubits=4, num_features=1, num_layers=2)
|
|
243
243
|
pqk_instance = ProjectedQuantumKernel(
|
|
244
244
|
encoding_circuit=enc_circ,
|
|
245
|
-
executor=Executor(
|
|
245
|
+
executor=Executor(),
|
|
246
246
|
measurement='XYZ',
|
|
247
247
|
outer_kernel='gaussian',
|
|
248
248
|
parameter_seed=0
|
|
@@ -274,7 +274,7 @@ training and test data and shows how to optimize kernels.
|
|
|
274
274
|
enc_circ = ChebyshevPQC(num_qubits=4, num_features=1, num_layers=2)
|
|
275
275
|
pqk_instance = ProjectedQuantumKernel(
|
|
276
276
|
encoding_circuit=enc_circ,
|
|
277
|
-
executor=Executor(
|
|
277
|
+
executor=Executor(),
|
|
278
278
|
measurement='XYZ',
|
|
279
279
|
outer_kernel='gaussian',
|
|
280
280
|
parameter_seed=0
|
|
@@ -292,8 +292,7 @@ training and test data and shows how to optimize kernels.
|
|
|
292
292
|
|
|
293
293
|
*Note:* The same workflow has to be used for FQKs!
|
|
294
294
|
|
|
295
|
-
|
|
296
|
-
------------
|
|
295
|
+
.. rubric:: References
|
|
297
296
|
|
|
298
297
|
[1] `M. Schuld, "Supervised quantum machine learning models are kernel methods". arXiv:2101.11020v2 (2021). <http://arxiv.org/abs/2101.11020v2>`_
|
|
299
298
|
|
|
@@ -99,7 +99,7 @@ The map can be for example obtained in the transpiled encoding circuit.
|
|
|
99
99
|
|
|
100
100
|
from squlearn.encoding_circuit import ChebyshevRx,TranspiledEncodingCircuit
|
|
101
101
|
from squlearn.observables import SummedPaulis
|
|
102
|
-
from
|
|
102
|
+
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
|
|
103
103
|
fm = TranspiledEncodingCircuit(ChebyshevRx(3,1),backend=FakeManilaV2(),initial_layout=[0,1,4])
|
|
104
104
|
ob = SummedPaulis(num_qubits=3, op_str="Z")
|
|
105
105
|
print("Observable before mapping:\n",ob,"\n\n")
|
|
@@ -137,7 +137,7 @@ and the Adam optimizer for optimization.
|
|
|
137
137
|
|
|
138
138
|
op = SummedPaulis(num_qubits = 4)
|
|
139
139
|
pqc = ChebyshevPQC(num_qubits = 4, num_features = 1, num_layers = 2)
|
|
140
|
-
qnn = QNNRegressor(pqc, op, Executor(
|
|
140
|
+
qnn = QNNRegressor(pqc, op, Executor(), SquaredLoss(), Adam())
|
|
141
141
|
|
|
142
142
|
The QNN can be trained utilizing the :meth:`fit <squlearn.qnn.QNNRegressor.fit>` method:
|
|
143
143
|
|
|
@@ -217,6 +217,7 @@
|
|
|
217
217
|
"a sQUlearn EncodingCircuitBase object. The TwoLocal circuit below can be \n",
|
|
218
218
|
"replaced by any other QuantumCircuit\n",
|
|
219
219
|
"\"\"\"\n",
|
|
220
|
+
"\n",
|
|
220
221
|
"local = TwoLocal(3, \"ry\", \"cx\", \"linear\", reps=2, insert_barriers=True)\n",
|
|
221
222
|
"enc_circ9 = QiskitEncodingCircuit(local)\n",
|
|
222
223
|
"enc_circ9.draw(\"mpl\")"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"metadata": {},
|
|
16
16
|
"outputs": [],
|
|
17
17
|
"source": [
|
|
18
|
-
"from
|
|
18
|
+
"from qiskit_aer import Aer\n",
|
|
19
19
|
"from qiskit.circuit.random import random_circuit\n",
|
|
20
20
|
"from qiskit.primitives import Sampler, Estimator, BackendSampler, BackendEstimator\n",
|
|
21
21
|
"from qiskit.quantum_info import SparsePauliOp\n",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"cell_type": "markdown",
|
|
30
30
|
"metadata": {},
|
|
31
31
|
"source": [
|
|
32
|
-
"The following
|
|
32
|
+
"The following cells shows different ways to initialize of the ``Executor`` class with Qiskit backends or services."
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
{
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"executor = Executor(\"statevector_simulator\")\n",
|
|
45
45
|
"executor = Executor(\"qasm_simulator\")\n",
|
|
46
46
|
"# from a backend following the Qiskit backend standard:\n",
|
|
47
|
-
"executor = Executor(Aer.get_backend(\"
|
|
47
|
+
"executor = Executor(Aer.get_backend(\"aer_simulator_statevector\"))"
|
|
48
48
|
]
|
|
49
49
|
},
|
|
50
50
|
{
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
"# from a backend obtained from the Qiskit IBM runtime service (here, the account has to be set-up previously):\n",
|
|
61
61
|
"service = QiskitRuntimeService(channel=\"ibm_quantum\")\n",
|
|
62
62
|
"# Alternative: service = QiskitRuntimeService(channel=\"ibm_quantum\",token=\"YOUR_TOKEN_HERE\")\n",
|
|
63
|
-
"executor = Executor(service.get_backend(\"
|
|
63
|
+
"executor = Executor(service.get_backend(\"ibm_kyoto\"))\n",
|
|
64
64
|
"# from a session set-up with the Qiskit IBM runtime service:\n",
|
|
65
|
-
"session = Session(service, backend=service.get_backend(\"
|
|
65
|
+
"session = Session(service, backend=service.get_backend(\"ibm_kyoto\"), max_time=28800)\n",
|
|
66
66
|
"executor = Executor(session)\n",
|
|
67
67
|
"\n",
|
|
68
68
|
"# from the Qiskit IBM runtime Estimator primitive:\n",
|
|
69
|
-
"session = Session(service, backend=service.get_backend(\"
|
|
69
|
+
"session = Session(service, backend=service.get_backend(\"ibm_kyoto\"), max_time=28800)\n",
|
|
70
70
|
"estimator = RuntimeEstimator(session=session)\n",
|
|
71
71
|
"executor = Executor(estimator)"
|
|
72
72
|
]
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"# from a Qiskit simulator primitive:\n",
|
|
81
81
|
"executor = Executor(Estimator())\n",
|
|
82
82
|
"executor = Executor(Sampler())\n",
|
|
83
|
-
"executor = Executor(BackendEstimator(Aer.get_backend(\"
|
|
84
|
-
"executor = Executor(BackendSampler(Aer.get_backend(\"
|
|
83
|
+
"executor = Executor(BackendEstimator(Aer.get_backend(\"aer_simulator\")))\n",
|
|
84
|
+
"executor = Executor(BackendSampler(Aer.get_backend(\"aer_simulator\")))"
|
|
85
85
|
]
|
|
86
86
|
},
|
|
87
87
|
{
|
|
@@ -133,8 +133,8 @@
|
|
|
133
133
|
"name": "stdout",
|
|
134
134
|
"output_type": "stream",
|
|
135
135
|
"text": [
|
|
136
|
-
"EstimatorResult(values=array([-0.
|
|
137
|
-
"SamplerResult(quasi_dists=[{0: 0.
|
|
136
|
+
"EstimatorResult(values=array([-0.11825966]), metadata=[{'variance': 0.9860146523163866, 'shots': 4321}])\n",
|
|
137
|
+
"SamplerResult(quasi_dists=[{0: 0.3935546875, 3: 0.541015625, 1: 0.02734375, 2: 0.0380859375}], metadata=[{'shots': 1024}])\n"
|
|
138
138
|
]
|
|
139
139
|
}
|
|
140
140
|
],
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
{
|
|
170
170
|
"data": {
|
|
171
171
|
"text/plain": [
|
|
172
|
-
"Result(backend_name='
|
|
172
|
+
"Result(backend_name='aer_simulator', backend_version='0.13.2', qobj_id='', job_id='3fa1608d-e234-4d64-b957-9c61555f4a89', success=True, results=[ExperimentResult(shots=1024, success=True, meas_level=2, data=ExperimentResultData(), header=QobjExperimentHeader(creg_sizes=[], global_phase=0.0, memory_slots=0, n_qubits=2, name='circuit-158', qreg_sizes=[['q', 2]], metadata={}), status=DONE, seed_simulator=1643401811, metadata={'batched_shots_optimization': False, 'required_memory_mb': 0, 'method': 'stabilizer', 'active_input_qubits': [], 'device': 'CPU', 'remapped_qubits': False, 'num_qubits': 0, 'num_clbits': 0, 'time_taken': 1.84e-05, 'input_qubit_map': [], 'max_memory_mb': 16135, 'measure_sampling': False, 'parallel_shots': 1, 'parallel_state_update': 12, 'runtime_parameter_bind': False, 'num_bind_params': 1}, time_taken=1.84e-05)], date=2024-04-10T17:05:42.732421, status=COMPLETED, header=None, metadata={'omp_enabled': True, 'parallel_experiments': 1, 'max_memory_mb': 16135, 'max_gpu_memory_mb': 0, 'time_taken_execute': 6.57e-05, 'time_taken_parameter_binding': 5.7e-06}, time_taken=0.0)"
|
|
173
173
|
]
|
|
174
174
|
},
|
|
175
175
|
"execution_count": 7,
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
}
|
|
179
179
|
],
|
|
180
180
|
"source": [
|
|
181
|
-
"job = executor.
|
|
181
|
+
"job = executor.qiskit_execute(circuit)\n",
|
|
182
182
|
"job.result()"
|
|
183
183
|
]
|
|
184
184
|
},
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"name": "stdout",
|
|
199
199
|
"output_type": "stream",
|
|
200
200
|
"text": [
|
|
201
|
-
"EstimatorResult(values=array([-0.
|
|
201
|
+
"EstimatorResult(values=array([-0.10807683]), metadata=[{'variance': 0.9883193979382295, 'shots': 4321}])\n"
|
|
202
202
|
]
|
|
203
203
|
}
|
|
204
204
|
],
|
|
@@ -226,9 +226,9 @@
|
|
|
226
226
|
"name": "stdout",
|
|
227
227
|
"output_type": "stream",
|
|
228
228
|
"text": [
|
|
229
|
-
"EstimatorResult(values=array([-0.
|
|
229
|
+
"EstimatorResult(values=array([-0.11455682]), metadata=[{'variance': 0.9868767360105952, 'shots': 4321}])\n",
|
|
230
230
|
"EstimatorResult(values=array([-0.11345219]), metadata=[{'variance': 0.9871286010365417, 'shots': 1234}])\n",
|
|
231
|
-
"EstimatorResult(values=array([-0.
|
|
231
|
+
"EstimatorResult(values=array([-0.11455682]), metadata=[{'variance': 0.9868767360105952, 'shots': 4321}])\n"
|
|
232
232
|
]
|
|
233
233
|
}
|
|
234
234
|
],
|