qadence 1.4.0__tar.gz → 1.5.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.
Files changed (155) hide show
  1. {qadence-1.4.0 → qadence-1.5.0}/PKG-INFO +22 -8
  2. {qadence-1.4.0 → qadence-1.5.0}/README.md +14 -3
  3. {qadence-1.4.0 → qadence-1.5.0}/mkdocs.yml +1 -1
  4. {qadence-1.4.0 → qadence-1.5.0}/pyproject.toml +6 -4
  5. {qadence-1.4.0 → qadence-1.5.0}/qadence/__init__.py +1 -0
  6. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pulser/backend.py +1 -1
  7. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pulser/config.py +3 -0
  8. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pyqtorch/backend.py +25 -22
  9. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pyqtorch/convert_ops.py +25 -10
  10. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/utils.py +3 -2
  11. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/ansatze.py +5 -0
  12. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/feature_maps.py +4 -0
  13. {qadence-1.4.0 → qadence-1.5.0}/qadence/engines/torch/differentiable_expectation.py +4 -164
  14. {qadence-1.4.0 → qadence-1.5.0}/qadence/extensions.py +1 -0
  15. qadence-1.5.0/qadence/libs.py +15 -0
  16. qadence-1.5.0/qadence/measurements/samples.py +38 -0
  17. qadence-1.5.0/qadence/measurements/tomography.py +69 -0
  18. qadence-1.5.0/qadence/measurements/utils.py +180 -0
  19. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/data.py +11 -11
  20. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/models.py +8 -8
  21. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/optimize_step.py +2 -1
  22. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/train_grad.py +4 -2
  23. {qadence-1.4.0 → qadence-1.5.0}/qadence/models/quantum_model.py +12 -7
  24. {qadence-1.4.0 → qadence-1.5.0}/qadence/operations/analog.py +1 -0
  25. qadence-1.5.0/renovate.json +15 -0
  26. qadence-1.4.0/qadence/measurements/tomography.py +0 -179
  27. {qadence-1.4.0 → qadence-1.5.0}/.coveragerc +0 -0
  28. {qadence-1.4.0 → qadence-1.5.0}/.github/dependabot.yml +0 -0
  29. {qadence-1.4.0 → qadence-1.5.0}/.github/workflows/build_docs.yml +0 -0
  30. {qadence-1.4.0 → qadence-1.5.0}/.github/workflows/dependabot.yml +0 -0
  31. {qadence-1.4.0 → qadence-1.5.0}/.github/workflows/lint.yml +0 -0
  32. {qadence-1.4.0 → qadence-1.5.0}/.github/workflows/test_all.yml +0 -0
  33. {qadence-1.4.0 → qadence-1.5.0}/.github/workflows/test_examples.yml +0 -0
  34. {qadence-1.4.0 → qadence-1.5.0}/.github/workflows/test_fast.yml +0 -0
  35. {qadence-1.4.0 → qadence-1.5.0}/.gitignore +0 -0
  36. {qadence-1.4.0 → qadence-1.5.0}/.pre-commit-config.yaml +0 -0
  37. {qadence-1.4.0 → qadence-1.5.0}/LICENSE +0 -0
  38. {qadence-1.4.0 → qadence-1.5.0}/MANIFEST.in +0 -0
  39. {qadence-1.4.0 → qadence-1.5.0}/qadence/analog/__init__.py +0 -0
  40. {qadence-1.4.0 → qadence-1.5.0}/qadence/analog/addressing.py +0 -0
  41. {qadence-1.4.0 → qadence-1.5.0}/qadence/analog/constants.py +0 -0
  42. {qadence-1.4.0 → qadence-1.5.0}/qadence/analog/device.py +0 -0
  43. {qadence-1.4.0 → qadence-1.5.0}/qadence/analog/hamiltonian_terms.py +0 -0
  44. {qadence-1.4.0 → qadence-1.5.0}/qadence/analog/parse_analog.py +0 -0
  45. {qadence-1.4.0 → qadence-1.5.0}/qadence/backend.py +0 -0
  46. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/__init__.py +0 -0
  47. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/adjoint.py +0 -0
  48. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/api.py +0 -0
  49. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/braket/__init__.py +0 -0
  50. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/braket/backend.py +0 -0
  51. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/braket/config.py +0 -0
  52. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/braket/convert_ops.py +0 -0
  53. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/gpsr.py +0 -0
  54. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/horqrux/__init__.py +0 -0
  55. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/horqrux/backend.py +0 -0
  56. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/horqrux/config.py +0 -0
  57. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/horqrux/convert_ops.py +0 -0
  58. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/jax_utils.py +0 -0
  59. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pulser/__init__.py +0 -0
  60. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pulser/channels.py +0 -0
  61. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pulser/cloud.py +0 -0
  62. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pulser/convert_ops.py +0 -0
  63. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pulser/devices.py +0 -0
  64. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pulser/pulses.py +0 -0
  65. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pulser/waveforms.py +0 -0
  66. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pyqtorch/__init__.py +0 -0
  67. {qadence-1.4.0 → qadence-1.5.0}/qadence/backends/pyqtorch/config.py +0 -0
  68. {qadence-1.4.0 → qadence-1.5.0}/qadence/blocks/__init__.py +0 -0
  69. {qadence-1.4.0 → qadence-1.5.0}/qadence/blocks/abstract.py +0 -0
  70. {qadence-1.4.0 → qadence-1.5.0}/qadence/blocks/analog.py +0 -0
  71. {qadence-1.4.0 → qadence-1.5.0}/qadence/blocks/block_to_tensor.py +0 -0
  72. {qadence-1.4.0 → qadence-1.5.0}/qadence/blocks/composite.py +0 -0
  73. {qadence-1.4.0 → qadence-1.5.0}/qadence/blocks/embedding.py +0 -0
  74. {qadence-1.4.0 → qadence-1.5.0}/qadence/blocks/manipulate.py +0 -0
  75. {qadence-1.4.0 → qadence-1.5.0}/qadence/blocks/matrix.py +0 -0
  76. {qadence-1.4.0 → qadence-1.5.0}/qadence/blocks/primitive.py +0 -0
  77. {qadence-1.4.0 → qadence-1.5.0}/qadence/blocks/utils.py +0 -0
  78. {qadence-1.4.0 → qadence-1.5.0}/qadence/circuit.py +0 -0
  79. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/__init__.py +0 -0
  80. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/daqc/__init__.py +0 -0
  81. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/daqc/daqc.py +0 -0
  82. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/daqc/gen_parser.py +0 -0
  83. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/daqc/utils.py +0 -0
  84. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/hamiltonians.py +0 -0
  85. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/iia.py +0 -0
  86. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/qft.py +0 -0
  87. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/rydberg_feature_maps.py +0 -0
  88. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/rydberg_hea.py +0 -0
  89. {qadence-1.4.0 → qadence-1.5.0}/qadence/constructors/utils.py +0 -0
  90. {qadence-1.4.0 → qadence-1.5.0}/qadence/decompose.py +0 -0
  91. {qadence-1.4.0 → qadence-1.5.0}/qadence/divergences.py +0 -0
  92. {qadence-1.4.0 → qadence-1.5.0}/qadence/draw/__init__.py +0 -0
  93. {qadence-1.4.0 → qadence-1.5.0}/qadence/draw/assets/dark/measurement.png +0 -0
  94. {qadence-1.4.0 → qadence-1.5.0}/qadence/draw/assets/dark/measurement.svg +0 -0
  95. {qadence-1.4.0 → qadence-1.5.0}/qadence/draw/assets/light/measurement.png +0 -0
  96. {qadence-1.4.0 → qadence-1.5.0}/qadence/draw/assets/light/measurement.svg +0 -0
  97. {qadence-1.4.0 → qadence-1.5.0}/qadence/draw/themes.py +0 -0
  98. {qadence-1.4.0 → qadence-1.5.0}/qadence/draw/utils.py +0 -0
  99. {qadence-1.4.0 → qadence-1.5.0}/qadence/draw/vizbackend.py +0 -0
  100. {qadence-1.4.0 → qadence-1.5.0}/qadence/engines/__init__.py +0 -0
  101. {qadence-1.4.0 → qadence-1.5.0}/qadence/engines/differentiable_backend.py +0 -0
  102. {qadence-1.4.0 → qadence-1.5.0}/qadence/engines/jax/__init__.py +0 -0
  103. {qadence-1.4.0 → qadence-1.5.0}/qadence/engines/jax/differentiable_backend.py +0 -0
  104. {qadence-1.4.0 → qadence-1.5.0}/qadence/engines/jax/differentiable_expectation.py +0 -0
  105. {qadence-1.4.0 → qadence-1.5.0}/qadence/engines/torch/__init__.py +0 -0
  106. {qadence-1.4.0 → qadence-1.5.0}/qadence/engines/torch/differentiable_backend.py +0 -0
  107. {qadence-1.4.0 → qadence-1.5.0}/qadence/exceptions/__init__.py +0 -0
  108. {qadence-1.4.0 → qadence-1.5.0}/qadence/exceptions/exceptions.py +0 -0
  109. {qadence-1.4.0 → qadence-1.5.0}/qadence/execution.py +0 -0
  110. {qadence-1.4.0 → qadence-1.5.0}/qadence/finitediff.py +0 -0
  111. {qadence-1.4.0 → qadence-1.5.0}/qadence/logger.py +0 -0
  112. {qadence-1.4.0 → qadence-1.5.0}/qadence/measurements/__init__.py +0 -0
  113. {qadence-1.4.0 → qadence-1.5.0}/qadence/measurements/protocols.py +2 -2
  114. {qadence-1.4.0 → qadence-1.5.0}/qadence/measurements/shadow.py +0 -0
  115. {qadence-1.4.0 → qadence-1.5.0}/qadence/mitigations/__init__.py +0 -0
  116. {qadence-1.4.0 → qadence-1.5.0}/qadence/mitigations/analog_zne.py +0 -0
  117. {qadence-1.4.0 → qadence-1.5.0}/qadence/mitigations/protocols.py +0 -0
  118. {qadence-1.4.0 → qadence-1.5.0}/qadence/mitigations/readout.py +0 -0
  119. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/__init__.py +0 -0
  120. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/config.py +0 -0
  121. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/parameters.py +0 -0
  122. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/printing.py +0 -0
  123. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/saveload.py +0 -0
  124. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/tensors.py +0 -0
  125. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/train_no_grad.py +0 -0
  126. {qadence-1.4.0 → qadence-1.5.0}/qadence/ml_tools/utils.py +0 -0
  127. {qadence-1.4.0 → qadence-1.5.0}/qadence/models/__init__.py +0 -0
  128. {qadence-1.4.0 → qadence-1.5.0}/qadence/models/qnn.py +0 -0
  129. {qadence-1.4.0 → qadence-1.5.0}/qadence/noise/__init__.py +0 -0
  130. {qadence-1.4.0 → qadence-1.5.0}/qadence/noise/protocols.py +0 -0
  131. {qadence-1.4.0 → qadence-1.5.0}/qadence/noise/readout.py +0 -0
  132. {qadence-1.4.0 → qadence-1.5.0}/qadence/operations/__init__.py +0 -0
  133. {qadence-1.4.0 → qadence-1.5.0}/qadence/operations/control_ops.py +0 -0
  134. {qadence-1.4.0 → qadence-1.5.0}/qadence/operations/ham_evo.py +0 -0
  135. {qadence-1.4.0 → qadence-1.5.0}/qadence/operations/parametric.py +0 -0
  136. {qadence-1.4.0 → qadence-1.5.0}/qadence/operations/primitive.py +0 -0
  137. {qadence-1.4.0 → qadence-1.5.0}/qadence/overlap.py +0 -0
  138. {qadence-1.4.0 → qadence-1.5.0}/qadence/parameters.py +0 -0
  139. {qadence-1.4.0 → qadence-1.5.0}/qadence/protocols.py +0 -0
  140. {qadence-1.4.0 → qadence-1.5.0}/qadence/py.typed +0 -0
  141. {qadence-1.4.0 → qadence-1.5.0}/qadence/qubit_support.py +0 -0
  142. {qadence-1.4.0 → qadence-1.5.0}/qadence/register.py +0 -0
  143. {qadence-1.4.0 → qadence-1.5.0}/qadence/serialization.py +0 -0
  144. {qadence-1.4.0 → qadence-1.5.0}/qadence/states.py +0 -0
  145. {qadence-1.4.0 → qadence-1.5.0}/qadence/transpile/__init__.py +0 -0
  146. {qadence-1.4.0 → qadence-1.5.0}/qadence/transpile/apply_fn.py +0 -0
  147. {qadence-1.4.0 → qadence-1.5.0}/qadence/transpile/block.py +0 -0
  148. {qadence-1.4.0 → qadence-1.5.0}/qadence/transpile/circuit.py +0 -0
  149. {qadence-1.4.0 → qadence-1.5.0}/qadence/transpile/digitalize.py +0 -0
  150. {qadence-1.4.0 → qadence-1.5.0}/qadence/transpile/flatten.py +0 -0
  151. {qadence-1.4.0 → qadence-1.5.0}/qadence/transpile/invert.py +0 -0
  152. {qadence-1.4.0 → qadence-1.5.0}/qadence/transpile/transpile.py +0 -0
  153. {qadence-1.4.0 → qadence-1.5.0}/qadence/types.py +0 -0
  154. {qadence-1.4.0 → qadence-1.5.0}/qadence/utils.py +0 -0
  155. {qadence-1.4.0 → qadence-1.5.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: qadence
3
- Version: 1.4.0
3
+ Version: 1.5.0
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>
6
6
  License: Apache 2.0
@@ -13,14 +13,14 @@ Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: Implementation :: CPython
15
15
  Classifier: Programming Language :: Python :: Implementation :: PyPy
16
- Requires-Python: <3.12,>=3.9
16
+ Requires-Python: <3.13,>=3.9
17
17
  Requires-Dist: deepdiff
18
18
  Requires-Dist: jsonschema
19
19
  Requires-Dist: matplotlib
20
20
  Requires-Dist: nevergrad
21
21
  Requires-Dist: numpy
22
22
  Requires-Dist: openfermion
23
- Requires-Dist: pyqtorch==1.0.6
23
+ Requires-Dist: pyqtorch==1.1.0
24
24
  Requires-Dist: rich
25
25
  Requires-Dist: scipy
26
26
  Requires-Dist: sympytorch>=0.1.2
@@ -29,10 +29,11 @@ Requires-Dist: torch
29
29
  Provides-Extra: all
30
30
  Requires-Dist: amazon-braket-sdk; extra == 'all'
31
31
  Requires-Dist: graphviz; extra == 'all'
32
+ Requires-Dist: libs; extra == 'all'
32
33
  Requires-Dist: protocols; extra == 'all'
33
34
  Requires-Dist: pulser>=0.15.2; extra == 'all'
34
35
  Provides-Extra: braket
35
- Requires-Dist: amazon-braket-sdk; extra == 'braket'
36
+ Requires-Dist: amazon-braket-sdk==1.71.0; extra == 'braket'
36
37
  Provides-Extra: horqrux
37
38
  Requires-Dist: einops; extra == 'horqrux'
38
39
  Requires-Dist: flax; extra == 'horqrux'
@@ -41,6 +42,8 @@ Requires-Dist: jax; extra == 'horqrux'
41
42
  Requires-Dist: jaxopt; extra == 'horqrux'
42
43
  Requires-Dist: optax; extra == 'horqrux'
43
44
  Requires-Dist: sympy2jax; extra == 'horqrux'
45
+ Provides-Extra: libs
46
+ Requires-Dist: qadence-libs; extra == 'libs'
44
47
  Provides-Extra: protocols
45
48
  Requires-Dist: qadence-protocols; extra == 'protocols'
46
49
  Provides-Extra: pulser
@@ -51,13 +54,15 @@ Requires-Dist: graphviz; extra == 'visualization'
51
54
  Description-Content-Type: text/markdown
52
55
 
53
56
  <picture>
54
- <source media="(prefers-color-scheme: dark)" srcset="./docs/logo/qadence_logo_white.svg">
55
- <source media="(prefers-color-scheme: light)" srcset="./docs/logo/qadence_logo.svg">
56
- <img alt="Qadence logo" src="./docs/logo/qadence_logo.svg">
57
+ <source media="(prefers-color-scheme: dark)" srcset="./docs/assets/logo/qadence_logo_white.svg">
58
+ <source media="(prefers-color-scheme: light)" srcset="./docs/assets/logo/qadence_logo.svg">
59
+ <img alt="Qadence logo" src="./docs/assets/logo/qadence_logo.svg">
57
60
  </picture>
58
61
 
59
62
  **For a high-level overview of Qadence features, [check out our white paper](https://arxiv.org/abs/2401.09915).**
60
63
 
64
+ **For more detailed information, [check out the documentation](https://pasqal-io.github.io/qadence/latest/).**
65
+
61
66
  **Qadence** is a Python package that provides a simple interface to build _**digital-analog quantum
62
67
  programs**_ with tunable qubit interaction defined on _**arbitrary register topologies**_ realizable on neutral atom devices.
63
68
 
@@ -69,6 +74,13 @@ programs**_ with tunable qubit interaction defined on _**arbitrary register topo
69
74
 
70
75
  ## Feature highlights
71
76
 
77
+ <picture>
78
+ <source media="(prefers-color-scheme: dark)" srcset="./docs/assets/qadence_arch.svg">
79
+ <source media="(prefers-color-scheme: light)" srcset="./docs/assets/qadence_arch.svg">
80
+ <img alt="Qadence architecture" src="./docs/assets/qadence_arch.svg">
81
+ </picture>
82
+
83
+
72
84
  * A [block-based system](docs/tutorials/getting_started.md) for composing _**complex digital-analog
73
85
  programs**_ in a flexible and scalable manner, inspired by the Julia quantum SDK
74
86
  [Yao.jl](https://github.com/QuantumBFS/Yao.jl) and functional programming concepts.
@@ -97,6 +109,8 @@ The default, pre-installed backend for Qadence is [PyQTorch](https://github.com/
97
109
  * `pulser`: The [Pulser](https://github.com/pasqal-io/Pulser) backend for composing, simulating and executing pulse sequences for neutral-atom quantum devices.
98
110
  * `braket`: The [Braket](https://github.com/amazon-braket/amazon-braket-sdk-python) backend, an open source library that provides a framework for interacting with quantum computing hardware devices through Amazon Braket.
99
111
  * `visualization`: A visualization library to display quantum circuit diagrams.
112
+ * `protocols`: A collection of [protocols](https://github.com/pasqal-io/qadence-protocols) for error mitigation in Qadence.
113
+ * `libs`: A collection of [functionalities](https://github.com/pasqal-io/qadence-libs) for graph machine learning problems build on top of Qadence.
100
114
 
101
115
  Qadence also supports a `JAX` engine which is currently supporting the [Horqrux](https://github.com/pasqal-io/horqrux) backend. `horqrux` is currently only available via the [low-level API](examples/backends/low_level/horqrux_backend.py).
102
116
 
@@ -1,11 +1,13 @@
1
1
  <picture>
2
- <source media="(prefers-color-scheme: dark)" srcset="./docs/logo/qadence_logo_white.svg">
3
- <source media="(prefers-color-scheme: light)" srcset="./docs/logo/qadence_logo.svg">
4
- <img alt="Qadence logo" src="./docs/logo/qadence_logo.svg">
2
+ <source media="(prefers-color-scheme: dark)" srcset="./docs/assets/logo/qadence_logo_white.svg">
3
+ <source media="(prefers-color-scheme: light)" srcset="./docs/assets/logo/qadence_logo.svg">
4
+ <img alt="Qadence logo" src="./docs/assets/logo/qadence_logo.svg">
5
5
  </picture>
6
6
 
7
7
  **For a high-level overview of Qadence features, [check out our white paper](https://arxiv.org/abs/2401.09915).**
8
8
 
9
+ **For more detailed information, [check out the documentation](https://pasqal-io.github.io/qadence/latest/).**
10
+
9
11
  **Qadence** is a Python package that provides a simple interface to build _**digital-analog quantum
10
12
  programs**_ with tunable qubit interaction defined on _**arbitrary register topologies**_ realizable on neutral atom devices.
11
13
 
@@ -17,6 +19,13 @@ programs**_ with tunable qubit interaction defined on _**arbitrary register topo
17
19
 
18
20
  ## Feature highlights
19
21
 
22
+ <picture>
23
+ <source media="(prefers-color-scheme: dark)" srcset="./docs/assets/qadence_arch.svg">
24
+ <source media="(prefers-color-scheme: light)" srcset="./docs/assets/qadence_arch.svg">
25
+ <img alt="Qadence architecture" src="./docs/assets/qadence_arch.svg">
26
+ </picture>
27
+
28
+
20
29
  * A [block-based system](docs/tutorials/getting_started.md) for composing _**complex digital-analog
21
30
  programs**_ in a flexible and scalable manner, inspired by the Julia quantum SDK
22
31
  [Yao.jl](https://github.com/QuantumBFS/Yao.jl) and functional programming concepts.
@@ -45,6 +54,8 @@ The default, pre-installed backend for Qadence is [PyQTorch](https://github.com/
45
54
  * `pulser`: The [Pulser](https://github.com/pasqal-io/Pulser) backend for composing, simulating and executing pulse sequences for neutral-atom quantum devices.
46
55
  * `braket`: The [Braket](https://github.com/amazon-braket/amazon-braket-sdk-python) backend, an open source library that provides a framework for interacting with quantum computing hardware devices through Amazon Braket.
47
56
  * `visualization`: A visualization library to display quantum circuit diagrams.
57
+ * `protocols`: A collection of [protocols](https://github.com/pasqal-io/qadence-protocols) for error mitigation in Qadence.
58
+ * `libs`: A collection of [functionalities](https://github.com/pasqal-io/qadence-libs) for graph machine learning problems build on top of Qadence.
48
59
 
49
60
  Qadence also supports a `JAX` engine which is currently supporting the [Horqrux](https://github.com/pasqal-io/horqrux) backend. `horqrux` is currently only available via the [low-level API](examples/backends/low_level/horqrux_backend.py).
50
61
 
@@ -79,7 +79,7 @@ edit_uri: edit/main/docs/
79
79
 
80
80
  theme:
81
81
  name: material
82
- logo: logo/qadence_logo_small_white.svg
82
+ logo: assets/logo/qadence_logo_small_white.svg
83
83
  features:
84
84
  - content.code.annotate
85
85
  - content.action.view
@@ -18,9 +18,9 @@ authors = [
18
18
  { name = "Vytautas Abramavicius", email = "vytautas.abramavicius@pasqal.com" },
19
19
  { name = "Gergana Velikova", email = "gergana.velikova@pasqal.com" },
20
20
  ]
21
- requires-python = ">=3.9,<3.12"
21
+ requires-python = ">=3.9,<3.13"
22
22
  license = {text = "Apache 2.0"}
23
- version = "1.4.0"
23
+ version = "1.5.0"
24
24
  classifiers=[
25
25
  "License :: OSI Approved :: Apache Software License",
26
26
  "Programming Language :: Python",
@@ -42,7 +42,7 @@ dependencies = [
42
42
  "jsonschema",
43
43
  "nevergrad",
44
44
  "scipy",
45
- "pyqtorch==1.0.6",
45
+ "pyqtorch==1.1.0",
46
46
  "matplotlib",
47
47
  ]
48
48
 
@@ -52,7 +52,7 @@ allow-ambiguous-features = true
52
52
 
53
53
  [project.optional-dependencies]
54
54
  pulser = ["pulser>=v0.15.2", "pasqal-cloud>=0.3.5"]
55
- braket = ["amazon-braket-sdk"]
55
+ braket = ["amazon-braket-sdk==1.71.0"]
56
56
  visualization = [
57
57
  "graphviz",
58
58
  # FIXME: will be needed once we support latex labels
@@ -68,11 +68,13 @@ horqrux = [
68
68
  "einops",
69
69
  "sympy2jax"]
70
70
  protocols = ["qadence-protocols"]
71
+ libs = ["qadence-libs"]
71
72
  all = [
72
73
  "pulser>=0.15.2",
73
74
  "amazon-braket-sdk",
74
75
  "graphviz",
75
76
  "protocols",
77
+ "libs",
76
78
  # FIXME: will be needed once we support latex labels
77
79
  # "latex2svg @ git+https://github.com/Moonbase59/latex2svg.git#egg=latex2svg",
78
80
  # "scour",
@@ -32,6 +32,7 @@ DEFAULT_FLOAT_DTYPE = torchfloat64
32
32
  DEFAULT_COMPLEX_DTYPE = cdouble
33
33
  set_default_dtype(DEFAULT_FLOAT_DTYPE)
34
34
 
35
+
35
36
  """Fetch the functions defined in the __all__ of each sub-module.
36
37
 
37
38
  Import to the qadence name space. Make sure each added submodule has the respective definition:
@@ -71,7 +71,7 @@ def make_sequence(circ: QuantumCircuit, config: Configuration) -> Sequence:
71
71
  )
72
72
 
73
73
  ########
74
- # FIXME: Remove the block below in V1.1.0
74
+ # FIXME: Remove the block below in V1.5.0
75
75
  if config.spacing is not None:
76
76
  logger.warning(
77
77
  "Passing register spacing in the backend configuration is deprecated. "
@@ -30,6 +30,7 @@ class Configuration(BackendConfiguration):
30
30
 
31
31
  FIXME: This is deprecated, the device_type is now controlled in the
32
32
  Qadence Device, as detailed in the documentation.
33
+ FIXME: Remove in v1.5.0
33
34
  """
34
35
 
35
36
  sampling_rate: float = 1.0
@@ -44,6 +45,7 @@ class Configuration(BackendConfiguration):
44
45
 
45
46
  FIXME: This is deprecated, spacing is now controlled in the Register,
46
47
  as detailed in the register tutorial.
48
+ FIXME: Remove in v1.5.0
47
49
  """
48
50
 
49
51
  method_solv: str = "adams"
@@ -89,6 +91,7 @@ class Configuration(BackendConfiguration):
89
91
 
90
92
  FIXME: This is deprecated, the interaction is now controlled in the
91
93
  Qadence Device, as detailed in the documentation.
94
+ FIXME: Remove in v1.5.0
92
95
  """
93
96
 
94
97
  # configuration for cloud simulations
@@ -151,7 +151,9 @@ class Backend(BackendInterface):
151
151
  if state is None:
152
152
  from qadence.states import zero_state
153
153
 
154
- state = zero_state(circuit.abstract.n_qubits, batch_size=1)
154
+ state = zero_state(circuit.abstract.n_qubits, batch_size=1).to(
155
+ dtype=circuit.native.dtype
156
+ )
155
157
  if state.size(0) != 1:
156
158
  raise ValueError(
157
159
  "Looping expectation does not make sense with batched initial state. "
@@ -222,28 +224,29 @@ class Backend(BackendInterface):
222
224
  }
223
225
  )
224
226
 
225
- wf = self.run(circuit=circuit, param_values=param_values, state=state)
226
- probs = torch.abs(torch.pow(wf, 2))
227
- samples = list(
228
- map(
229
- lambda _probs: _sample(
230
- _probs=_probs,
231
- n_shots=n_shots,
232
- endianness=endianness,
233
- n_qubits=circuit.abstract.n_qubits,
234
- ),
235
- probs,
236
- )
237
- )
238
- if noise is not None:
239
- samples = apply_noise(noise=noise, samples=samples)
240
- if mitigation is not None:
241
- logger.warning(
242
- "Mitigation protocol is deprecated. Use qadence-protocols instead.",
227
+ with torch.no_grad():
228
+ wf = self.run(circuit=circuit, param_values=param_values, state=state)
229
+ probs = torch.abs(torch.pow(wf, 2))
230
+ samples = list(
231
+ map(
232
+ lambda _probs: _sample(
233
+ _probs=_probs,
234
+ n_shots=n_shots,
235
+ endianness=endianness,
236
+ n_qubits=circuit.abstract.n_qubits,
237
+ ),
238
+ probs,
239
+ )
243
240
  )
244
- assert noise
245
- samples = apply_mitigation(noise=noise, mitigation=mitigation, samples=samples)
246
- return samples
241
+ if noise is not None:
242
+ samples = apply_noise(noise=noise, samples=samples)
243
+ if mitigation is not None:
244
+ logger.warning(
245
+ "Mitigation protocol is deprecated. Use qadence-protocols instead.",
246
+ )
247
+ assert noise
248
+ samples = apply_mitigation(noise=noise, mitigation=mitigation, samples=samples)
249
+ return samples
247
250
 
248
251
  def assign_parameters(self, circuit: ConvertedCircuit, param_values: dict[str, Tensor]) -> Any:
249
252
  raise NotImplementedError
@@ -4,7 +4,7 @@ from functools import reduce
4
4
  from itertools import chain as flatten
5
5
  from math import prod
6
6
  from operator import add
7
- from typing import Sequence, Tuple
7
+ from typing import Any, Sequence, Tuple
8
8
 
9
9
  import pyqtorch as pyq
10
10
  import sympy
@@ -26,6 +26,7 @@ from torch import (
26
26
  transpose,
27
27
  )
28
28
  from torch import device as torch_device
29
+ from torch import dtype as torch_dtype
29
30
  from torch.nn import Module
30
31
 
31
32
  from qadence.backends.utils import (
@@ -178,6 +179,7 @@ class PyQMatrixBlock(Module):
178
179
  self.register_buffer("mat", block.matrix.unsqueeze(2))
179
180
  self.mat: Tensor
180
181
  self._device: torch_device = self.mat.device
182
+ self._dtype: torch_dtype = self.mat.dtype
181
183
 
182
184
  def forward(self, state: Tensor, _: dict[str, Tensor] = None) -> Tensor:
183
185
  return apply_operator(state, self.mat, self.qubits, self.n_qubits)
@@ -186,9 +188,10 @@ class PyQMatrixBlock(Module):
186
188
  def device(self) -> torch_device:
187
189
  return self._device
188
190
 
189
- def to(self, device: torch_device) -> PyQMatrixBlock:
190
- self.mat = self.mat.to(device)
191
- self._device = device
191
+ def to(self, *args: Any, **kwargs: Any) -> PyQMatrixBlock:
192
+ self.mat = self.mat.to(*args, **kwargs)
193
+ self._device = self.mat.device
194
+ self._dtype = self.mat.dtype
192
195
  return self
193
196
 
194
197
 
@@ -262,6 +265,7 @@ class PyQObservable(Module):
262
265
  )
263
266
  self._forward = lambda self, state, values: self.operation(state, values)
264
267
  self._device = self.operation.device
268
+ self._dtype = self.operation.dtype
265
269
 
266
270
  def run(self, state: Tensor, values: dict[str, Tensor]) -> Tensor:
267
271
  return self._forward(self, state, values)
@@ -273,9 +277,14 @@ class PyQObservable(Module):
273
277
  def device(self) -> torch_device:
274
278
  return self._device
275
279
 
276
- def to(self, device: torch_device) -> PyQObservable:
277
- self.operation = self.operation.to(device)
278
- self._device = device
280
+ @property
281
+ def dtype(self) -> torch_dtype:
282
+ return self._dtype
283
+
284
+ def to(self, *args: Any, **kwargs: Any) -> PyQObservable:
285
+ self.operation = self.operation.to(*args, **kwargs)
286
+ self._device = self.operation.device
287
+ self._dtype = self.operation.dtype
279
288
  return self
280
289
 
281
290
 
@@ -338,6 +347,7 @@ class PyQHamiltonianEvolution(Module):
338
347
  self._device: torch_device = (
339
348
  self.hmat.device if hasattr(self, "hmat") else torch_device("cpu")
340
349
  )
350
+ self._dtype: torch_dtype = self.hmat.dtype if hasattr(self, "hmat") else cdouble
341
351
 
342
352
  def _unitary(self, hamiltonian: Tensor, time_evolution: Tensor) -> Tensor:
343
353
  self.batch_size = max(hamiltonian.size()[2], len(time_evolution))
@@ -419,10 +429,15 @@ class PyQHamiltonianEvolution(Module):
419
429
  def device(self) -> torch_device:
420
430
  return self._device
421
431
 
422
- def to(self, device: torch_device) -> PyQHamiltonianEvolution:
432
+ @property
433
+ def dtype(self) -> torch_dtype:
434
+ return self._dtype
435
+
436
+ def to(self, *args: Any, **kwargs: Any) -> PyQHamiltonianEvolution:
423
437
  if hasattr(self, "hmat"):
424
- self.hmat = self.hmat.to(device)
425
- self._device = device
438
+ self.hmat = self.hmat.to(*args, **kwargs)
439
+ self._device = self.hmat.device
440
+ self._dtype = self.hmat.dtype
426
441
  return self
427
442
 
428
443
 
@@ -13,6 +13,7 @@ from pyqtorch.parametric import Parametric as PyQParametric
13
13
  from torch import (
14
14
  Tensor,
15
15
  cat,
16
+ complex64,
16
17
  complex128,
17
18
  mean,
18
19
  no_grad,
@@ -129,8 +130,8 @@ def is_pyq_shape(state: Tensor, n_qubits: int) -> bool:
129
130
 
130
131
  def validate_state(state: Tensor, n_qubits: int) -> None:
131
132
  """Check if a custom initial state conforms to the qadence or the pyqtorch format."""
132
- if state.dtype != complex128:
133
- raise TypeError(f"Expected type complex128, got {state.dtype}")
133
+ if state.dtype not in [complex128, complex64]:
134
+ raise TypeError(f"Expected complex dtype, got {state.dtype}")
134
135
  elif len(state.size()) < 2:
135
136
  raise ValueError(f"Invalid state shape. Got {state.shape}")
136
137
  elif not is_qadence_shape(state, n_qubits) and not is_pyq_shape(state, n_qubits):
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import itertools
4
+ import warnings
4
5
  from typing import Any, Optional, Type, Union
5
6
 
6
7
  from qadence.blocks import AbstractBlock, block_is_qubit_hamiltonian, chain, kron, tag
@@ -328,6 +329,7 @@ def hea_analog(*args: Any, **kwargs: Any) -> Any:
328
329
  #########
329
330
 
330
331
 
332
+ # FIXME: Remove in v1.5.0
331
333
  def build_qnn(
332
334
  n_qubits: int,
333
335
  n_features: int,
@@ -360,6 +362,9 @@ def build_qnn(
360
362
  Returns:
361
363
  A list of Abstract blocks to be used for constructing a quantum circuit
362
364
  """
365
+
366
+ warnings.warn("Function build_qnn is deprecated and will be removed in v1.5.0.", FutureWarning)
367
+
363
368
  depth = n_qubits if depth is None else depth
364
369
 
365
370
  idx_fms = build_idx_fms(basis, fm_pauli, fm_strategy, n_features, n_qubits, spectrum)
@@ -35,6 +35,7 @@ RS_FUNC_DICT = {
35
35
  }
36
36
 
37
37
 
38
+ # FIXME: Remove in v1.5.0
38
39
  def backwards_compatibility(
39
40
  fm_type: BasisSet | Callable | str,
40
41
  reupload_scaling: ReuploadScaling | Callable | str,
@@ -224,6 +225,7 @@ def feature_map(
224
225
  return fm
225
226
 
226
227
 
228
+ # FIXME: Remove in v1.5.0
227
229
  def fourier_feature_map(
228
230
  n_qubits: int, support: tuple[int, ...] = None, param: str = "phi", op: RotationTypes = RX
229
231
  ) -> AbstractBlock:
@@ -241,6 +243,7 @@ def fourier_feature_map(
241
243
  return fm
242
244
 
243
245
 
246
+ # FIXME: Remove in v1.5.0
244
247
  def chebyshev_feature_map(
245
248
  n_qubits: int, support: tuple[int, ...] = None, param: str = "phi", op: RotationTypes = RX
246
249
  ) -> AbstractBlock:
@@ -259,6 +262,7 @@ def chebyshev_feature_map(
259
262
  return fm
260
263
 
261
264
 
265
+ # FIXME: Remove in v1.5.0
262
266
  def tower_feature_map(
263
267
  n_qubits: int, support: tuple[int, ...] = None, param: str = "phi", op: RotationTypes = RX
264
268
  ) -> AbstractBlock:
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from collections import Counter, OrderedDict
3
+ from collections import OrderedDict
4
4
  from dataclasses import dataclass
5
5
  from functools import partial
6
6
  from typing import Any, Callable, Sequence
@@ -8,22 +8,19 @@ from typing import Any, Callable, Sequence
8
8
  import torch
9
9
  from torch import Tensor
10
10
  from torch.autograd import Function
11
- from torch.nn import Module
12
11
 
13
12
  from qadence.backend import Backend as QuantumBackend
14
- from qadence.backend import Converted, ConvertedCircuit, ConvertedObservable
13
+ from qadence.backend import ConvertedCircuit, ConvertedObservable
15
14
  from qadence.backends.adjoint import AdjointExpectation
16
15
  from qadence.backends.utils import infer_batchsize, is_pyq_shape, param_dict, pyqify, validate_state
17
16
  from qadence.blocks.abstract import AbstractBlock
18
- from qadence.blocks.primitive import PrimitiveBlock
19
- from qadence.blocks.utils import uuid_to_block, uuid_to_eigen
17
+ from qadence.blocks.utils import uuid_to_eigen
20
18
  from qadence.circuit import QuantumCircuit
21
- from qadence.extensions import get_gpsr_fns
22
19
  from qadence.measurements import Measurements
23
20
  from qadence.mitigations import Mitigations
24
21
  from qadence.ml_tools import promote_to_tensor
25
22
  from qadence.noise import Noise
26
- from qadence.types import DiffMode, Endianness
23
+ from qadence.types import Endianness
27
24
 
28
25
 
29
26
  class PSRExpectation(Function):
@@ -232,160 +229,3 @@ class DifferentiableExpectation:
232
229
  # Since they are constants their gradients are 0.
233
230
  param_to_psr[param_id] = lambda x: torch.tensor([0.0], requires_grad=False)
234
231
  return param_to_psr
235
-
236
-
237
- class DifferentiableBackend(Module):
238
- """A class to abstract the operations done by the autodiff engine.
239
-
240
- Arguments:
241
- backend: An instance of the QuantumBackend type perform execution.
242
- diff_mode: A differentiable mode supported by the differentiation engine.
243
- **psr_args: Arguments that will be passed on to `DifferentiableExpectation`.
244
- """
245
-
246
- def __init__(
247
- self,
248
- backend: QuantumBackend,
249
- diff_mode: DiffMode = DiffMode.AD,
250
- **psr_args: int | float | None,
251
- ) -> None:
252
- super().__init__()
253
-
254
- self.backend = backend
255
- self.diff_mode = diff_mode
256
- self.psr_args = psr_args
257
- # TODO: Add differentiable overlap calculation
258
- self._overlap: Callable = None # type: ignore [assignment]
259
-
260
- def run(
261
- self,
262
- circuit: ConvertedCircuit,
263
- param_values: dict = {},
264
- state: Tensor | None = None,
265
- endianness: Endianness = Endianness.BIG,
266
- ) -> Tensor:
267
- """Run on the underlying backend."""
268
- return self.backend.run(
269
- circuit=circuit, param_values=param_values, state=state, endianness=endianness
270
- )
271
-
272
- def expectation(
273
- self,
274
- circuit: ConvertedCircuit,
275
- observable: list[ConvertedObservable] | ConvertedObservable,
276
- param_values: dict[str, Tensor] = {},
277
- state: Tensor | None = None,
278
- measurement: Measurements | None = None,
279
- noise: Noise | None = None,
280
- mitigation: Mitigations | None = None,
281
- endianness: Endianness = Endianness.BIG,
282
- ) -> Tensor:
283
- """Compute the expectation value of a given observable.
284
-
285
- Arguments:
286
- circuit: A backend native quantum circuit to be executed.
287
- observable: A backend native observable to compute the expectation value from.
288
- param_values: A dict of values for symbolic substitution.
289
- state: An initial state.
290
- measurement: A shot-based measurement protocol.
291
- endianness: Endianness of the state.
292
-
293
- Returns:
294
- A tensor of expectation values.
295
- """
296
- observable = observable if isinstance(observable, list) else [observable]
297
- differentiable_expectation = DifferentiableExpectation(
298
- backend=self.backend,
299
- circuit=circuit,
300
- observable=observable,
301
- param_values=param_values,
302
- state=state,
303
- measurement=measurement,
304
- noise=noise,
305
- mitigation=mitigation,
306
- endianness=endianness,
307
- )
308
-
309
- if self.diff_mode == DiffMode.AD:
310
- expectation = differentiable_expectation.ad
311
- elif self.diff_mode == DiffMode.ADJOINT:
312
- expectation = differentiable_expectation.adjoint
313
- else:
314
- try:
315
- fns = get_gpsr_fns()
316
- psr_fn = fns[self.diff_mode]
317
- except KeyError:
318
- raise ValueError(f"{self.diff_mode} differentiation mode is not supported")
319
- expectation = partial(differentiable_expectation.psr, psr_fn=psr_fn, **self.psr_args)
320
- return expectation()
321
-
322
- def sample(
323
- self,
324
- circuit: ConvertedCircuit,
325
- param_values: dict[str, Tensor],
326
- n_shots: int = 1,
327
- state: Tensor | None = None,
328
- noise: Noise | None = None,
329
- mitigation: Mitigations | None = None,
330
- endianness: Endianness = Endianness.BIG,
331
- ) -> list[Counter]:
332
- """Sample bitstring from the registered circuit.
333
-
334
- Arguments:
335
- circuit: A backend native quantum circuit to be executed.
336
- param_values: The values of the parameters after embedding
337
- n_shots: The number of shots. Defaults to 1.
338
- state: Initial state.
339
- noise: A noise model to use.
340
- mitigation: A mitigation protocol to apply to noisy samples.
341
- endianness: Endianness of the resulting bitstrings.
342
-
343
- Returns:
344
- An iterable with all the sampled bitstrings
345
- """
346
- with torch.no_grad():
347
- return self.backend.sample(
348
- circuit=circuit,
349
- param_values=param_values,
350
- n_shots=n_shots,
351
- state=state,
352
- noise=noise,
353
- mitigation=mitigation,
354
- endianness=endianness,
355
- )
356
-
357
- def circuit(self, circuit: QuantumCircuit) -> ConvertedCircuit:
358
- parametrized_blocks = list(uuid_to_block(circuit.block).values())
359
- non_prim_blocks = filter(lambda b: not isinstance(b, PrimitiveBlock), parametrized_blocks)
360
- if len(list(non_prim_blocks)) > 0:
361
- raise ValueError(
362
- "The circuit contains non-primitive blocks that are currently not supported by the "
363
- "PSR differentiable mode."
364
- )
365
- return self.backend.circuit(circuit)
366
-
367
- def observable(self, observable: AbstractBlock, n_qubits: int) -> ConvertedObservable:
368
- if observable is not None and observable.is_parametric:
369
- raise ValueError("PSR cannot be applied to a parametric observable.")
370
- return self.backend.observable(observable, n_qubits)
371
-
372
- def convert(
373
- self,
374
- circuit: QuantumCircuit,
375
- observable: list[AbstractBlock] | AbstractBlock | None = None,
376
- ) -> Converted:
377
- if self.diff_mode != DiffMode.AD and observable is not None:
378
- msg = (
379
- f"Differentiation mode '{self.diff_mode}' does not support parametric observables."
380
- )
381
- if isinstance(observable, list):
382
- for obs in observable:
383
- if obs.is_parametric:
384
- raise ValueError(msg)
385
- else:
386
- if observable.is_parametric:
387
- raise ValueError(msg)
388
- return self.backend.convert(circuit, observable)
389
-
390
- def assign_parameters(self, circuit: ConvertedCircuit, param_values: dict[str, Tensor]) -> Any:
391
- return self.backend.assign_parameters(circuit, param_values)
@@ -79,6 +79,7 @@ def _validate_diff_mode(backend: Backend, diff_mode: DiffMode) -> None:
79
79
 
80
80
  def _validate_backend_config(backend: Backend) -> None:
81
81
  if backend.config.use_gradient_checkpointing:
82
+ # FIXME: Remove in v1.5.0
82
83
  msg = "use_gradient_checkpointing is deprecated."
83
84
  import warnings
84
85