Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev into master #1302

Merged
merged 40 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d037085
Merge branch 'master' into dev
actions-user Nov 7, 2024
d440291
Merge branch 'master' into dev
actions-user Nov 7, 2024
9eee4c5
Merge branch 'master' into dev
actions-user Nov 7, 2024
c4acc2e
Merge branch 'master' into dev
actions-user Nov 7, 2024
3370db1
Merge branch 'master' into dev
actions-user Nov 8, 2024
0d7c3fb
Update deprecated `gradient_fn` argument to `diff_method` (#1264)
andrijapau Nov 12, 2024
38cc0a4
Update deprecated usage of `tape` and `qtape` properties in `QNode` (…
andrijapau Nov 15, 2024
b497909
Merge branch 'master' into dev
actions-user Nov 15, 2024
b94dfb4
Fix `max_expansion` deprecation warnings (#1268)
andrijapau Nov 19, 2024
0de2a7d
Merge branch 'master' into dev
actions-user Nov 20, 2024
394f245
Merge branch 'master' into dev
actions-user Nov 21, 2024
a2e93b1
Merge branch 'master' into dev
actions-user Nov 25, 2024
93c9fec
Merge branch 'master' into dev
actions-user Nov 25, 2024
e015c00
Merge branch 'master' into dev
actions-user Nov 25, 2024
171bcf4
Updating `pennylane-qrack` to version 0.11.1 and `bluequbit` (#1272)
PietropaoloFrisoni Dec 3, 2024
5bb9b1d
Merge branch 'master' into dev
actions-user Dec 5, 2024
d431140
QubitDevice removed from toplevel, along with their warnings (#1263)
JerryChen97 Dec 5, 2024
e5404df
Update QSVT on hardware how-to to use poly_to_angles (#1273)
soranjh Dec 6, 2024
d88d898
Merge branch 'master' into dev
actions-user Dec 6, 2024
8d4f99d
Merge branch 'master' into dev
actions-user Dec 9, 2024
b9009ab
Update QSVT demos (intro_qsvt and apply_qsvt) (#1276)
KetpuntoG Dec 11, 2024
07dbec8
Update qchem demos to be JAX or JAX/JIT compatible (#1211)
austingmhuang Dec 13, 2024
95ef8d3
Fix demos to use jax that require grads (#1226)
austingmhuang Dec 13, 2024
57eb851
Merge branch 'master' into dev
actions-user Dec 13, 2024
ab12990
Merge branch 'master' into dev
actions-user Dec 18, 2024
c48675e
Merge branch 'master' into dev
actions-user Dec 19, 2024
ac53b35
Merge branch 'master' into dev
actions-user Dec 20, 2024
13bd02d
Temp update to makefile to install PL RC (#1290)
PietropaoloFrisoni Jan 7, 2025
6bf981c
Merge branch 'master' into dev
actions-user Jan 8, 2025
cd3edc6
Merge branch 'master' into dev
actions-user Jan 9, 2025
2b58378
Merge branch 'master' into dev
actions-user Jan 9, 2025
10b0e58
QA demo process for PL 0.40 during feature freeze (#1291)
PietropaoloFrisoni Jan 10, 2025
614b305
QA updates v0.40 lillian (#1296)
lillian542 Jan 10, 2025
88a3a17
Updates to quantum volume and how to use qiskit (#1289)
albi3ro Jan 10, 2025
3a53c3a
[QA v0.40.0] Demo Improvements (#1293)
andrijapau Jan 11, 2025
89eb7dd
[QA v0.40.0] Fix liesim_extension demo (#1298)
Qottmann Jan 13, 2025
b5b4de0
[QA v.0.40.0] Fix liesim_extension demo small typoe (#1299)
Qottmann Jan 13, 2025
886976d
Update PL and plugin dependencies (#1297)
PietropaoloFrisoni Jan 14, 2025
d77a460
E.C.
PietropaoloFrisoni Jan 14, 2025
f9c2fc7
Re-triggering CI after new label
PietropaoloFrisoni Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@

# Raise PennyLane deprecation warnings as errors
warnings.filterwarnings("error", category=PennyLaneDeprecationWarning)
warnings.filterwarnings(
"ignore", message="Device will no longer be accessible", category=PennyLaneDeprecationWarning
)

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down
2 changes: 1 addition & 1 deletion demonstrations/ensemble_multi_qpu.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2020-02-14T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2025-01-14T00:00:00+00:00",
"categories": [
"Quantum Machine Learning"
],
Expand Down
16 changes: 8 additions & 8 deletions demonstrations/ensemble_multi_qpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
classification problem.

.. warning::
This demo does not work with the latest version of Qiskit or the Pennylane-Qiskit plugin.
It is compatible with ``qiskit==0.46`` and ``pennylane-qiskit==0.35.1``. Older versions of
Qiskit and the Pennylane-Qiskit plugin should not be installed in environments with an
existing installation of Qiskit 1.0 or above.
This demo does not work with the latest version of Qiskit or the Pennylane-Qiskit plugin and
is compatible with Python versions 3.10 and lower. It is compatible with ``qiskit==0.46`` and
``pennylane-qiskit==0.35.1``. Older versions of Qiskit and the Pennylane-Qiskit plugin should
not be installed in environments with an existing installation of Qiskit 1.0 or above.

We use the ``rigetti.qvm`` device to simulate one QPU and the ``qiskit.aer`` device to
simulate another. Each QPU makes an independent prediction, and an ensemble model is
Expand Down Expand Up @@ -198,9 +198,9 @@ def plot_points(x_train, y_train, x_test, y_test):
##############################################################################
# .. note::
# If you have access to Rigetti hardware, you can swap out ``rigetti.qvm`` for ``rigetti.qpu``
# and specify the hardware device to run on. Users with access to the IBM Q Experience can
# swap ``qiskit.aer`` for ``qiskit.ibmq`` and specify their chosen backend (see `here
# <https://docs.pennylane.ai/projects/qiskit/en/latest/devices/ibmq.html>`__).
# and specify the hardware device to run on. Users with access to the IBM hardware can
# swap ``qiskit.aer`` for ``qiskit.remote`` and specify their chosen backend (see `here
# <https://docs.pennylane.ai/projects/qiskit/en/latest/devices/remote.html>`__).
#
#
# The circuits for both QPUs are shown in the figure below:
Expand Down Expand Up @@ -578,4 +578,4 @@ def plot_points_prediction(x, y, p, title):
##############################################################################
# About the author
# ----------------
# .. include:: ../_static/authors/thomas_bromley.txt
# .. include:: ../_static/authors/thomas_bromley.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2023-10-16T00:00:00+00:00",
"dateOfLastModification": "2024-11-06T00:00:00+00:00",
"dateOfLastModification": "2025-01-14T00:00:00+00:00",
"categories": [
"Devices and Performance"
],
Expand Down
4 changes: 4 additions & 0 deletions demonstrations/getting_started_with_hybrid_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ def circuit(params):
# .. note::
# AWS devices must be declared within the body of the decorated function.
#
# .. warning::
# The Rigetti device used in this demo, AspenM3, has been retired. For an updated list of available hardware through
# Amazon Braket, please consult the `supported regions and devices documentation <https://docs.aws.amazon.com/braket/latest/developerguide/braket-devices.html>`__. The general steps outlined below still hold regardless of the choice of device, though.
#

from braket.devices import Devices

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2024-07-02T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2025-01-08T00:00:00+00:00",
"categories": [
"Quantum Computing",
"How-to"
Expand Down
10 changes: 7 additions & 3 deletions demonstrations/how_to_use_qiskit1_with_pennylane.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def qiskit_GHZ_circuit(n):
#

pl_circuit = qml.QNode(pl_qfunc, device=qml.device("lightning.qubit", wires=n))
pl_circuit()
print(pl_circuit())

######################################################################
# .. rst-class:: sphx-glr-script-out
Expand All @@ -263,7 +263,7 @@ def qiskit_GHZ_circuit(n):
pl_qfunc = qml.from_qiskit(qc, measurements=measurements)

pl_circuit = qml.QNode(pl_qfunc, device=qml.device("default.qubit", wires=n))
pl_circuit(shots=5)
print(pl_circuit(shots=5))

######################################################################
# .. rst-class:: sphx-glr-script-out
Expand Down Expand Up @@ -304,6 +304,7 @@ def qiskit_GHZ_circuit(n):
#

from qiskit.circuit import ParameterVector, Parameter
from matplotlib import pyplot as plt

n = 3

Expand All @@ -316,6 +317,8 @@ def qiskit_GHZ_circuit(n):
qc.ry(angle2, [2])

qc.draw("mpl")
plt.show()


######################################################################
# .. rst-class:: image-no-text-wrap
Expand Down Expand Up @@ -349,7 +352,8 @@ def differentiable_circuit(phis, theta):
theta = np.array([0.19])

print(differentiable_circuit(phis, theta))
print(qml.draw_mpl(differentiable_circuit)(phis, theta))
qml.draw_mpl(differentiable_circuit, style="pennylane")(phis, theta)
plt.show()

######################################################################
# .. rst-class:: sphx-glr-script-out
Expand Down
2 changes: 1 addition & 1 deletion demonstrations/ibm_pennylane.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"dateOfPublication": "2023-06-20T00:00:00+00:00",
"dateOfLastModification": "2024-11-06T00:00:00+00:00",
"dateOfLastModification": "2025-01-10T00:00:00+00:00",
"categories": [
"Devices and Performance"
],
Expand Down
21 changes: 17 additions & 4 deletions demonstrations/ibm_pennylane.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@
#
# First, we set up our problem as usual, and then retrieve a program ID from IBM, which gives us a
# place to upload our job:
#
# .. warning::
#
# By default, this demo uses the online simulator (`ibmq_qasm_simulator`), which is free at the
# time of writing. Please note that IBM Quantum's policies may change, and simulators could become paid services.
# Always verify current pricing and access policies on the IBM Quantum platform.
#
# This demo can also run on quantum hardware by updating the backend variable accordingly. Be aware, that access
# to IBM Quantum hardware is not free and may result in substantial costs. Ensure you are aware of these costs
# and comfortable with them before proceeding.

from pennylane import numpy as pnp
from qiskit_ibm_runtime import QiskitRuntimeService
Expand All @@ -135,13 +145,16 @@
H = dataset.hamiltonian
qubits = 4

# Initialize QiskitRuntimeService
service = QiskitRuntimeService()
# Gets a 127 qubit device from IBM
backend = service.least_busy(n_qubits=127, simulator=False, operational=True)

# Use the `ibmq_qasm_simulator` available on IBM Cloud
backend = service.backend("ibmq_qasm_simulator")

try:
# Although we only need 4 qubits, our device has 127 qubits, therefore we initialize with wires=127
dev = qml.device("qiskit.remote", wires=127, backend=backend)
# Our device supports a maximum of 31 qubits
NUM_QUBITS_SUPPORTED = 31
dev = qml.device("qiskit.remote", wires=NUM_QUBITS_SUPPORTED, backend=backend)
except Exception as e:
print(e)

Expand Down
2 changes: 1 addition & 1 deletion demonstrations/learning2learn.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2021-03-02T00:00:00+00:00",
"dateOfLastModification": "2024-11-06T00:00:00+00:00",
"dateOfLastModification": "2025-01-07T00:00:00+00:00",
"categories": [
"Quantum Machine Learning"
],
Expand Down
3 changes: 3 additions & 0 deletions demonstrations/learning2learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*Author: Stefano Mangini — Posted: 02 March 2021. Last updated: 15 September 2021.*
.. warning::
This demo is only compatible with TensorFlow version ``2.9`` or below.
Otherwise, the output of some cells and plots may differ.
In this demo we recreate the architecture proposed
in *Learning to learn with quantum neural networks via
Expand Down
2 changes: 1 addition & 1 deletion demonstrations/ml_classical_shadows.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2022-05-02T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2025-01-10T00:00:00+00:00",
"categories": [
"Quantum Machine Learning"
],
Expand Down
5 changes: 2 additions & 3 deletions demonstrations/ml_classical_shadows.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ def estimate_shadow_obs(shadow, observable, k=10):
target_obs = np.array([map_name_to_int[observable.name]])
target_locs = np.array([observable.wires[0]])
else:
target_obs = np.array([map_name_to_int[o.name] for o in observable.obs])
target_locs = np.array([o.wires[0] for o in observable.obs])
target_obs = np.array([map_name_to_int[o.name] for o in observable.operands])
target_locs = np.array([o.wires[0] for o in observable.operands])

# perform median of means to return the result
means = []
Expand Down Expand Up @@ -859,4 +859,3 @@ def fit_predict_data(cij, kernel, opt="linear"):
#
# About the author
# ----------------

2 changes: 1 addition & 1 deletion demonstrations/oqc_pulse.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2023-10-30T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2025-01-14T00:00:00+00:00",
"categories": [
"Quantum Computing"
],
Expand Down
4 changes: 4 additions & 0 deletions demonstrations/oqc_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
*Author: Korbinian Kottmann — Posted: 30 October 2023.*
.. warning::
The OQC Lucy device is no longer available on Amazon Braket. As there is no alternative at this time, this
demo is now intended for educational purposes only.
Pulse-level access to quantum computers offers many interesting new avenues in
quantum optimal control, variational quantum algorithms and device-aware algorithm design.
We now have the possibility to run hardware-level circuits combined with standard gates on a
Expand Down
2 changes: 1 addition & 1 deletion demonstrations/pytorch_noise.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2019-10-11T00:00:00+00:00",
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
"dateOfLastModification": "2025-01-14T00:00:00+00:00",
"categories": [
"Devices and Performance"
],
Expand Down
6 changes: 5 additions & 1 deletion demonstrations/pytorch_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*Author: Josh Izaac — Posted: 11 October 2019. Last updated: 9 November 2022.*
.. warning::
This demo is only compatible with PennyLane v0.40 or below and Braket v1.31.0. To use Rigetti hardware with newer versions of PennyLane please use the `PennyLane-Braket plugin <https://amazon-braket-pennylane-plugin-python.readthedocs.io/en/stable/index.html>`__ instead.
Let's revisit the original :ref:`qubit rotation <qubit_rotation>` tutorial, but instead of
using the default NumPy/autograd QNode interface, we'll use the :doc:`introduction/interfaces/torch`.
We'll also replace the ``default.qubit`` device with a noisy ``rigetti.qvm``
Expand Down Expand Up @@ -251,4 +255,4 @@ def cost(phi, theta, step):
#
# About the author
# ----------------
# .. include:: ../_static/authors/josh_izaac.txt
# .. include:: ../_static/authors/josh_izaac.txt
2 changes: 1 addition & 1 deletion demonstrations/qnspsa.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2022-07-18T00:00:00+00:00",
"dateOfLastModification": "2024-11-06T00:00:00+00:00",
"dateOfLastModification": "2025-01-09T00:00:00+00:00",
"categories": [
"Optimization"
],
Expand Down
63 changes: 17 additions & 46 deletions demonstrations/qnspsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,26 +356,12 @@ def get_grad(params_curr):
# 0 (minimum overlap) and 1 (perfect overlap).
#

from copy import copy


def get_operations(qnode, params):
qnode.construct([params], {})
return qnode.tape.operations


def get_overlap_tape(qnode, params1, params2):
op_forward = get_operations(qnode, params1)
op_inv = get_operations(qnode, params2)

with qml.tape.QuantumTape() as tape:
for op in op_forward:
qml.apply(op)
for op in reversed(op_inv):
qml.adjoint(copy(op))
qml.probs(wires=qnode.tape.wires.labels)
return tape
tape_forward = qml.workflow.construct_tape(qnode)(*params1)
tape_inv = qml.workflow.construct_tape(qnode)(*params2)

ops = tape_forward.operations + list(qml.adjoint(op) for op in reversed(tape_inv.operations))
return qml.tape.QuantumTape(ops, [qml.probs(wires=tape_forward.wires)])

def get_state_overlap(tape):
return qml.execute([tape], dev, None)[0][0]
Expand Down Expand Up @@ -833,10 +819,8 @@ def __get_spsa_grad_tapes(self, cost, params):
# used to estimate the gradient per optimization step. The sampled
# direction is of the shape of the input parameter.
direction = self.__get_perturbation_direction(params)
cost.construct([params + self.finite_diff_step * direction], {})
tape_forward = cost.tape.copy(copy_operations=True)
cost.construct([params - self.finite_diff_step * direction], {})
tape_backward = cost.tape.copy(copy_operations=True)
tape_forward = qml.workflow.construct_tape(cost)(*[params + self.finite_diff_step * direction])
tape_backward = qml.workflow.construct_tape(cost)(*[params - self.finite_diff_step * direction])
return [tape_forward, tape_backward], direction

def __update_tensor(self, tensor_raw):
Expand Down Expand Up @@ -864,21 +848,7 @@ def __get_tensor_tapes(self, cost, params):
return tapes, dir_vecs

def __get_overlap_tape(self, cost, params1, params2):
op_forward = self.__get_operations(cost, params1)
op_inv = self.__get_operations(cost, params2)

with qml.tape.QuantumTape() as tape:
for op in op_forward:
qml.apply(op)
for op in reversed(op_inv):
qml.adjoint(copy(op))
qml.probs(wires=cost.tape.wires.labels)
return tape

def __get_operations(self, cost, params):
# Given a QNode, returns the list of operations before the measurement.
cost.construct([params], {})
return cost.tape.operations
return get_overlap_tape(cost, params1, params2)

def __get_tensor_moving_avg(self, metric_tensor):
# For numerical stability: averaging on the Fubini-Study metric tensor.
Expand All @@ -893,10 +863,8 @@ def __regularize_tensor(self, metric_tensor):

def __apply_blocking(self, cost, params_curr, params_next):
# For numerical stability: apply the blocking condition on the parameter update.
cost.construct([params_curr], {})
tape_loss_curr = cost.tape.copy(copy_operations=True)
cost.construct([params_next], {})
tape_loss_next = cost.tape.copy(copy_operations=True)
tape_loss_curr = qml.workflow.construct_tape(cost)(*[params_curr])
tape_loss_next = qml.workflow.construct_tape(cost)(*[params_next])

loss_curr, loss_next = qml.execute([tape_loss_curr, tape_loss_next], cost.device, None)
# self.k has been updated earlier.
Expand Down Expand Up @@ -945,11 +913,14 @@ def __apply_blocking(self, cost, params_curr, params_next):
# The optimizer performs reasonably well: the loss drops over optimization
# steps and converges finally. We then reproduce the benchmarking test
# between the gradient descent, quantum natural gradient descent, SPSA and
# QN-SPSA in Fig. 1(b) of reference [#Gacon2021]_ with the following job. You
# can find a more detailed version of the example in this
# `notebook <https://github.com/aws/amazon-braket-examples/blob/main/examples/hybrid_jobs/6_QNSPSA_optimizer_with_embedded_simulator/qnspsa_with_embedded_simulator.ipynb>`__,
# with its dependencies in the `source_scripts`
# `folder <https://github.com/aws/amazon-braket-examples/blob/main/examples/hybrid_jobs/6_QNSPSA_optimizer_with_embedded_simulator/source_scripts/>`__.
# QN-SPSA in Fig. 1(b) of reference [#Gacon2021]_ with the following job.
#
# .. warning::
# The code required to plot the results of the example below is not provided, but a similar
# example can be found in this
# `notebook <https://github.com/aws/amazon-braket-examples/blob/main/examples/hybrid_jobs/6_QNSPSA_optimizer_with_embedded_simulator/qnspsa_with_embedded_simulator.ipynb>`__,
# with all its dependencies included in the `source_scripts`
# `folder <https://github.com/aws/amazon-braket-examples/blob/main/examples/hybrid_jobs/6_QNSPSA_optimizer_with_embedded_simulator/source_scripts/>`__.
#
# .. note::
# In order for the remainder of this demo to work, you will need to have done 3 things:
Expand Down
2 changes: 1 addition & 1 deletion demonstrations/qrack.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"dateOfPublication": "2024-07-10T00:00:00+00:00",
"dateOfLastModification": "2024-11-06T00:00:00+00:00",
"dateOfLastModification": "2025-01-10T00:00:00+00:00",
"categories": [
"Devices and Performance"
],
Expand Down
Loading
Loading