qadence 1.6.0__tar.gz → 1.6.3__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.6.0 → qadence-1.6.3}/PKG-INFO +19 -10
- {qadence-1.6.0 → qadence-1.6.3}/README.md +11 -0
- {qadence-1.6.0 → qadence-1.6.3}/pyproject.toml +6 -11
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/gpsr.py +15 -3
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/horqrux/backend.py +19 -31
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pulser/backend.py +14 -3
- qadence-1.6.3/qadence/backends/pulser/convert_ops.py +55 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pyqtorch/backend.py +28 -43
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pyqtorch/convert_ops.py +39 -200
- {qadence-1.6.0 → qadence-1.6.3}/qadence/blocks/block_to_tensor.py +3 -2
- {qadence-1.6.0 → qadence-1.6.3}/qadence/blocks/matrix.py +1 -1
- {qadence-1.6.0 → qadence-1.6.3}/qadence/blocks/primitive.py +2 -1
- {qadence-1.6.0 → qadence-1.6.3}/qadence/engines/torch/differentiable_expectation.py +1 -1
- {qadence-1.6.0 → qadence-1.6.3}/qadence/measurements/shadow.py +3 -16
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/config.py +11 -1
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/printing.py +1 -3
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/saveload.py +12 -7
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/train_grad.py +36 -3
- {qadence-1.6.0 → qadence-1.6.3}/qadence/operations/ham_evo.py +3 -5
- {qadence-1.6.0 → qadence-1.6.3}/qadence/overlap.py +7 -12
- {qadence-1.6.0 → qadence-1.6.3}/qadence/parameters.py +1 -1
- {qadence-1.6.0 → qadence-1.6.3}/qadence/states.py +19 -5
- {qadence-1.6.0 → qadence-1.6.3}/qadence/utils.py +40 -1
- qadence-1.6.0/qadence/backends/adjoint.py +0 -163
- qadence-1.6.0/qadence/backends/pulser/convert_ops.py +0 -42
- {qadence-1.6.0 → qadence-1.6.3}/.coveragerc +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/.github/dependabot.yml +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/.github/workflows/build_docs.yml +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/.github/workflows/dependabot.yml +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/.github/workflows/lint.yml +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/.github/workflows/test_all.yml +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/.github/workflows/test_examples.yml +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/.github/workflows/test_fast.yml +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/.gitignore +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/.pre-commit-config.yaml +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/LICENSE +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/MANIFEST.in +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/mkdocs.yml +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/analog/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/analog/addressing.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/analog/constants.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/analog/device.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/analog/hamiltonian_terms.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/analog/parse_analog.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backend.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/api.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/braket/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/braket/backend.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/braket/config.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/braket/convert_ops.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/horqrux/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/horqrux/config.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/horqrux/convert_ops.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/jax_utils.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pulser/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pulser/channels.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pulser/cloud.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pulser/config.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pulser/devices.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pulser/pulses.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pulser/waveforms.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pyqtorch/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/pyqtorch/config.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/backends/utils.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/blocks/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/blocks/abstract.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/blocks/analog.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/blocks/composite.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/blocks/embedding.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/blocks/manipulate.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/blocks/utils.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/circuit.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/ansatze.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/daqc/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/daqc/daqc.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/daqc/gen_parser.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/daqc/utils.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/feature_maps.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/hamiltonians.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/iia.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/qft.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/rydberg_feature_maps.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/rydberg_hea.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/constructors/utils.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/decompose.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/divergences.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/draw/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/draw/assets/dark/measurement.png +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/draw/assets/dark/measurement.svg +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/draw/assets/light/measurement.png +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/draw/assets/light/measurement.svg +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/draw/themes.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/draw/utils.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/draw/vizbackend.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/engines/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/engines/differentiable_backend.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/engines/jax/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/engines/jax/differentiable_backend.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/engines/jax/differentiable_expectation.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/engines/torch/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/engines/torch/differentiable_backend.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/exceptions/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/exceptions/exceptions.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/execution.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/extensions.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/finitediff.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/libs.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/log_config.yaml +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/logger.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/measurements/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/measurements/protocols.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/measurements/samples.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/measurements/tomography.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/measurements/utils.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/mitigations/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/mitigations/analog_zne.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/mitigations/protocols.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/mitigations/readout.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/data.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/models.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/optimize_step.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/parameters.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/tensors.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/train_no_grad.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/ml_tools/utils.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/models/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/models/qnn.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/models/quantum_model.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/noise/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/noise/protocols.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/noise/readout.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/operations/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/operations/analog.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/operations/control_ops.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/operations/parametric.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/operations/primitive.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/protocols.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/py.typed +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/qubit_support.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/register.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/serial_expr_grammar.peg +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/serialization.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/transpile/__init__.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/transpile/apply_fn.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/transpile/block.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/transpile/circuit.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/transpile/digitalize.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/transpile/flatten.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/transpile/invert.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/transpile/transpile.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/qadence/types.py +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/renovate.json +0 -0
- {qadence-1.6.0 → qadence-1.6.3}/setup.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: qadence
|
3
|
-
Version: 1.6.
|
3
|
+
Version: 1.6.3
|
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>
|
6
6
|
License: Apache 2.0
|
@@ -22,7 +22,7 @@ Requires-Dist: matplotlib
|
|
22
22
|
Requires-Dist: nevergrad
|
23
23
|
Requires-Dist: numpy
|
24
24
|
Requires-Dist: openfermion
|
25
|
-
Requires-Dist: pyqtorch==1.1
|
25
|
+
Requires-Dist: pyqtorch==1.2.1
|
26
26
|
Requires-Dist: pyyaml
|
27
27
|
Requires-Dist: rich
|
28
28
|
Requires-Dist: scipy
|
@@ -30,13 +30,11 @@ Requires-Dist: sympytorch>=0.1.2
|
|
30
30
|
Requires-Dist: tensorboard>=2.12.0
|
31
31
|
Requires-Dist: torch
|
32
32
|
Provides-Extra: all
|
33
|
-
Requires-Dist:
|
34
|
-
Requires-Dist: graphviz; extra == 'all'
|
33
|
+
Requires-Dist: braket; extra == 'all'
|
35
34
|
Requires-Dist: libs; extra == 'all'
|
36
|
-
Requires-Dist: pasqal-cloud==0.8.1; extra == 'all'
|
37
35
|
Requires-Dist: protocols; extra == 'all'
|
38
|
-
Requires-Dist: pulser
|
39
|
-
Requires-Dist:
|
36
|
+
Requires-Dist: pulser; extra == 'all'
|
37
|
+
Requires-Dist: visualization; extra == 'all'
|
40
38
|
Provides-Extra: braket
|
41
39
|
Requires-Dist: amazon-braket-sdk<1.71.2; extra == 'braket'
|
42
40
|
Provides-Extra: dlprof
|
@@ -55,9 +53,9 @@ Requires-Dist: qadence-libs; extra == 'libs'
|
|
55
53
|
Provides-Extra: protocols
|
56
54
|
Requires-Dist: qadence-protocols; extra == 'protocols'
|
57
55
|
Provides-Extra: pulser
|
58
|
-
Requires-Dist: pasqal-cloud==0.
|
59
|
-
Requires-Dist: pulser-core==0.18.
|
60
|
-
Requires-Dist: pulser-simulation==0.18.
|
56
|
+
Requires-Dist: pasqal-cloud==0.10.1; extra == 'pulser'
|
57
|
+
Requires-Dist: pulser-core==0.18.1; extra == 'pulser'
|
58
|
+
Requires-Dist: pulser-simulation==0.18.1; extra == 'pulser'
|
61
59
|
Provides-Extra: visualization
|
62
60
|
Requires-Dist: graphviz; extra == 'visualization'
|
63
61
|
Description-Content-Type: text/markdown
|
@@ -151,6 +149,15 @@ brew install graphviz
|
|
151
149
|
conda install python-graphviz
|
152
150
|
```
|
153
151
|
|
152
|
+
On Windows Linux Subsystem (WSL2) it has been reported that in some cases "wslutilities" must be installed.
|
153
|
+
Please follow instructions [here](https://wslutiliti.es/wslu/install.html) for your flavour.
|
154
|
+
For example on Ubuntu 22.04 LTS and later you must run:
|
155
|
+
```
|
156
|
+
sudo add-apt-repository ppa:wslutilities/wslu
|
157
|
+
sudo apt update
|
158
|
+
sudo apt install wslu
|
159
|
+
```
|
160
|
+
|
154
161
|
## Contributing
|
155
162
|
|
156
163
|
Before making a contribution, please review our [code of conduct](docs/getting_started/CODE_OF_CONDUCT.md).
|
@@ -181,6 +188,8 @@ install it from source using `pip`:
|
|
181
188
|
python -m pip install -e .
|
182
189
|
```
|
183
190
|
|
191
|
+
Users also report problems running Hatch on Windows, we suggest using WSL2.
|
192
|
+
|
184
193
|
## Citation
|
185
194
|
|
186
195
|
If you use Qadence for a publication, we kindly ask you to cite our work using the following BibTex entry:
|
@@ -87,6 +87,15 @@ brew install graphviz
|
|
87
87
|
conda install python-graphviz
|
88
88
|
```
|
89
89
|
|
90
|
+
On Windows Linux Subsystem (WSL2) it has been reported that in some cases "wslutilities" must be installed.
|
91
|
+
Please follow instructions [here](https://wslutiliti.es/wslu/install.html) for your flavour.
|
92
|
+
For example on Ubuntu 22.04 LTS and later you must run:
|
93
|
+
```
|
94
|
+
sudo add-apt-repository ppa:wslutilities/wslu
|
95
|
+
sudo apt update
|
96
|
+
sudo apt install wslu
|
97
|
+
```
|
98
|
+
|
90
99
|
## Contributing
|
91
100
|
|
92
101
|
Before making a contribution, please review our [code of conduct](docs/getting_started/CODE_OF_CONDUCT.md).
|
@@ -117,6 +126,8 @@ install it from source using `pip`:
|
|
117
126
|
python -m pip install -e .
|
118
127
|
```
|
119
128
|
|
129
|
+
Users also report problems running Hatch on Windows, we suggest using WSL2.
|
130
|
+
|
120
131
|
## Citation
|
121
132
|
|
122
133
|
If you use Qadence for a publication, we kindly ask you to cite our work using the following BibTex entry:
|
@@ -21,7 +21,7 @@ authors = [
|
|
21
21
|
]
|
22
22
|
requires-python = ">=3.9"
|
23
23
|
license = {text = "Apache 2.0"}
|
24
|
-
version = "1.6.
|
24
|
+
version = "1.6.3"
|
25
25
|
classifiers=[
|
26
26
|
"License :: OSI Approved :: Apache Software License",
|
27
27
|
"Programming Language :: Python",
|
@@ -44,7 +44,7 @@ dependencies = [
|
|
44
44
|
"jsonschema",
|
45
45
|
"nevergrad",
|
46
46
|
"scipy",
|
47
|
-
"pyqtorch==1.1
|
47
|
+
"pyqtorch==1.2.1",
|
48
48
|
"pyyaml",
|
49
49
|
"matplotlib",
|
50
50
|
"Arpeggio==2.0.2",
|
@@ -55,7 +55,7 @@ allow-direct-references = true
|
|
55
55
|
allow-ambiguous-features = true
|
56
56
|
|
57
57
|
[project.optional-dependencies]
|
58
|
-
pulser = ["pulser-core==0.18.
|
58
|
+
pulser = ["pulser-core==0.18.1", "pulser-simulation==0.18.1","pasqal-cloud==0.10.1"]
|
59
59
|
braket = ["amazon-braket-sdk<1.71.2"]
|
60
60
|
visualization = [
|
61
61
|
"graphviz",
|
@@ -75,16 +75,11 @@ protocols = ["qadence-protocols"]
|
|
75
75
|
libs = ["qadence-libs"]
|
76
76
|
dlprof = ["nvidia-pyindex", "nvidia-dlprof[pytorch]"]
|
77
77
|
all = [
|
78
|
-
"pulser
|
79
|
-
"
|
80
|
-
"
|
81
|
-
"amazon-braket-sdk<1.71.2",
|
82
|
-
"graphviz",
|
78
|
+
"pulser",
|
79
|
+
"braket",
|
80
|
+
"visualization",
|
83
81
|
"protocols",
|
84
82
|
"libs",
|
85
|
-
# FIXME: will be needed once we support latex labels
|
86
|
-
# "latex2svg @ git+https://github.com/Moonbase59/latex2svg.git#egg=latex2svg",
|
87
|
-
# "scour",
|
88
83
|
]
|
89
84
|
|
90
85
|
[tool.hatch.envs.default]
|
@@ -48,7 +48,13 @@ def single_gap_psr(
|
|
48
48
|
Returns:
|
49
49
|
Tensor: tensor containing derivative values
|
50
50
|
"""
|
51
|
-
|
51
|
+
device = torch.device("cpu")
|
52
|
+
try:
|
53
|
+
device = [v.device for v in param_dict.values()][0]
|
54
|
+
except Exception:
|
55
|
+
pass
|
56
|
+
spectral_gap = spectral_gap.to(device=device)
|
57
|
+
shift = shift.to(device=device)
|
52
58
|
# + pi/2 shift
|
53
59
|
shifted_params = param_dict.copy()
|
54
60
|
shifted_params[param_name] = shifted_params[param_name] + shift
|
@@ -89,11 +95,17 @@ def multi_gap_psr(
|
|
89
95
|
|
90
96
|
# get shift values
|
91
97
|
shifts = shift_prefac * torch.linspace(PI / 2 - PI / 5, PI / 2 + PI / 5, n_eqs)
|
92
|
-
|
98
|
+
device = torch.device("cpu")
|
99
|
+
try:
|
100
|
+
device = [v.device for v in param_dict.values()][0]
|
101
|
+
except Exception:
|
102
|
+
pass
|
103
|
+
spectral_gaps = spectral_gaps.to(device=device)
|
104
|
+
shifts = shifts.to(device=device)
|
93
105
|
# calculate F vector and M matrix
|
94
106
|
# (see: https://arxiv.org/pdf/2108.01218.pdf on p. 4 for definitions)
|
95
107
|
F = []
|
96
|
-
M = torch.empty((n_eqs, n_eqs))
|
108
|
+
M = torch.empty((n_eqs, n_eqs)).to(device=device)
|
97
109
|
n_obs = 1
|
98
110
|
for i in range(n_eqs):
|
99
111
|
# + shift
|
@@ -195,28 +195,6 @@ class Backend(BackendInterface):
|
|
195
195
|
if n_shots < 1:
|
196
196
|
raise ValueError("You can only call sample with n_shots>0.")
|
197
197
|
|
198
|
-
def _sample(
|
199
|
-
_probs: ArrayLike, n_shots: int, endianness: Endianness, n_qubits: int
|
200
|
-
) -> Counter:
|
201
|
-
_logits = jax.vmap(lambda _p: jnp.log(_p / (1 - _p)))(_probs)
|
202
|
-
|
203
|
-
def _smple(accumulator: ArrayLike, i: int) -> tuple[ArrayLike, None]:
|
204
|
-
accumulator = accumulator.at[i].set(
|
205
|
-
jax.random.categorical(jax.random.PRNGKey(i), _logits)
|
206
|
-
)
|
207
|
-
return accumulator, None
|
208
|
-
|
209
|
-
samples = jax.lax.scan(
|
210
|
-
_smple, jnp.empty_like(jnp.arange(n_shots)), jnp.arange(n_shots)
|
211
|
-
)[0]
|
212
|
-
return Counter(
|
213
|
-
{
|
214
|
-
int_to_basis(k=k, n_qubits=n_qubits, endianness=endianness): count.item()
|
215
|
-
for k, count in enumerate(jnp.bincount(samples))
|
216
|
-
if count > 0
|
217
|
-
}
|
218
|
-
)
|
219
|
-
|
220
198
|
wf = self.run(
|
221
199
|
circuit=circuit,
|
222
200
|
param_values=param_values,
|
@@ -225,16 +203,26 @@ class Backend(BackendInterface):
|
|
225
203
|
unhorqify_state=False,
|
226
204
|
)
|
227
205
|
probs = jnp.abs(jnp.float_power(wf, 2.0)).ravel()
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
)
|
235
|
-
|
206
|
+
key = jax.random.PRNGKey(0)
|
207
|
+
# JAX handles pseudo random number generation by tracking an explicit state via a random key
|
208
|
+
# For more details, see https://jax.readthedocs.io/en/latest/random-numbers.html
|
209
|
+
samples = jax.vmap(
|
210
|
+
lambda subkey: jax.random.choice(
|
211
|
+
key=subkey, a=jnp.arange(0, 2**circuit.abstract.n_qubits), p=probs
|
212
|
+
)
|
213
|
+
)(jax.random.split(key, n_shots))
|
236
214
|
|
237
|
-
return
|
215
|
+
return [
|
216
|
+
Counter(
|
217
|
+
{
|
218
|
+
int_to_basis(
|
219
|
+
k=k, n_qubits=circuit.abstract.n_qubits, endianness=endianness
|
220
|
+
): count.item()
|
221
|
+
for k, count in enumerate(jnp.bincount(samples))
|
222
|
+
if count > 0
|
223
|
+
}
|
224
|
+
)
|
225
|
+
]
|
238
226
|
|
239
227
|
def assign_parameters(self, circuit: ConvertedCircuit, param_values: ParamDictType) -> Any:
|
240
228
|
raise NotImplementedError
|
@@ -264,7 +264,10 @@ class Backend(BackendInterface):
|
|
264
264
|
if isinstance(noise_probs, Iterable):
|
265
265
|
noisy_batched_dms = []
|
266
266
|
for noise_prob in noise_probs:
|
267
|
-
|
267
|
+
noisy_sim = run_noisy_sim(noise_prob)
|
268
|
+
if not param_values:
|
269
|
+
noisy_sim = noisy_sim[0]
|
270
|
+
noisy_batched_dms.append(noisy_sim)
|
268
271
|
noisy_batched_dms = torch.stack(noisy_batched_dms)
|
269
272
|
else:
|
270
273
|
noisy_batched_dms = run_noisy_sim(noise_probs)
|
@@ -350,10 +353,18 @@ class Backend(BackendInterface):
|
|
350
353
|
# TODO: There should be a better check for batched density matrices.
|
351
354
|
if dms.size()[0] > 1:
|
352
355
|
res_list = [
|
353
|
-
[
|
356
|
+
[
|
357
|
+
obs.native(
|
358
|
+
dm.squeeze(), param_values, qubit_support=support, noise=noise
|
359
|
+
)
|
360
|
+
for dm in dms
|
361
|
+
]
|
354
362
|
for obs in observable
|
355
363
|
]
|
356
|
-
res = torch.stack(
|
364
|
+
res = torch.stack(
|
365
|
+
[torch.transpose(torch.stack(res), 0, -1) for res in res_list]
|
366
|
+
)
|
367
|
+
|
357
368
|
else:
|
358
369
|
res_list = [
|
359
370
|
obs.native(dms, param_values, qubit_support=support) for obs in observable
|
@@ -0,0 +1,55 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import Sequence
|
4
|
+
|
5
|
+
import torch
|
6
|
+
from torch.nn import Module
|
7
|
+
|
8
|
+
from qadence import Noise
|
9
|
+
from qadence.blocks import (
|
10
|
+
AbstractBlock,
|
11
|
+
)
|
12
|
+
from qadence.blocks.block_to_tensor import (
|
13
|
+
block_to_tensor,
|
14
|
+
)
|
15
|
+
from qadence.utils import Endianness
|
16
|
+
|
17
|
+
from .config import Configuration
|
18
|
+
|
19
|
+
|
20
|
+
def convert_observable(
|
21
|
+
block: AbstractBlock, n_qubits: int | None, config: Configuration = None
|
22
|
+
) -> Sequence[Module]:
|
23
|
+
return [PulserObservable(block, n_qubits)]
|
24
|
+
|
25
|
+
|
26
|
+
class PulserObservable(Module):
|
27
|
+
def __init__(self, block: AbstractBlock, n_qubits: int | None):
|
28
|
+
super().__init__()
|
29
|
+
self.block = block
|
30
|
+
self.n_qubits = n_qubits if n_qubits else max(block.qubit_support) + 1
|
31
|
+
|
32
|
+
if not self.block.is_parametric:
|
33
|
+
block_mat = block_to_tensor(
|
34
|
+
self.block, {}, qubit_support=tuple(i for i in range(self.n_qubits))
|
35
|
+
).squeeze(0)
|
36
|
+
self.register_buffer("block_mat", block_mat)
|
37
|
+
|
38
|
+
def forward(
|
39
|
+
self,
|
40
|
+
state: torch.Tensor,
|
41
|
+
values: dict[str, torch.Tensor] = dict(),
|
42
|
+
qubit_support: tuple | None = None,
|
43
|
+
noise: Noise | None = None,
|
44
|
+
endianness: Endianness = Endianness.BIG,
|
45
|
+
) -> torch.Tensor:
|
46
|
+
if not self.block.is_parametric:
|
47
|
+
block_mat = self.block_mat
|
48
|
+
else:
|
49
|
+
block_mat = block_to_tensor(
|
50
|
+
self.block, values, qubit_support=qubit_support, endianness=endianness # type: ignore [arg-type] # noqa
|
51
|
+
).squeeze(0)
|
52
|
+
if noise is None: # Compute expectations for state vector.
|
53
|
+
return torch.sum(torch.matmul(state, block_mat) * state.conj(), dim=1)
|
54
|
+
else: # Compute expectations for density matrices.
|
55
|
+
return torch.trace(torch.matmul(block_mat, state))
|
@@ -31,10 +31,10 @@ from qadence.transpile import (
|
|
31
31
|
transpile,
|
32
32
|
)
|
33
33
|
from qadence.types import BackendName, Endianness, Engine
|
34
|
-
from qadence.utils import infer_batchsize
|
34
|
+
from qadence.utils import infer_batchsize
|
35
35
|
|
36
36
|
from .config import Configuration, default_passes
|
37
|
-
from .convert_ops import convert_block
|
37
|
+
from .convert_ops import convert_block
|
38
38
|
|
39
39
|
logger = getLogger(__name__)
|
40
40
|
|
@@ -77,8 +77,13 @@ class Backend(BackendInterface):
|
|
77
77
|
scale_primitive_blocks_only,
|
78
78
|
]
|
79
79
|
block = transpile(*transpilations)(observable) # type: ignore[call-overload]
|
80
|
-
|
81
|
-
|
80
|
+
operations = convert_block(block, n_qubits, self.config)
|
81
|
+
obs_cls = (
|
82
|
+
pyq.DiagonalObservable
|
83
|
+
if block._is_diag_pauli and not block.is_parametric
|
84
|
+
else pyq.Observable
|
85
|
+
)
|
86
|
+
native = obs_cls(n_qubits=n_qubits, operations=operations)
|
82
87
|
return ConvertedObservable(native=native, abstract=block, original=observable)
|
83
88
|
|
84
89
|
def run(
|
@@ -99,7 +104,7 @@ class Backend(BackendInterface):
|
|
99
104
|
validate_state(state, n_qubits)
|
100
105
|
# pyqtorch expects input shape [2] * n_qubits + [batch_size]
|
101
106
|
state = pyqify(state, n_qubits) if pyqify_state else state
|
102
|
-
state = circuit.native.run(state, param_values)
|
107
|
+
state = circuit.native.run(state=state, values=param_values)
|
103
108
|
state = unpyqify(state) if unpyqify_state else state
|
104
109
|
state = invert_endianness(state) if endianness != self.native_endianness else state
|
105
110
|
return state
|
@@ -208,46 +213,26 @@ class Backend(BackendInterface):
|
|
208
213
|
noise: Noise | None = None,
|
209
214
|
mitigation: Mitigations | None = None,
|
210
215
|
endianness: Endianness = Endianness.BIG,
|
216
|
+
pyqify_state: bool = True,
|
211
217
|
) -> list[Counter]:
|
212
|
-
if
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
)
|
227
|
-
|
228
|
-
with torch.no_grad():
|
229
|
-
wf = self.run(circuit=circuit, param_values=param_values, state=state)
|
230
|
-
probs = torch.abs(torch.pow(wf, 2))
|
231
|
-
samples = list(
|
232
|
-
map(
|
233
|
-
lambda _probs: _sample(
|
234
|
-
_probs=_probs,
|
235
|
-
n_shots=n_shots,
|
236
|
-
endianness=endianness,
|
237
|
-
n_qubits=circuit.abstract.n_qubits,
|
238
|
-
),
|
239
|
-
probs,
|
240
|
-
)
|
218
|
+
if state is None:
|
219
|
+
state = circuit.native.init_state(batch_size=infer_batchsize(param_values))
|
220
|
+
elif state is not None and pyqify_state:
|
221
|
+
n_qubits = circuit.abstract.n_qubits
|
222
|
+
state = pyqify(state, n_qubits) if pyqify_state else state
|
223
|
+
samples: list[Counter] = circuit.native.sample(
|
224
|
+
state=state, values=param_values, n_shots=n_shots
|
225
|
+
)
|
226
|
+
samples = invert_endianness(samples) if endianness != Endianness.BIG else samples
|
227
|
+
if noise is not None:
|
228
|
+
samples = apply_noise(noise=noise, samples=samples)
|
229
|
+
if mitigation is not None:
|
230
|
+
logger.warning(
|
231
|
+
"Mitigation protocol is deprecated. Use qadence-protocols instead.",
|
241
232
|
)
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
logger.warning(
|
246
|
-
"Mitigation protocol is deprecated. Use qadence-protocols instead.",
|
247
|
-
)
|
248
|
-
assert noise
|
249
|
-
samples = apply_mitigation(noise=noise, mitigation=mitigation, samples=samples)
|
250
|
-
return samples
|
233
|
+
assert noise
|
234
|
+
samples = apply_mitigation(noise=noise, mitigation=mitigation, samples=samples)
|
235
|
+
return samples
|
251
236
|
|
252
237
|
def assign_parameters(self, circuit: ConvertedCircuit, param_values: dict[str, Tensor]) -> Any:
|
253
238
|
raise NotImplementedError
|