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

Update Rigetti demos #1042

Merged
merged 6 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 12 additions & 12 deletions demonstrations/ensemble_multi_qpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
# /interfaces.html>`_, which can be installed from `here
# <https://pytorch.org/get-started/locally/>`__.
#
# .. warning::
# Rigetti's QVM and Quil Compiler services must be running for this tutorial to execute. They
# can be installed by consulting the `Rigetti documentation
# <http://docs.rigetti.com/qcs/>`__ or, for users with Docker, by running:
#
# .. code-block:: bash
#
# docker run -d -p 5555:5555 rigetti/quilc -R -p 5555
# docker run -d -p 5000:5000 rigetti/qvm -S -p 5000
#
# Load data
# ---------
#
Expand Down Expand Up @@ -186,15 +196,6 @@ def plot_points(x_train, y_train, x_test, y_test):
# swap ``qiskit.aer`` for ``qiskit.ibmq`` and specify their chosen backend (see `here
# <https://docs.pennylane.ai/projects/qiskit/en/latest/devices/ibmq.html>`__).
#
# .. warning::
# Rigetti's QVM and Quil Compiler services must be running for this tutorial to execute. They
# can be installed by consulting the `Rigetti documentation
# <http://docs.rigetti.com/qcs/>`__ or, for users with Docker, by running:
#
# .. code-block:: bash
#
# docker run -d -p 5555:5555 rigetti/quilc -R -p 5555
# docker run -d -p 5000:5000 rigetti/qvm -S -p 5000
#
# The circuits for both QPUs are shown in the figure below:
#
Expand Down Expand Up @@ -259,9 +260,8 @@ def decision(softmax):

def predict_point(params, x_point=None, parallel=True):
if parallel:
results = tuple(dask.delayed(q)(params, x=x_point) for q in qnodes)
results = dask.compute(*results, scheduler="threads")
results = torch.tensor(torch.vstack(results))
results = tuple(dask.delayed(q)(params, x=torch.from_numpy(x_point)) for q in qnodes)
results = torch.tensor(dask.compute(*results, scheduler="threads"))
else:
results = tuple(q(params, x=x_point) for q in qnodes)
results = torch.tensor(results)
Expand Down
13 changes: 10 additions & 3 deletions demonstrations/pytorch_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@
To follow along with this tutorial on your own computer, you will require the
following dependencies:

* The `Rigetti SDK <https://qcs.rigetti.com/sdk-downloads>`_, which contains the quantum virtual
* Rigetti's QVM and Quil Compiler services. One option for setting this up is the
`Rigetti SDK <https://qcs.rigetti.com/sdk-downloads>`_, which contains the quantum virtual
machine (QVM) and quilc quantum compiler. Once installed, the QVM and quilc can be
started by running the commands ``quilc -S`` and ``qvm -S`` in separate terminal windows.
Alternatively, for users with Docker, the QVM and Quil Compiler services can be run with commands:

.. code-block:: bash

docker run -d -p 5555:5555 rigetti/quilc -R -p 5555
docker run -d -p 5000:5000 rigetti/qvm -S -p 5000

* `PennyLane-Rigetti plugin <https://docs.pennylane.ai/projects/rigetti/en/latest/>`_, in order
to access the QVM as a PennyLane device. This can be installed via pip:
Expand Down Expand Up @@ -198,7 +205,7 @@ def cost(phi, theta, step):
my_prefix = "Your-Folder-Name" # the name of the folder in the bucket
s3_folder = (my_bucket, my_prefix)

device_arn = "arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-2"
device_arn = "arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-3"

qpu = qml.device(
"braket.aws.qubit",
Expand All @@ -208,7 +215,7 @@ def cost(phi, theta, step):
)

# Note: swap dev to qpu here to use the QPU
# Warning: check the pricing of Aspen-M-2 on Braket to make
# Warning: check the pricing of Aspen-M-3 on Braket to make
# sure you are aware of the costs associated with running the
# optimization below.
@qml.qnode(dev, interface="torch")
Expand Down
Loading