qadence 1.11.0__tar.gz → 1.11.2__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.
- {qadence-1.11.0 → qadence-1.11.2}/.github/workflows/test_fast.yml +1 -1
- qadence-1.11.2/LICENSE +13 -0
- {qadence-1.11.0 → qadence-1.11.2}/PKG-INFO +12 -11
- {qadence-1.11.0 → qadence-1.11.2}/README.md +2 -2
- {qadence-1.11.0 → qadence-1.11.2}/mkdocs.yml +1 -0
- {qadence-1.11.0 → qadence-1.11.2}/pyproject.toml +10 -9
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backend.py +10 -3
- qadence-1.11.2/qadence/backends/agpsr_utils.py +96 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/api.py +8 -1
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/horqrux/backend.py +6 -5
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/horqrux/config.py +17 -1
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/horqrux/convert_ops.py +20 -97
- qadence-1.11.0/qadence/backends/gpsr.py → qadence-1.11.2/qadence/backends/parameter_shift_rules.py +48 -30
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pulser/config.py +18 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pyqtorch/config.py +18 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/blocks/primitive.py +2 -3
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/hamiltonians.py +10 -1
- {qadence-1.11.0 → qadence-1.11.2}/qadence/draw/utils.py +2 -1
- {qadence-1.11.0 → qadence-1.11.2}/qadence/engines/torch/differentiable_backend.py +5 -8
- {qadence-1.11.0 → qadence-1.11.2}/qadence/extensions.py +0 -10
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/callbacks/callbackmanager.py +4 -2
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/constructors.py +269 -4
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/models.py +2 -7
- qadence-1.11.2/qadence/ml_tools/qcnn_model.py +158 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/trainer.py +1 -9
- {qadence-1.11.0 → qadence-1.11.2}/qadence/model.py +42 -1
- {qadence-1.11.0 → qadence-1.11.2}/qadence/parameters.py +2 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/register.py +5 -1
- {qadence-1.11.0 → qadence-1.11.2}/qadence/serialization.py +1 -1
- {qadence-1.11.0 → qadence-1.11.2}/qadence/types.py +1 -3
- {qadence-1.11.0 → qadence-1.11.2}/qadence/utils.py +16 -7
- qadence-1.11.0/LICENSE +0 -202
- {qadence-1.11.0 → qadence-1.11.2}/.coveragerc +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/.github/ISSUE_TEMPLATE/bug-report.yml +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/.github/ISSUE_TEMPLATE/new-feature.yml +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/.github/workflows/build_docs.yml +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/.github/workflows/lint.yml +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/.github/workflows/test_all.yml +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/.github/workflows/test_examples.yml +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/.gitignore +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/.pre-commit-config.yaml +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/MANIFEST.in +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/analog/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/analog/addressing.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/analog/constants.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/analog/device.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/analog/hamiltonian_terms.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/analog/parse_analog.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/horqrux/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/jax_utils.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pulser/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pulser/backend.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pulser/channels.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pulser/cloud.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pulser/convert_ops.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pulser/devices.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pulser/pulses.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pulser/waveforms.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pyqtorch/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pyqtorch/backend.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/pyqtorch/convert_ops.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/backends/utils.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/blocks/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/blocks/abstract.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/blocks/analog.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/blocks/block_to_tensor.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/blocks/composite.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/blocks/embedding.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/blocks/manipulate.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/blocks/matrix.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/blocks/utils.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/circuit.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/ala.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/daqc/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/daqc/daqc.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/daqc/gen_parser.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/daqc/utils.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/feature_maps.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/hea.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/iia.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/qft.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/rydberg_feature_maps.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/rydberg_hea.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/constructors/utils.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/decompose.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/divergences.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/draw/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/draw/assets/dark/measurement.png +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/draw/assets/dark/measurement.svg +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/draw/assets/light/measurement.png +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/draw/assets/light/measurement.svg +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/draw/themes.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/draw/vizbackend.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/engines/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/engines/differentiable_backend.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/engines/jax/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/engines/jax/differentiable_backend.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/engines/jax/differentiable_expectation.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/engines/torch/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/engines/torch/differentiable_expectation.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/exceptions/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/exceptions/exceptions.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/execution.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/libs.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/log_config.yaml +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/logger.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/measurements/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/measurements/protocols.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/measurements/samples.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/measurements/shadow.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/measurements/tomography.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/measurements/utils.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/mitigations/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/mitigations/analog_zne.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/mitigations/protocols.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/mitigations/readout.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/callbacks/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/callbacks/callback.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/callbacks/saveload.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/callbacks/writer_registry.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/config.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/data.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/information/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/information/information_content.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/loss/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/loss/loss.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/optimize_step.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/parameters.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/stages.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/tensors.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/train_utils/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/train_utils/accelerator.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/train_utils/base_trainer.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/train_utils/config_manager.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/train_utils/distribution.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/train_utils/execution.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/ml_tools/utils.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/noise/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/noise/protocols.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/operations/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/operations/analog.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/operations/control_ops.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/operations/ham_evo.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/operations/parametric.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/operations/primitive.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/overlap.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/pasqal_cloud_connection.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/protocols.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/py.typed +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/qubit_support.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/serial_expr_grammar.peg +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/states.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/transpile/__init__.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/transpile/apply_fn.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/transpile/block.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/transpile/circuit.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/transpile/digitalize.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/transpile/flatten.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/transpile/invert.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/transpile/noise.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/qadence/transpile/transpile.py +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/renovate.json +0 -0
- {qadence-1.11.0 → qadence-1.11.2}/setup.py +0 -0
qadence-1.11.2/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
PASQAL OPEN-SOURCE SOFTWARE LICENSE AGREEMENT (MIT-derived)
|
2
|
+
|
3
|
+
The author of the License is:
|
4
|
+
Pasqal, a Société par Actions Simplifiée (Simplified Joint Stock Company) registered under number 849 441 522 at the Registre du commerce et des sociétés (Trade and Companies Register) of Evry – France, headquartered at 24 rue Émile Baudot – 91120 – Palaiseau – France, duly represented by its Président, M. Georges-Olivier REYMOND, Hereafter referred to as « the Licensor »
|
5
|
+
|
6
|
+
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software (the “Licensee”) and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The Software is “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise arising from, out of or in connection with the Software or the use or other dealings in the Software.
|
8
|
+
|
9
|
+
- If use of the Software leads to the necessary use of any patent of the Licensor and/or any of its Affiliates (defined as a company owned or controlled by the Licensor), the Licensee is granted a royalty-free license, in any country where such patent is in force, to use the object of such patent; or use the process covered by such patent,
|
10
|
+
|
11
|
+
- Such a patent license is granted for internal research or academic use of the Licensee's, which includes use by employees and students of the Licensee, acting on behalf of the Licensee, for research purposes only.
|
12
|
+
|
13
|
+
- The License is governed by the laws of France. Any dispute relating to the License, notably its execution, performance and/or termination shall be brought to, heard and tried by the Tribunal Judiciaire de Paris, regardless of the rules of jurisdiction in the matter.
|
@@ -1,17 +1,18 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: qadence
|
3
|
-
Version: 1.11.
|
3
|
+
Version: 1.11.2
|
4
4
|
Summary: Pasqal interface for circuit-based quantum computing SDKs
|
5
5
|
Author-email: Aleksander Wennersteen <aleksander.wennersteen@pasqal.com>, Gert-Jan Both <gert-jan.both@pasqal.com>, Niklas Heim <niklas.heim@pasqal.com>, Mario Dagrada <mario.dagrada@pasqal.com>, Vincent Elfving <vincent.elfving@pasqal.com>, Dominik Seitz <dominik.seitz@pasqal.com>, Roland Guichard <roland.guichard@pasqal.com>, "Joao P. Moutinho" <joao.moutinho@pasqal.com>, Vytautas Abramavicius <vytautas.abramavicius@pasqal.com>, Gergana Velikova <gergana.velikova@pasqal.com>, Eduardo Maschio <eduardo.maschio@pasqal.com>, Smit Chaudhary <smit.chaudhary@pasqal.com>, Ignacio Fernández Graña <ignacio.fernandez-grana@pasqal.com>, Charles Moussa <charles.moussa@pasqal.com>, Giorgio Tosti Balducci <giorgio.tosti-balducci@pasqal.com>, Daniele Cucurachi <daniele.cucurachi@pasqal.com>, Pim Venderbosch <pim.venderbosch@pasqal.com>, Manu Lahariya <manu.lahariya@pasqal.com>
|
6
|
-
License:
|
6
|
+
License: PASQAL OPEN-SOURCE SOFTWARE LICENSE (MIT-derived)
|
7
7
|
License-File: LICENSE
|
8
|
-
Classifier: License ::
|
8
|
+
Classifier: License :: Other/Proprietary License
|
9
9
|
Classifier: Programming Language :: Python
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
11
11
|
Classifier: Programming Language :: Python :: 3.9
|
12
12
|
Classifier: Programming Language :: Python :: 3.10
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
15
16
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
16
17
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
17
18
|
Requires-Python: >=3.9
|
@@ -23,11 +24,11 @@ Requires-Dist: nevergrad
|
|
23
24
|
Requires-Dist: numpy
|
24
25
|
Requires-Dist: openfermion
|
25
26
|
Requires-Dist: pasqal-cloud
|
26
|
-
Requires-Dist: pyqtorch==1.7.
|
27
|
+
Requires-Dist: pyqtorch==1.7.5
|
27
28
|
Requires-Dist: pyyaml
|
28
29
|
Requires-Dist: rich
|
29
30
|
Requires-Dist: scipy
|
30
|
-
Requires-Dist: sympy<1.13
|
31
|
+
Requires-Dist: sympy<1.13.4
|
31
32
|
Requires-Dist: sympytorch>=0.1.2
|
32
33
|
Requires-Dist: tensorboard>=2.12.0
|
33
34
|
Requires-Dist: torch
|
@@ -43,7 +44,7 @@ Requires-Dist: nvidia-pyindex; extra == 'dlprof'
|
|
43
44
|
Provides-Extra: horqrux
|
44
45
|
Requires-Dist: einops; extra == 'horqrux'
|
45
46
|
Requires-Dist: flax; extra == 'horqrux'
|
46
|
-
Requires-Dist: horqrux==0.
|
47
|
+
Requires-Dist: horqrux==0.8.0; extra == 'horqrux'
|
47
48
|
Requires-Dist: jax; extra == 'horqrux'
|
48
49
|
Requires-Dist: jaxopt; extra == 'horqrux'
|
49
50
|
Requires-Dist: optax; extra == 'horqrux'
|
@@ -55,9 +56,9 @@ Requires-Dist: mlflow; extra == 'mlflow'
|
|
55
56
|
Provides-Extra: protocols
|
56
57
|
Requires-Dist: qadence-protocols; extra == 'protocols'
|
57
58
|
Provides-Extra: pulser
|
58
|
-
Requires-Dist: pasqal-cloud==0.
|
59
|
-
Requires-Dist: pulser-core==1.
|
60
|
-
Requires-Dist: pulser-simulation==1.
|
59
|
+
Requires-Dist: pasqal-cloud==0.20.2; extra == 'pulser'
|
60
|
+
Requires-Dist: pulser-core==1.4.0; extra == 'pulser'
|
61
|
+
Requires-Dist: pulser-simulation==1.4.0; extra == 'pulser'
|
61
62
|
Provides-Extra: visualization
|
62
63
|
Requires-Dist: graphviz; extra == 'visualization'
|
63
64
|
Description-Content-Type: text/markdown
|
@@ -84,7 +85,7 @@ programs** with tunable qubit interactions and arbitrary register topologies rea
|
|
84
85
|
[](https://github.com/pasqal-io/qadence/actions/workflows/test_fast.yml)
|
85
86
|
[](https://pasqal-io.github.io/qadence/latest)
|
86
87
|
[](https://pypi.org/project/qadence/)
|
87
|
-
[](https://opensource.org/licenses/MIT)
|
88
89
|

|
89
90
|
|
90
91
|
|
@@ -215,4 +216,4 @@ doi = {10.1109/MS.2025.3536607}
|
|
215
216
|
```
|
216
217
|
|
217
218
|
## License
|
218
|
-
Qadence is a free and open source software package, released under the
|
219
|
+
Qadence is a free and open source software package, released under the PASQAL OPEN-SOURCE SOFTWARE LICENSE (MIT-derived).
|
@@ -20,7 +20,7 @@ programs** with tunable qubit interactions and arbitrary register topologies rea
|
|
20
20
|
[](https://github.com/pasqal-io/qadence/actions/workflows/test_fast.yml)
|
21
21
|
[](https://pasqal-io.github.io/qadence/latest)
|
22
22
|
[](https://pypi.org/project/qadence/)
|
23
|
-
[](https://opensource.org/licenses/MIT)
|
24
24
|

|
25
25
|
|
26
26
|
|
@@ -151,4 +151,4 @@ doi = {10.1109/MS.2025.3536607}
|
|
151
151
|
```
|
152
152
|
|
153
153
|
## License
|
154
|
-
Qadence is a free and open source software package, released under the
|
154
|
+
Qadence is a free and open source software package, released under the PASQAL OPEN-SOURCE SOFTWARE LICENSE (MIT-derived).
|
@@ -45,6 +45,7 @@ nav:
|
|
45
45
|
- tutorials/qml/index.md
|
46
46
|
- Configuring a QNN: tutorials/qml/config_qnn.md
|
47
47
|
- Quantum circuit learning: tutorials/qml/qcl.md
|
48
|
+
- Classification with QNN: tutorials/qml/classification.md
|
48
49
|
- Solving MaxCut with QAOA: tutorials/qml/qaoa.md
|
49
50
|
- Solving a 1D ODE: tutorials/qml/dqc_1d.md
|
50
51
|
|
@@ -27,16 +27,17 @@ authors = [
|
|
27
27
|
{ name = "Manu Lahariya", email = "manu.lahariya@pasqal.com" },
|
28
28
|
]
|
29
29
|
requires-python = ">=3.9"
|
30
|
-
license = { text = "
|
31
|
-
version = "1.11.
|
30
|
+
license = { text = "PASQAL OPEN-SOURCE SOFTWARE LICENSE (MIT-derived)" }
|
31
|
+
version = "1.11.2"
|
32
32
|
classifiers = [
|
33
|
-
"License ::
|
33
|
+
"License :: Other/Proprietary License",
|
34
34
|
"Programming Language :: Python",
|
35
35
|
"Programming Language :: Python :: 3",
|
36
36
|
"Programming Language :: Python :: 3.9",
|
37
37
|
"Programming Language :: Python :: 3.10",
|
38
38
|
"Programming Language :: Python :: 3.11",
|
39
39
|
"Programming Language :: Python :: 3.12",
|
40
|
+
"Programming Language :: Python :: 3.13",
|
40
41
|
"Programming Language :: Python :: Implementation :: CPython",
|
41
42
|
"Programming Language :: Python :: Implementation :: PyPy",
|
42
43
|
]
|
@@ -44,7 +45,7 @@ dependencies = [
|
|
44
45
|
"numpy",
|
45
46
|
"torch",
|
46
47
|
"openfermion",
|
47
|
-
"sympy<1.13",
|
48
|
+
"sympy<1.13.4",
|
48
49
|
"sympytorch>=0.1.2",
|
49
50
|
"rich",
|
50
51
|
"tensorboard>=2.12.0",
|
@@ -52,7 +53,7 @@ dependencies = [
|
|
52
53
|
"jsonschema",
|
53
54
|
"nevergrad",
|
54
55
|
"scipy",
|
55
|
-
"pyqtorch==1.7.
|
56
|
+
"pyqtorch==1.7.5",
|
56
57
|
"pyyaml",
|
57
58
|
"matplotlib",
|
58
59
|
"Arpeggio==2.0.2",
|
@@ -65,9 +66,9 @@ allow-ambiguous-features = true
|
|
65
66
|
|
66
67
|
[project.optional-dependencies]
|
67
68
|
pulser = [
|
68
|
-
"pulser-core==1.
|
69
|
-
"pulser-simulation==1.
|
70
|
-
"pasqal-cloud==0.
|
69
|
+
"pulser-core==1.4.0",
|
70
|
+
"pulser-simulation==1.4.0",
|
71
|
+
"pasqal-cloud==0.20.2",
|
71
72
|
]
|
72
73
|
visualization = [
|
73
74
|
"graphviz",
|
@@ -76,7 +77,7 @@ visualization = [
|
|
76
77
|
# "scour",
|
77
78
|
]
|
78
79
|
horqrux = [
|
79
|
-
"horqrux==0.
|
80
|
+
"horqrux==0.8.0",
|
80
81
|
"jax",
|
81
82
|
"flax",
|
82
83
|
"optax",
|
@@ -54,11 +54,18 @@ class BackendConfiguration:
|
|
54
54
|
conf_msg = ""
|
55
55
|
for _field in fields(self):
|
56
56
|
if not _field.name.startswith("_"):
|
57
|
-
conf_msg += (
|
58
|
-
f"Name: {_field.name} - Type: {_field.type} - Default value: {_field.default}\n"
|
59
|
-
)
|
57
|
+
conf_msg += f"Name: {_field.name} - Type: {_field.type} - Current value: {getattr(self, _field.name)} - Default value: {_field.default}\n"
|
60
58
|
return conf_msg
|
61
59
|
|
60
|
+
def change_config(self, new_config: dict) -> None:
|
61
|
+
"""Change configuration with the input."""
|
62
|
+
|
63
|
+
for key, value in new_config.items():
|
64
|
+
if hasattr(self, key):
|
65
|
+
setattr(self, key, value)
|
66
|
+
else:
|
67
|
+
raise ValueError(f"Warning: '{key}' is not a valid configuration attribute.")
|
68
|
+
|
62
69
|
@classmethod
|
63
70
|
def from_dict(cls, values: dict) -> BackendConfiguration:
|
64
71
|
field_names = {field.name for field in fields(cls)}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from functools import lru_cache
|
4
|
+
from typing import Callable
|
5
|
+
|
6
|
+
import numpy as np
|
7
|
+
import torch
|
8
|
+
from scipy.optimize import minimize
|
9
|
+
from torch import Tensor
|
10
|
+
|
11
|
+
|
12
|
+
def variance(shifts: Tensor, spectral_gaps: Tensor) -> Tensor:
|
13
|
+
"""Calculate the exact variance of deirivative estimation using aGPSR.
|
14
|
+
|
15
|
+
Args:
|
16
|
+
shifts (Tensor): shifts to apply for each spectral gap
|
17
|
+
spectral_gaps (Tensor): tensor containing spectral gap values
|
18
|
+
|
19
|
+
Returns:
|
20
|
+
Tensor: variance tensor
|
21
|
+
"""
|
22
|
+
|
23
|
+
# calculate inverse of M (see: https://arxiv.org/pdf/2108.01218.pdf on p. 4 for definitions)
|
24
|
+
M = 4 * torch.sin(torch.outer(torch.as_tensor(shifts), spectral_gaps) / 2)
|
25
|
+
try:
|
26
|
+
# calculate the variance of derivative estimation by solving a linear equation system
|
27
|
+
a = torch.linalg.solve(M, spectral_gaps.reshape(-1, 1))
|
28
|
+
var = 2 * torch.matmul(a.T, a)
|
29
|
+
except RuntimeError: # matrix M is singulkar
|
30
|
+
# fallback method of variance calculation using inverse matrix
|
31
|
+
M_inv = torch.linalg.pinv(M)
|
32
|
+
a = torch.matmul(spectral_gaps.reshape(1, -1), M_inv)
|
33
|
+
var = 2 * torch.matmul(a, a.T)
|
34
|
+
|
35
|
+
return var
|
36
|
+
|
37
|
+
|
38
|
+
@lru_cache
|
39
|
+
def calculate_optimal_shifts(
|
40
|
+
n_eqs: int,
|
41
|
+
spectral_gaps: Tensor,
|
42
|
+
lb: float,
|
43
|
+
ub: float,
|
44
|
+
) -> Tensor:
|
45
|
+
"""Calculates optimal shift values for GPSR algorithm.
|
46
|
+
|
47
|
+
Args:
|
48
|
+
n_eqs (int): number of equations in linear equation system for derivative estimation
|
49
|
+
spectral_gaps (Tensor): tensor containing spectral gap values
|
50
|
+
lb (float): lower bound of optimal shift value search interval
|
51
|
+
ub (float): upper bound of optimal shift value search interval
|
52
|
+
|
53
|
+
Returns:
|
54
|
+
Tensor: optimal shift values
|
55
|
+
"""
|
56
|
+
if not (lb and ub):
|
57
|
+
raise ValueError("Both lower and upper bounds of optimization interval must be given.")
|
58
|
+
|
59
|
+
constraints = []
|
60
|
+
|
61
|
+
# specify solution bound constraints
|
62
|
+
for i in range(n_eqs):
|
63
|
+
|
64
|
+
def fn_lb(x, i=i): # type: ignore [no-untyped-def]
|
65
|
+
return x[i] - lb
|
66
|
+
|
67
|
+
def fn_ub(x, i=i): # type: ignore [no-untyped-def]
|
68
|
+
return ub - x[i]
|
69
|
+
|
70
|
+
constraints.append({"type": "ineq", "fun": fn_lb})
|
71
|
+
constraints.append({"type": "ineq", "fun": fn_ub})
|
72
|
+
|
73
|
+
# specify constraints for solutions to be unique
|
74
|
+
for i in range(n_eqs - 1, 0, -1):
|
75
|
+
for j in range(i):
|
76
|
+
|
77
|
+
def fn(x, i=i, j=j): # type: ignore [no-untyped-def]
|
78
|
+
return np.abs(x[i] - x[j]) - 0.02
|
79
|
+
|
80
|
+
constraints.append({"type": "ineq", "fun": fn})
|
81
|
+
|
82
|
+
init_guess = torch.linspace(lb, ub, n_eqs)
|
83
|
+
|
84
|
+
def minimize_variance(
|
85
|
+
var_fn: Callable[[Tensor, Tensor], Tensor],
|
86
|
+
) -> Tensor:
|
87
|
+
res = minimize(
|
88
|
+
fun=var_fn,
|
89
|
+
x0=init_guess,
|
90
|
+
args=(spectral_gaps,),
|
91
|
+
method="COBYLA",
|
92
|
+
constraints=constraints,
|
93
|
+
)
|
94
|
+
return torch.as_tensor(res.x)
|
95
|
+
|
96
|
+
return minimize_variance(variance)
|
@@ -50,7 +50,14 @@ def backend_factory(
|
|
50
50
|
# Wrap the quantum Backend in a DifferentiableBackend if a diff_mode is passed.
|
51
51
|
if diff_mode is not None:
|
52
52
|
diff_backend_cls = import_engine(backend_inst.engine)
|
53
|
-
|
53
|
+
psr_args = {
|
54
|
+
"n_eqs": configuration.n_eqs, # type: ignore [attr-defined]
|
55
|
+
"shift_prefac": configuration.shift_prefac, # type: ignore [attr-defined]
|
56
|
+
"gap_step": configuration.gap_step, # type: ignore [attr-defined]
|
57
|
+
"lb": configuration.lb, # type: ignore [attr-defined]
|
58
|
+
"ub": configuration.ub, # type: ignore [attr-defined]
|
59
|
+
}
|
60
|
+
backend_inst = diff_backend_cls(backend=backend_inst, diff_mode=DiffMode(diff_mode), **psr_args) # type: ignore[operator]
|
54
61
|
return backend_inst
|
55
62
|
except (BackendNotFoundError, EngineNotFoundError, ConfigNotFoundError) as e:
|
56
63
|
logger.error(e.msg)
|
@@ -7,7 +7,7 @@ from typing import Any
|
|
7
7
|
|
8
8
|
import jax
|
9
9
|
import jax.numpy as jnp
|
10
|
-
from horqrux.utils import zero_state
|
10
|
+
from horqrux.utils.operator_utils import zero_state
|
11
11
|
from jax.typing import ArrayLike
|
12
12
|
|
13
13
|
from qadence.backend import Backend as BackendInterface
|
@@ -27,7 +27,8 @@ from qadence.types import BackendName, Endianness, Engine, ParamDictType
|
|
27
27
|
from qadence.utils import int_to_basis
|
28
28
|
|
29
29
|
from .config import Configuration, default_passes
|
30
|
-
from .convert_ops import
|
30
|
+
from .convert_ops import convert_block, convert_observable
|
31
|
+
from horqrux.circuit import QuantumCircuit as HorqruxCircuit
|
31
32
|
|
32
33
|
logger = getLogger(__name__)
|
33
34
|
|
@@ -58,7 +59,7 @@ class Backend(BackendInterface):
|
|
58
59
|
circuit = transpile(*passes)(circuit)
|
59
60
|
ops = convert_block(circuit.block, n_qubits=circuit.n_qubits, config=self.config)
|
60
61
|
return ConvertedCircuit(
|
61
|
-
native=HorqruxCircuit(ops), abstract=circuit, original=original_circ
|
62
|
+
native=HorqruxCircuit(circuit.n_qubits, ops), abstract=circuit, original=original_circ
|
62
63
|
)
|
63
64
|
|
64
65
|
def observable(self, observable: AbstractBlock, n_qubits: int) -> ConvertedObservable:
|
@@ -97,7 +98,7 @@ class Backend(BackendInterface):
|
|
97
98
|
state = zero_state(n_qubits)
|
98
99
|
else:
|
99
100
|
state = horqify(state) if horqify_state else state
|
100
|
-
state = circuit.native
|
101
|
+
state = circuit.native(state, param_values)
|
101
102
|
if endianness != self.native_endianness:
|
102
103
|
state = jnp.reshape(state, (1, 2**n_qubits)) # batch_size is always 1
|
103
104
|
ls = list(range(2**n_qubits))
|
@@ -141,7 +142,7 @@ class Backend(BackendInterface):
|
|
141
142
|
out_state = self.run(
|
142
143
|
circuit, params, state, endianness, horqify_state=True, unhorqify_state=False
|
143
144
|
)
|
144
|
-
return jnp.array([o.native
|
145
|
+
return jnp.array([o.native(out_state, params) for o in observable])
|
145
146
|
|
146
147
|
if batch_size > 1: # We vmap for batch_size > 1
|
147
148
|
expvals = jax.vmap(_expectation, in_axes=({k: 0 for k in param_values.keys()},))(
|
@@ -32,4 +32,20 @@ def default_passes(config: Configuration) -> list[Callable]:
|
|
32
32
|
|
33
33
|
@dataclass
|
34
34
|
class Configuration(BackendConfiguration):
|
35
|
-
|
35
|
+
n_eqs: int | None = None
|
36
|
+
"""Number of equations to use in aGPSR calculations."""
|
37
|
+
|
38
|
+
shift_prefac: float = 0.5
|
39
|
+
"""Prefactor governing the magnitude of parameter shift values.
|
40
|
+
|
41
|
+
Select smaller value if spectral gaps are large.
|
42
|
+
"""
|
43
|
+
|
44
|
+
gap_step: float = 1.0
|
45
|
+
"""Step between generated pseudo-gaps when using aGPSR algorithm."""
|
46
|
+
|
47
|
+
lb: float | None = None
|
48
|
+
"""Lower bound of optimal shift value search interval."""
|
49
|
+
|
50
|
+
ub: float | None = None
|
51
|
+
"""Upper bound of optimal shift value search interval."""
|
@@ -8,11 +8,15 @@ from typing import Any, Callable, Dict
|
|
8
8
|
|
9
9
|
import jax.numpy as jnp
|
10
10
|
from horqrux.analog import _HamiltonianEvolution as NativeHorqHEvo
|
11
|
-
from horqrux.apply import
|
12
|
-
from horqrux.parametric import RX, RY, RZ
|
13
|
-
from horqrux.primitive import NOT, SWAP, H, I, X, Y, Z
|
14
|
-
from horqrux.primitive import Primitive as Gate
|
15
|
-
from horqrux.
|
11
|
+
from horqrux.apply import apply_gates
|
12
|
+
from horqrux.primitives.parametric import RX, RY, RZ
|
13
|
+
from horqrux.primitives.primitive import NOT, SWAP, H, I, X, Y, Z
|
14
|
+
from horqrux.primitives.primitive import Primitive as Gate
|
15
|
+
from horqrux.composite.sequence import OpSequence as HorqruxSequence
|
16
|
+
from horqrux.composite.compose import Scale as HorqScaleGate
|
17
|
+
from horqrux.composite.compose import Add as HorqAddGate
|
18
|
+
from horqrux.composite.compose import Observable as HorqruxObservable
|
19
|
+
from horqrux.utils.operator_utils import ControlQubits, TargetQubits
|
16
20
|
from jax import Array
|
17
21
|
from jax.scipy.linalg import expm
|
18
22
|
from jax.tree_util import register_pytree_node_class
|
@@ -36,6 +40,7 @@ from qadence.operations import (
|
|
36
40
|
MCRY,
|
37
41
|
MCRZ,
|
38
42
|
MCZ,
|
43
|
+
CZ,
|
39
44
|
)
|
40
45
|
from qadence.operations import SWAP as QDSWAP
|
41
46
|
from qadence.types import OpName, ParamDictType
|
@@ -53,6 +58,7 @@ ops_map: Dict[str, Callable] = {
|
|
53
58
|
OpName.CRX: RX,
|
54
59
|
OpName.CRY: RY,
|
55
60
|
OpName.CRZ: RZ,
|
61
|
+
OpName.CZ: Z,
|
56
62
|
OpName.CNOT: NOT,
|
57
63
|
OpName.I: I,
|
58
64
|
OpName.SWAP: SWAP,
|
@@ -61,37 +67,6 @@ ops_map: Dict[str, Callable] = {
|
|
61
67
|
supported_gates = list(set(list(ops_map.keys())))
|
62
68
|
|
63
69
|
|
64
|
-
@register_pytree_node_class
|
65
|
-
@dataclass
|
66
|
-
class HorqruxCircuit:
|
67
|
-
operators: list[Gate] = field(default_factory=list)
|
68
|
-
|
69
|
-
def tree_flatten(self) -> tuple[tuple[list[Any]], tuple[()]]:
|
70
|
-
children = (self.operators,)
|
71
|
-
aux_data = ()
|
72
|
-
return (children, aux_data)
|
73
|
-
|
74
|
-
@classmethod
|
75
|
-
def tree_unflatten(cls, aux_data: Any, children: Any) -> Any:
|
76
|
-
return cls(*children, *aux_data)
|
77
|
-
|
78
|
-
def _forward(self, state: Array, values: ParamDictType) -> Array:
|
79
|
-
return reduce(lambda state, gate: gate.forward(state, values), self.operators, state)
|
80
|
-
|
81
|
-
def forward(self, state: Array, values: ParamDictType) -> Array:
|
82
|
-
return self._forward(state, values)
|
83
|
-
|
84
|
-
|
85
|
-
@register_pytree_node_class
|
86
|
-
@dataclass
|
87
|
-
class HorqruxObservable(HorqruxCircuit):
|
88
|
-
def __init__(self, operators: list[Gate]):
|
89
|
-
super().__init__(operators=operators)
|
90
|
-
|
91
|
-
def forward(self, state: Array, values: ParamDictType) -> Array:
|
92
|
-
return jnp.real(inner(state, self._forward(state, values)))
|
93
|
-
|
94
|
-
|
95
70
|
def convert_observable(
|
96
71
|
block: AbstractBlock, n_qubits: int, config: Configuration
|
97
72
|
) -> HorqruxObservable:
|
@@ -109,7 +84,7 @@ def convert_block(
|
|
109
84
|
ops = []
|
110
85
|
if isinstance(block, CompositeBlock):
|
111
86
|
ops = list(flatten(*(convert_block(b, n_qubits, config) for b in block.blocks)))
|
112
|
-
ops = [HorqAddGate(ops)] if isinstance(block, AddBlock) else [
|
87
|
+
ops = [HorqAddGate(ops)] if isinstance(block, AddBlock) else [HorqruxSequence(ops)]
|
113
88
|
elif isinstance(block, ScaleBlock):
|
114
89
|
op = convert_block(block.block, n_qubits, config=config)[0]
|
115
90
|
param_name = config.get_param_name(block)[0]
|
@@ -118,7 +93,7 @@ def convert_block(
|
|
118
93
|
native_op_fn = ops_map[block.name]
|
119
94
|
target, control = (
|
120
95
|
(block.qubit_support[1], block.qubit_support[0])
|
121
|
-
if isinstance(block, (CNOT, CRX, CRY, CRZ, QDSWAP))
|
96
|
+
if isinstance(block, (CZ, CNOT, CRX, CRY, CRZ, QDSWAP))
|
122
97
|
else (block.qubit_support[0], (None,))
|
123
98
|
)
|
124
99
|
native_gate: Gate
|
@@ -133,7 +108,7 @@ def convert_block(
|
|
133
108
|
native_gate = native_op_fn(block.qubit_support[::-1])
|
134
109
|
else:
|
135
110
|
native_gate = native_op_fn(target=target, control=control)
|
136
|
-
ops = [
|
111
|
+
ops = [native_gate]
|
137
112
|
|
138
113
|
elif isinstance(block, (MCRX, MCRY, MCRZ, MCZ)):
|
139
114
|
block_name = block.name[2:] if block.name.startswith("M") else block.name
|
@@ -146,7 +121,7 @@ def convert_block(
|
|
146
121
|
native_gate = native_op_fn(param=param, target=target, control=control)
|
147
122
|
else:
|
148
123
|
native_gate = native_op_fn(target, control)
|
149
|
-
ops = [
|
124
|
+
ops = [native_gate]
|
150
125
|
elif isinstance(block, TimeEvolutionBlock):
|
151
126
|
ops = [HorqHamiltonianEvolution(block, config)]
|
152
127
|
else:
|
@@ -155,58 +130,6 @@ def convert_block(
|
|
155
130
|
return ops
|
156
131
|
|
157
132
|
|
158
|
-
@register_pytree_node_class
|
159
|
-
class HorqAddGate(HorqruxCircuit):
|
160
|
-
def __init__(self, operations: list[Gate]):
|
161
|
-
self.operators = operations
|
162
|
-
self.name = "Add"
|
163
|
-
|
164
|
-
def forward(self, state: Array, values: ParamDictType = {}) -> Array:
|
165
|
-
return reduce(add, (gate.forward(state, values) for gate in self.operators))
|
166
|
-
|
167
|
-
def __repr__(self) -> str:
|
168
|
-
return self.name + f"({self.operators})"
|
169
|
-
|
170
|
-
|
171
|
-
@register_pytree_node_class
|
172
|
-
@dataclass
|
173
|
-
class HorqOperation:
|
174
|
-
def __init__(self, native_gate: Gate):
|
175
|
-
self.native_gate = native_gate
|
176
|
-
|
177
|
-
def forward(self, state: Array, values: ParamDictType) -> Array:
|
178
|
-
return apply_gate(state, self.native_gate, values)
|
179
|
-
|
180
|
-
def tree_flatten(self) -> tuple[tuple[Gate], tuple[()]]:
|
181
|
-
children = (self.native_gate,)
|
182
|
-
aux_data = ()
|
183
|
-
return (children, aux_data)
|
184
|
-
|
185
|
-
@classmethod
|
186
|
-
def tree_unflatten(cls, aux_data: Any, children: Any) -> Any:
|
187
|
-
return cls(*children, *aux_data)
|
188
|
-
|
189
|
-
|
190
|
-
@register_pytree_node_class
|
191
|
-
@dataclass
|
192
|
-
class HorqScaleGate:
|
193
|
-
def __init__(self, gate: HorqOperation, parameter_name: str):
|
194
|
-
self.gate = gate
|
195
|
-
self.parameter: str = parameter_name
|
196
|
-
|
197
|
-
def forward(self, state: Array, values: ParamDictType) -> Array:
|
198
|
-
return jnp.array(values[self.parameter]) * self.gate.forward(state, values)
|
199
|
-
|
200
|
-
def tree_flatten(self) -> tuple[tuple[HorqOperation], tuple[str]]:
|
201
|
-
children = (self.gate,)
|
202
|
-
aux_data = (self.parameter,)
|
203
|
-
return (children, aux_data)
|
204
|
-
|
205
|
-
@classmethod
|
206
|
-
def tree_unflatten(cls, aux_data: Any, children: Any) -> Any:
|
207
|
-
return cls(*children, *aux_data)
|
208
|
-
|
209
|
-
|
210
133
|
@register_pytree_node_class
|
211
134
|
@dataclass
|
212
135
|
class HorqHamiltonianEvolution(NativeHorqHEvo):
|
@@ -216,7 +139,7 @@ class HorqHamiltonianEvolution(NativeHorqHEvo):
|
|
216
139
|
config: Configuration,
|
217
140
|
):
|
218
141
|
super().__init__("I", block.qubit_support, (None,))
|
219
|
-
self.
|
142
|
+
self._qubit_support = block.qubit_support
|
220
143
|
self.param_names = config.get_param_name(block)
|
221
144
|
self.block = block
|
222
145
|
self.hmat: Array
|
@@ -224,7 +147,7 @@ class HorqHamiltonianEvolution(NativeHorqHEvo):
|
|
224
147
|
if isinstance(block.generator, AbstractBlock) and not block.generator.is_parametric:
|
225
148
|
hmat = block_to_jax(
|
226
149
|
block.generator,
|
227
|
-
qubit_support=self.
|
150
|
+
qubit_support=self._qubit_support,
|
228
151
|
use_full_support=False,
|
229
152
|
)
|
230
153
|
self.hmat = hmat
|
@@ -236,7 +159,7 @@ class HorqHamiltonianEvolution(NativeHorqHEvo):
|
|
236
159
|
hmat = block_to_jax(
|
237
160
|
block.generator, # type: ignore[arg-type]
|
238
161
|
values=values,
|
239
|
-
qubit_support=self.
|
162
|
+
qubit_support=self._qubit_support,
|
240
163
|
use_full_support=False,
|
241
164
|
)
|
242
165
|
return hmat
|
@@ -249,12 +172,12 @@ class HorqHamiltonianEvolution(NativeHorqHEvo):
|
|
249
172
|
"""The evolved operator given current parameter values for generator and time evolution."""
|
250
173
|
return expm(self._hamiltonian(self, values) * (-1j * self._time_evolution(values)))
|
251
174
|
|
252
|
-
def
|
175
|
+
def __call__(
|
253
176
|
self,
|
254
177
|
state: Array,
|
255
178
|
values: dict[str, Array],
|
256
179
|
) -> Array:
|
257
|
-
return
|
180
|
+
return apply_gates(state, self, values)
|
258
181
|
|
259
182
|
def tree_flatten(self) -> tuple[tuple[NativeHorqHEvo], tuple]:
|
260
183
|
children = (self,)
|