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

Plugin page update #563

Merged
merged 182 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
20be42a
removed legacy ci
austingmhuang May 16, 2024
a2dade8
Delete .github/workflows/tests.yml
austingmhuang May 16, 2024
2c9ca56
Deleted use_primitives from tests
austingmhuang May 16, 2024
f25d567
remove use_primitive kwarg and things that depend on it
austingmhuang May 16, 2024
6e743f8
fix tests and split_exec
austingmhuang May 16, 2024
ca52cd0
fixed test
austingmhuang May 16, 2024
76e011e
pylint
austingmhuang May 16, 2024
cc9eb07
Merge branch 'update_reqs' into remove_use_primitives
austingmhuang May 16, 2024
de61385
change to v2 prims, del Options
austingmhuang May 16, 2024
769369e
del Options
austingmhuang May 16, 2024
0bc004b
temp changes to options
austingmhuang May 17, 2024
61b866f
naming and 0.46 test
austingmhuang May 17, 2024
78a7131
rename
austingmhuang May 17, 2024
fd87f82
update qiskit device
austingmhuang May 17, 2024
1b0d3af
dep warnings
austingmhuang May 17, 2024
7f13512
pylint
austingmhuang May 17, 2024
00337ee
Merge branch 'update_reqs' into remove_use_primitives
austingmhuang May 17, 2024
17325a2
changes to tests
austingmhuang May 21, 2024
05b346f
Merge branch 'update_reqs' into remove_use_primitives
austingmhuang May 21, 2024
e29ff38
Merge branch 'remove_use_primitives' into migrate_to_v2_primitives
austingmhuang May 21, 2024
fbf7279
deleted options for now
austingmhuang May 21, 2024
dbd0806
small changes
austingmhuang May 22, 2024
b09755d
Merge branch 'new_device_feature_branch' into remove_use_primitives
austingmhuang May 23, 2024
7dd0f21
Merge branch 'remove_use_primitives' into migrate_to_v2_primitives
austingmhuang May 23, 2024
ba3e944
access sampler results
austingmhuang May 23, 2024
2b13409
Sampler tests and functionality
austingmhuang May 23, 2024
8693f5f
estimator multi measurement works
austingmhuang May 23, 2024
46b6fe0
estimator now gives variances
austingmhuang May 23, 2024
29c4eb3
comments
austingmhuang May 23, 2024
261d7c2
removed backend.run() and _execute_runtime
austingmhuang May 23, 2024
7a40f1c
remove additional stuff
austingmhuang May 24, 2024
e41cd3d
linter
austingmhuang May 24, 2024
710bcb7
merge confs
austingmhuang May 24, 2024
b7447e2
docstring changes
austingmhuang May 24, 2024
73019a2
Merge branch 'remove_use_primitives' into migrate_to_v2_primitives
austingmhuang May 24, 2024
cfffed2
skip additional test
austingmhuang May 24, 2024
d71f440
Merge branch 'remove_use_primitives' into migrate_to_v2_primitives
austingmhuang May 24, 2024
28b4f98
[skip ci] format is correct, checks probs as well
austingmhuang May 24, 2024
c07d550
[skip ci] docstring
austingmhuang May 24, 2024
d6dd44b
docstrings
austingmhuang May 24, 2024
90d792a
Merge branch 'migrate_to_v2_primitives' into process_kwargs
austingmhuang May 24, 2024
02f9ee7
We delete the Options Handling class because there are no more Option…
austingmhuang May 24, 2024
e8f9002
changed warnings due to difference in UI for setting shots between Qi…
austingmhuang May 24, 2024
e7d2630
un did confusing change that didnt do anything
austingmhuang May 27, 2024
6441344
rerun ci
austingmhuang May 27, 2024
eaa9727
Syntax changes due to version change
austingmhuang May 27, 2024
cd3e7b2
Delete for codecov
austingmhuang May 27, 2024
b704207
Update tests/test_base_device.py
austingmhuang May 27, 2024
1f84aec
Update pennylane_qiskit/qiskit_device2.py
austingmhuang May 27, 2024
1d5370a
Update tests/test_base_device.py
austingmhuang May 27, 2024
1f2d4f9
docstrings
austingmhuang May 24, 2024
c203e48
Update tests/test_base_device.py
austingmhuang May 27, 2024
3652385
Update pennylane_qiskit/qiskit_device2.py
austingmhuang May 27, 2024
8d58148
Update tests/test_base_device.py
austingmhuang May 27, 2024
1f461d9
[skip ci] merge confs
austingmhuang May 27, 2024
026c0c7
Update tests/test_base_device.py
austingmhuang May 28, 2024
d924fa1
Update pennylane_qiskit/qiskit_device2.py
austingmhuang May 28, 2024
b15e31d
Merge branch 'remove_use_primitives' into migrate_to_v2_primitives
austingmhuang May 28, 2024
ac8833d
finishing touches
austingmhuang May 28, 2024
cd60bf9
Merge branch 'migrate_to_v2_primitives' into process_kwargs
austingmhuang May 28, 2024
8a61f34
comments
austingmhuang May 28, 2024
5bcb33a
[skip ci] formatting
austingmhuang May 28, 2024
fcb8767
[skip ci] refactor
austingmhuang May 28, 2024
089a7c9
Merge branch 'migrate_to_v2_primitives' into process_kwargs
austingmhuang May 28, 2024
729eeb2
Merge branch 'new_device_feature_branch' into migrate_to_v2_primitives
austingmhuang May 28, 2024
bd3a9b6
due to the fact that shots are not tracked in the estimator's metadat…
austingmhuang May 28, 2024
54bc21d
black
austingmhuang May 28, 2024
4fcb5e3
lint
austingmhuang May 28, 2024
f9f4f18
docstring changes
austingmhuang May 28, 2024
335c26e
backend options?
austingmhuang May 28, 2024
e8005c6
deleting unused tests
austingmhuang May 28, 2024
cc44aee
line change
austingmhuang May 28, 2024
c2ed32b
[skip ci] changed test to be more readable
austingmhuang May 29, 2024
dc90fa6
New tests for options functionality and edge case
austingmhuang May 29, 2024
cf66bf1
pylint
austingmhuang May 30, 2024
bcc1652
Merge branch 'migrate_to_v2_primitives' into process_kwargs
austingmhuang May 30, 2024
f3f1a73
We make sure that transpilation options are not passed to the primiti…
austingmhuang May 30, 2024
0e1f7fb
Due to changing the signature of get_transpile_args(), we need to fix…
austingmhuang May 30, 2024
8dadf7f
warning message for default_shots was unclear. changed to be more clear
austingmhuang May 30, 2024
78e102f
add more comments
austingmhuang May 30, 2024
d9c8dac
yay
austingmhuang May 30, 2024
d4163bb
docstring
austingmhuang May 30, 2024
7519b80
Merge branch 'migrate_to_v2_primitives' into process_kwargs
austingmhuang May 30, 2024
e58ce1c
Testing to ensure that options and kwargs combine properly
austingmhuang May 30, 2024
809e4ef
edit tests for pylint
austingmhuang May 30, 2024
b8153df
Update pennylane_qiskit/qiskit_device2.py
austingmhuang May 31, 2024
bd4c386
Update pennylane_qiskit/qiskit_device2.py
austingmhuang May 31, 2024
43fb89e
edit test regex matching due to changes earlier
austingmhuang May 31, 2024
34d1ada
refactoring of estimator and sampler
austingmhuang May 31, 2024
bb054b8
generate samples tested
austingmhuang May 31, 2024
790802b
process_estimator_job tests
austingmhuang May 31, 2024
a056911
comment for clarity
austingmhuang May 31, 2024
aa65304
merge conflicts
austingmhuang May 31, 2024
3429b40
pylint
austingmhuang May 31, 2024
1520414
pylint
austingmhuang May 31, 2024
6e9969d
Merge branch 'new_device_feature_branch' into migrate_to_v2_primitives
austingmhuang May 31, 2024
c02adbb
Merge branch 'migrate_to_v2_primitives' into process_kwargs
austingmhuang May 31, 2024
f733a27
[skip ci] minor formatting
austingmhuang Jun 4, 2024
1f71236
[skip ci] docstrings for converter functions
austingmhuang Jun 4, 2024
c863740
Fix unintended additonal dimensionality and added test for res != 1 t…
austingmhuang Jun 4, 2024
a16dcfe
fix to transpiles
austingmhuang Jun 4, 2024
b108fef
comments to explain some stuff
austingmhuang Jun 4, 2024
5e33456
Merge branch 'new_device_feature_branch' into process_kwargs
austingmhuang Jun 4, 2024
b08dd7e
merge conflicts
austingmhuang Jun 4, 2024
01bba73
[skip ci] examples of QiskitDevice2 added to docstring
austingmhuang Jun 6, 2024
7299f8c
docstring changes
austingmhuang Jun 6, 2024
e34f2ab
docstring
austingmhuang Jun 6, 2024
89f91d8
Merge branch 'process_kwargs' into docstrings_for_new_device
austingmhuang Jun 6, 2024
0c0e357
more docstrings
austingmhuang Jun 6, 2024
5e4d8dd
Update pennylane_qiskit/qiskit_device2.py
austingmhuang Jun 7, 2024
fb03ce7
Update pennylane_qiskit/qiskit_device2.py
austingmhuang Jun 7, 2024
da2fe8e
Update pennylane_qiskit/qiskit_device2.py
austingmhuang Jun 7, 2024
1ef119e
Update pennylane_qiskit/qiskit_device2.py
austingmhuang Jun 7, 2024
dbaddca
Update pennylane_qiskit/qiskit_device2.py
austingmhuang Jun 7, 2024
d66f441
clean up
austingmhuang Jun 7, 2024
6193aca
refactor
austingmhuang Jun 7, 2024
b742e3d
pylint
austingmhuang Jun 7, 2024
81d9d8f
formatting of docstring
austingmhuang Jun 7, 2024
c1d1796
Merge branch 'process_kwargs' into docstrings_for_new_device
austingmhuang Jun 7, 2024
7489724
docstrings
austingmhuang Jun 7, 2024
bfbd73a
merge confs
austingmhuang Jun 13, 2024
e0a4426
docstrings
austingmhuang Jun 14, 2024
edde1f1
formatting
austingmhuang Jun 14, 2024
6e37194
changes
austingmhuang Jun 14, 2024
bfb7935
some examples
austingmhuang Jun 17, 2024
47ec8f7
Update pennylane_qiskit/converter.py
austingmhuang Jun 19, 2024
2595523
Update pennylane_qiskit/qiskit_device2.py
austingmhuang Jun 19, 2024
f692360
Update pennylane_qiskit/qiskit_device2.py
austingmhuang Jun 19, 2024
0f497ce
examples and links
austingmhuang Jun 19, 2024
bff68b8
change inheritance for remote device
austingmhuang Jun 19, 2024
cdebc8c
build docs
austingmhuang Jun 19, 2024
d00f433
better docs
austingmhuang Jun 19, 2024
253afc6
fix docs a little
austingmhuang Jun 19, 2024
7a36402
remove redundant docstrings
austingmhuang Jun 19, 2024
c80105a
revert
austingmhuang Jun 19, 2024
c398ec6
import fix
austingmhuang Jun 19, 2024
9632755
prelim changes to aer
austingmhuang Jun 19, 2024
7cc18bb
changes to build sphinx
austingmhuang Jun 19, 2024
46f13d9
revert change
austingmhuang Jun 20, 2024
9459ecc
delete section on ibmq devices
austingmhuang Jun 20, 2024
ae127dc
add examples for remote.rst
austingmhuang Jun 20, 2024
6e5c3ac
plugin updates to the remote device and basicsim
austingmhuang Jun 20, 2024
eac4f9c
doc fixes for sphinx build
austingmhuang Jun 20, 2024
482569a
docs
austingmhuang Jun 20, 2024
34044eb
small fi
austingmhuang Jun 20, 2024
94d52ea
fix weird spacing
austingmhuang Jun 20, 2024
b938f26
[skip ci] small fix
austingmhuang Jun 20, 2024
cfab4f9
[skip ci] error in codeblock
austingmhuang Jun 20, 2024
2b628bf
delete extra the
austingmhuang Jun 20, 2024
6563111
[skip ci] changelog
austingmhuang Jun 20, 2024
c464caa
Merge branch 'new_device_feature_branch' into plugin_page_update
austingmhuang Jun 21, 2024
4e8e5b6
merge confs
austingmhuang Jun 21, 2024
2086757
formatting
austingmhuang Jun 21, 2024
c5fd9e0
black
austingmhuang Jun 21, 2024
fb56377
Update doc/devices/remote.rst
austingmhuang Jul 5, 2024
d5d9e36
Update doc/devices/remote.rst
austingmhuang Jul 8, 2024
8d7e0dd
Update doc/devices/remote.rst
austingmhuang Jul 8, 2024
e0a999e
Update doc/devices/remote.rst
austingmhuang Jul 8, 2024
b9478ce
Update doc/devices/remote.rst
austingmhuang Jul 8, 2024
8ad615c
address comments
austingmhuang Jul 8, 2024
0a11556
undo
austingmhuang Jul 8, 2024
0aca162
readme
austingmhuang Jul 9, 2024
0dd025b
Merge branch 'new_device_feature_branch' into plugin_page_update
austingmhuang Jul 9, 2024
a8bdb59
plugin page fixes
austingmhuang Jul 9, 2024
41931d7
Merge branch 'new_device_feature_branch' into plugin_page_update
austingmhuang Jul 9, 2024
4801ad7
fixed documentation
austingmhuang Jul 9, 2024
f23a6e7
fix
austingmhuang Jul 9, 2024
54ad699
Merge branch 'new_device_feature_branch' into plugin_page_update
austingmhuang Jul 9, 2024
1897b2d
fix merg conf
austingmhuang Jul 9, 2024
2f5fb18
Merge branch 'new_device_feature_branch' into plugin_page_update
austingmhuang Jul 9, 2024
3f24e63
Merge branch 'new_device_feature_branch' into plugin_page_update
austingmhuang Jul 9, 2024
f550bc7
Update doc/index.rst
austingmhuang Jul 11, 2024
5019372
doc changes
austingmhuang Jul 11, 2024
6c5c56e
typo
austingmhuang Jul 11, 2024
cf029a2
weird change didn't go through
austingmhuang Jul 11, 2024
3d67c4c
change to doc
austingmhuang Jul 11, 2024
6489976
small change
austingmhuang Jul 11, 2024
d4c69cc
Update doc/devices/remote.rst
austingmhuang Jul 11, 2024
624c764
Update doc/devices/remote.rst
austingmhuang Jul 11, 2024
2d76491
change name of iqp token
austingmhuang Jul 11, 2024
605fd94
small fix
austingmhuang Jul 11, 2024
957cee8
Merge branch 'new_device_feature_branch' into plugin_page_update
austingmhuang Jul 12, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

### Documentation 📝

* The Pennylane-Qiskit plugin page has been updated to reflect the changes in both the plugin's
capabilities and Qiskit.
[#563](https://github.com/PennyLaneAI/pennylane-qiskit/pull/563)
austingmhuang marked this conversation as resolved.
Show resolved Hide resolved

### Bug fixes 🐛

### Contributors ✍️
Expand Down
20 changes: 5 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,11 @@ To test that the PennyLane-Qiskit plugin is working correctly you can run

in the source folder.

.. note::

Tests on the `IBMQ device <https://pennylaneqiskit.readthedocs.io/en/latest/devices/ibmq.html>`_ can
only be run if a ``ibmqx_token`` for the
`IBM Q experience <https://quantum-computing.ibm.com/>`_ is
configured in the `PennyLane configuration file
<https://pennylane.readthedocs.io/en/latest/introduction/configuration.html>`_, if the token is
exported in your environment under the name ``IBMQX_TOKEN``, or if you have previously saved your
account credentials using the
`new IBMProvider <https://qiskit.org/ecosystem/ibm-provider/stubs/qiskit_ibm_provider.IBMProvider.html>`_

If this is the case, running ``make test`` also executes tests on the ``ibmq`` device.
By default, tests on the ``ibmq`` device run with ``ibmq_qasm_simulator`` backend. At
the time of writing this means that the test are "free".
Please verify that this is also the case for your account.
.. warning::
obliviateandsurrender marked this conversation as resolved.
Show resolved Hide resolved

When installing the Pennylane-Qiskit plugin, we recommend starting with a clean environment.
This is especially pertinent when upgrading from a pre-1.0 version of Qiskit, as described
in `Qiskit's migration guide <https://docs.quantum.ibm.com/api/migration-guides/qiskit-1.0-installation>`_.

.. installation-end-inclusion-marker-do-not-remove

Expand Down
43 changes: 24 additions & 19 deletions doc/devices/aer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,19 @@ parameters would look like:
qml.CNOT(wires=[0, 1])
return qml.expval(qml.PauliZ(wires=1))

You can then execute the circuit like any other function to get the quantum mechanical expectation value.
You can then execute the circuit like any other function to get the expectation value of a Pauli
operator.

.. code-block:: python

circuit(0.2, 0.1, 0.3)

Backends
~~~~~~~~
Backend Methods and Options
~~~~~~~~~~~~~~~~~~~~~~~~~~~
austingmhuang marked this conversation as resolved.
Show resolved Hide resolved

The default backend is the ``AerSimulator``. However, multiple other backends are also available.
To get a current overview what backends are available you can query

.. code-block:: python

dev.capabilities()['backend']

or, alternatively,

.. code-block:: python

from qiskit_aer import Aer
Expand All @@ -58,18 +53,28 @@ You can change a ``'qiskit.aer'`` device's backend with the ``backend`` argument

.. code-block:: python

dev = qml.device('qiskit.aer', wires=2, backend='aer_simulator_statevector')
from qiskit_aer import UnitarySimulator
dev = qml.device('qiskit.aer', wires=2, backend=UnitarySimulator())

Backend Methods and Options
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. note::

Occassionally, you may see others pass in a string as a backend. For example:

.. code-block:: python

dev = qml.device('qiskit.aer', wires=2, backend='unitary_simulator')

At the time of writing, this is still functional for the Aer devices. However, this will soon be
deprecated and may not function as intended. To ensure accurate results, we recommend passing in
a backend instance.

This ``AerSimulator`` backend has several available methods, which
The ``AerSimulator`` backend has several available methods, which
can be passed via the ``method`` keyword argument. For example
``'automatic'``, ``'statevector'``, and ``'unitary'``.

.. code-block:: python

dev = qml.device("qiskit.aer", wires=2, method="automatic")
dev = qml.device("qiskit.aer", wires=2, backend=AerSimulator(), method="automatic")

Each of these methods can take different *run options*, for example to specify the numerical
precision of the simulation.
Expand All @@ -81,7 +86,7 @@ The options are set via additional keyword arguments:
dev = qml.device(
'qiskit.aer',
wires=2,
backend='unitary_simulator',
backend=AerSimulator(),
validation_threshold=1e-6
)

Expand All @@ -96,9 +101,9 @@ documentation <https://qiskit.org/ecosystem/aer/stubs/qiskit_aer.AerSimulator.ht
Noise models
~~~~~~~~~~~~

One great feature of the ``'qiskit.aer'`` device is the ability to simulate noise. There are different noise models,
which you can instantiate and apply to the device as follows
(adapting `this <https://qiskit.org/documentation/apidoc/aer_noise.html>`_ qiskit tutorial):
Copy link
Contributor Author

@austingmhuang austingmhuang Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link is gone, also don't know what exactly to update this to instead so I removed it for now. Seems like this tutorial has either changed significantly or is just gone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this or this?

One great feature of the ``'qiskit.aer'`` device is the ability to simulate noise. There are
different noise models, which you can instantiate and apply to the device as follows (adapted
from a `Qiskit tutorial <https://qiskit.github.io/qiskit-aer/tutorials/4_custom_gate_noise.html>`_.):

.. code-block:: python

Expand Down Expand Up @@ -136,4 +141,4 @@ which you can instantiate and apply to the device as follows
print(circuit(0.2, 0.1, 0.3))

Please refer to the Qiskit documentation for more information on
`noise models <https://qiskit.org/documentation/tutorials/simulators/3_building_noise_models.html>`_.
`noise models <https://qiskit.github.io/qiskit-aer/tutorials/3_building_noise_models.html>`_.
3 changes: 1 addition & 2 deletions doc/devices/basicsim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ This device uses the Qiskit ``BasicSimulator`` backend from the

The `Qiskit Aer <https://qiskit.github.io/qiskit-aer/>`_ device
provides a fast simulator that is also capable of simulating
noise. It is available as :ref:`"qiskit.aer" <aer device page>`, but the backend must be
installed separately with ``pip install qiskit-aer``.
noise. It is available as :ref:`"qiskit.aer" <aer device page>`.
obliviateandsurrender marked this conversation as resolved.
Show resolved Hide resolved

118 changes: 109 additions & 9 deletions doc/devices/remote.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,117 @@ The Remote device
The ``'qiskit.remote'`` device is a generic adapter to use any Qiskit backend as interface
for a PennyLane device.

This device is useful when retrieving backends from providers with complex search options in
their ``get_backend()`` method, or for setting options on a backend prior to wrapping it as
PennyLane device.
To access IBM backends, we recommend using `Qiskit Runtime <https://docs.quantum.ibm.com/api/migration-guides/qiskit-runtime-from-ibm-provider>`_.

.. code-block:: python

import pennylane as qml
from qiskit_ibm_runtime import QiskitRuntimeService

def configured_backend():
backend = SomeProvider.get_backend(...)
backend.options.update_options(...)
return backend
QiskitRuntimeService.save_account(channel="ibm_quantum", token="<YOUR_IBMQ_TOKEN>")

dev = qml.device('qiskit.remote', wires=2, backend=configured_backend())
# To access saved credentials for the IBM quantum channel and select an instance
service = QiskitRuntimeService(channel="ibm_quantum", instance="my_hub/my_group/my_project")
backend = service.least_busy(operational=True, simulator=False, min_num_qubits=<num_qubits>)

dev = qml.device('qiskit.remote', wires=<num_qubits>, backend=backend)


.. note::

Certain third-party backends may be using the deprecated ``Provider`` interface, in which case
you can get the backend instance from providers with complex search options using their
``get_backend()`` method. For example:

.. code-block:: python

import pennylane as qml

def configured_backend():
backend = SomeProvider.get_backend(...)
backend.options.update_options(...) # Set backend options this way
return backend

dev = qml.device('qiskit.remote', wires=2, backend=configured_backend())

After installing the plugin, this device can be used just like any other PennyLane device for defining and evaluating QNodes.
For example, a simple quantum function that returns the expectation value of a measurement and depends on
three classical input parameters can be decorated with ``qml.qnode`` as usual to construct a ``QNode``:

.. code-block:: python

@qml.qnode(dev)
def circuit(x, y, z):
qml.RZ(z, wires=[0])
qml.RY(y, wires=[0])
qml.RX(x, wires=[0])
qml.CNOT(wires=[0, 1])
return qml.expval(qml.PauliZ(wires=1))

You can then execute the above quantum circuit to get the expectation value of a Pauli operator.

.. code-block:: python

circuit(0.2, 0.1, 0.3)

The ``'qiskit.remote'`` device also supports the use of `local simulators <https://docs.quantum.ibm.com/api/qiskit-ibm-runtime/fake_provider>`_ such as ``FakeManila``.

.. code-block:: python

from qiskit_ibm_runtime.fake_provider import FakeManilaV2
backend = FakeManilaV2()

# You could use an Aer simulator instead by using the following code:
# from qiskit_aer import AerSimulator
# backend = AerSimulator()

dev = qml.device('qiskit.remote', wires=5, backend=backend)

Device options
~~~~~~~~~~~~~~

The ``'qiskit.remote'`` device uses the `EstimatorV2 <https://docs.quantum.ibm.com/api/qiskit-ibm-runtime/qiskit_ibm_runtime.EstimatorV2/>`_
and the `SamplerV2 <https://docs.quantum.ibm.com/api/qiskit-ibm-runtime/qiskit_ibm_runtime.SamplerV2>`_ runtime primitives to execute
the measurements. To set options for `transpilation <https://docs.quantum.ibm.com/run/configure-runtime-compilation>`_
or `runtime <https://docs.quantum.ibm.com/api/qiskit-ibm-runtime/options>`_, simply pass the keyword arguments into the device.

.. code-block:: python

dev = qml.device(
"qiskit.remote",
wires=5,
backend=backend,
resilience_level=1,
optimization_level=1,
seed_transpiler=42
)
# to change options, re-initialize the device
dev = qml.device(
"qiskit.remote",
wires=5,
backend=backend,
resilience_level=1,
optimization_level=2,
seed_transpiler=24
)

This device is not compatible with analytic mode, so an error will be raised if ``shots=0`` or ``shots=None``.
The default value of the shots argument is ``1024``. You can set the number of shots on device initialization using the
``shots`` keyword, or you can choose the number of shots on circuit execution.

.. code-block:: python

dev = qml.device("qiskit.remote", wires=5, backend=backend, shots=4096)

@qml.qnode(dev)
def circuit(x, y, z):
qml.RZ(z, wires=[0])
qml.RY(y, wires=[0])
qml.RX(x, wires=[0])
qml.CNOT(wires=[0, 1])
return qml.expval(qml.PauliZ(wires=1))

# Runs with 4096 shots
circuit(0.2, 0.1, 0.3)

# Runs with 10000 shots
circuit(0.2, 0.1, 0.3, shots=10000)
38 changes: 30 additions & 8 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PennyLane-Qiskit Plugin
:end-before: header-end-inclusion-marker-do-not-remove


Once the PennyLane-Qiskit plugin is installed, the the Qiskit devices
Once the PennyLane-Qiskit plugin is installed, the Qiskit devices
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This had been bothering me for some time now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Backends" section on this page also feels outdated - it includes passing a string backend, which is only relevant for the Aer device now. It also claims that PennyLane chooses the aer_simulator as the default backend if none is specified, which is now only true for the Aer device.

can be accessed straightaway in PennyLane, without the need to import new packages.

Devices
Expand Down Expand Up @@ -48,17 +48,39 @@ For example, the ``'qiskit.aer'`` device with two wires is called like this:
Backends
~~~~~~~~

Qiskit devices have different **backends**, which define which actual simulator or hardware is used by the
device. Different simulator backends are optimized for different types of circuits. A backend can be defined as
follows:
Qiskit devices have different **backends**, which define the actual simulator or hardware
used by the device. A backend instance should be initalized and passed to the device.

Different simulator backends are optimized for different purposes. To change what backend is used,
a simulator backend can be defined as follows:

.. code-block:: python

from qiskit_aer import UnitarySimulator

dev = qml.device('qiskit.aer', wires=<num_qubits>, backend=UnitarySimulator())

.. note::

For ``'qiskit.aer'``, PennyLane chooses the ``aer_simulator`` as the default backend if no
backend is specified. For more details on the ``aer_simulator``, including available backend
options, see `Qiskit Aer Simulator documentation <https://qiskit.github.io/qiskit-aer/stubs/qiskit_aer.AerSimulator.html#qiskit_aer.AerSimulator.run>`_.

To access a real device, we can use the ``'qiskit.remote'`` device. A real hardware backend can
be defined as follows:

.. code-block:: python

dev = qml.device('qiskit.aer', wires=2, backend='unitary_simulator')
from qiskit_ibm_runtime import QiskitRuntimeService

QiskitRuntimeService.save_account(channel="ibm_quantum", token="<IQP_TOKEN>")

# To access saved credentials for the IBM quantum channel and select an instance
service = QiskitRuntimeService(channel="ibm_quantum", instance="my_hub/my_group/my_project")
backend = service.least_busy(operational=True, simulator=False, min_num_qubits=<num_qubits>)

PennyLane chooses the ``aer_simulator`` as the default backend if no backend is specified.
For more details on the ``aer_simulator``, including available backend options, see
`Qiskit Aer Simulator documentation <https://qiskit.github.io/qiskit-aer/stubs/qiskit_aer.AerSimulator.html#qiskit_aer.AerSimulator.run>`_.
# passing a string in backend would result in an error
dev = qml.device('qiskit.remote', wires=<num_qubits>, backend=backend)

Tutorials
~~~~~~~~~
Expand Down
Loading