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

[WIP] New Qiskit device prototype #513

Merged
merged 59 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
852783a
New Qiskit device prototype (#350)
lillian542 Apr 18, 2024
c83f8c8
Add compile_backend kwarg (#398)
lillian542 Apr 22, 2024
496d12a
Merge branch 'master' into new_device_feature_branch
austingmhuang Apr 22, 2024
41c73b0
Support both V1 and V2 (#399)
lillian542 Apr 22, 2024
0ba56a9
Scalar tests passing
austingmhuang Apr 23, 2024
a1ff606
Change mp_to_pauli to be more general
austingmhuang Apr 23, 2024
17c3e67
Hamiltonian testing
austingmhuang Apr 23, 2024
4f21e7d
tests
austingmhuang Apr 24, 2024
54c7483
Revert "tests"
austingmhuang Apr 24, 2024
160b14c
Revert "Hamiltonian testing"
austingmhuang Apr 24, 2024
4386d44
Revert "Change mp_to_pauli to be more general"
austingmhuang Apr 24, 2024
f71c1d4
revert
austingmhuang Apr 24, 2024
214cc32
Install PL dev intead of PL stable on CI (#516) (#518)
austingmhuang Apr 25, 2024
1593150
Delete ds store
austingmhuang Apr 25, 2024
bd4c2eb
Merge branch 'master' into new_device_feature_branch
austingmhuang Apr 25, 2024
5fe6092
import change
austingmhuang Apr 25, 2024
f0c6dc9
black
austingmhuang Apr 25, 2024
00b30f2
merge master
austingmhuang Apr 30, 2024
1b85a3a
some changes
austingmhuang Apr 30, 2024
d21adf8
linters
austingmhuang Apr 30, 2024
009aa76
black
austingmhuang Apr 30, 2024
0943af7
pylinting
austingmhuang Apr 30, 2024
98a3017
black
austingmhuang Apr 30, 2024
cbc23a3
small change
austingmhuang May 1, 2024
b25dda3
change conftest
austingmhuang May 1, 2024
64e0a4e
black linter
austingmhuang May 1, 2024
f47e285
fix
austingmhuang May 1, 2024
8d40745
Merge branch 'master' into new_device_feature_branch
austingmhuang May 1, 2024
6c37e6c
Generalize mp_to_pauli so that it can work with any observable that h…
austingmhuang May 1, 2024
fc1f98d
Merge branch 'master' into new_device_feature_branch
austingmhuang May 2, 2024
3c5dec3
Use old _execute_runtime_service for observables that are not compati…
austingmhuang May 7, 2024
f78851a
Move off of "ibmq_qasm_simulator" and towards using AerSimulator for …
austingmhuang May 10, 2024
5e11e3a
Merge branch 'master' into new_device_feature_branch
austingmhuang May 10, 2024
ae898be
Update reqs to 1.0 (#536)
austingmhuang May 22, 2024
9027131
Remove basicaer (#546)
austingmhuang May 23, 2024
83c9483
Remove use primitives and everything that depends on it (#538)
austingmhuang May 28, 2024
9e5df68
Remove ibmq devices (#550)
austingmhuang May 31, 2024
343e984
Migrate to v2 primitives (#539)
austingmhuang Jun 4, 2024
257bd93
merge conflicts
austingmhuang Jun 12, 2024
f1a2e18
Merge branch 'master' into new_device_feature_branch
austingmhuang Jun 13, 2024
db31979
pylint
austingmhuang Jun 13, 2024
f734b93
Process kwargs (#547)
austingmhuang Jun 13, 2024
6442fee
Docstrings for converter functions and new qiskit device (#552)
austingmhuang Jun 20, 2024
2bf4130
Diagonalize gates (#558)
austingmhuang Jun 21, 2024
74129f3
Merge branch 'master' into new_device_feature_branch
austingmhuang Jul 2, 2024
bd7a3cb
Qiskit session (#551)
austingmhuang Jul 5, 2024
b239c66
Tests with fakehardware (#553)
austingmhuang Jul 8, 2024
6f1bb7d
merge confs
austingmhuang Jul 9, 2024
ee26a16
Merge branch 'master' into new_device_feature_branch
austingmhuang Jul 9, 2024
d9baa67
Merge branch 'master' into new_device_feature_branch
austingmhuang Jul 9, 2024
ec6968b
fix merge conf
austingmhuang Jul 9, 2024
30f675c
fix setup.py
austingmhuang Jul 9, 2024
3d1ba4e
reqs.txt
austingmhuang Jul 9, 2024
19586e3
changelog changes
austingmhuang Jul 9, 2024
b6c3989
Use new qiskit device as the base for remote (#566)
austingmhuang Jul 12, 2024
23533e0
Plugin page update (#563)
austingmhuang Jul 12, 2024
e9e30de
Tracker functionality (#533)
austingmhuang Jul 15, 2024
a97f79c
Update CHANGELOG.md
austingmhuang Jul 24, 2024
984c7a5
CHANGELOG
austingmhuang Jul 24, 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
6 changes: 3 additions & 3 deletions .github/workflows/ibmq_tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: IBMQ integration tests
name: IBMQ integration tests with Qiskit 1.0
on:
schedule:
- cron: '0 0 * * 0,4' # At 00:00 on Sunday and Thursday.
- cron: '1 0 * * 0,4' # At 01:00 on Sunday and Thursday.
workflow_dispatch:

jobs:
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-ci-legacy.txt
pip install -r requirements-ci.txt
pip install wheel pytest pytest-cov pytest-mock flaky --upgrade
pip freeze

Expand Down
44 changes: 0 additions & 44 deletions .github/workflows/ibmq_tests_1.yml

This file was deleted.

17 changes: 6 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: Tests for 1.0
on:
push:
branches:
Expand Down Expand Up @@ -30,7 +30,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install git+https://github.com/PennyLaneAI/pennylane.git
pip install -r requirements-ci-legacy.txt
pip install -r requirements-ci.txt
pip install wheel pytest pytest-cov pytest-mock flaky --upgrade
pip freeze

Expand All @@ -39,12 +39,9 @@ jobs:
pip install git+https://github.com/PennyLaneAI/pennylane-qiskit.git@${{ github.ref }}
pip freeze

- name: Run tests
# Skip IBMQ and Runtime tests as they depend on IBMQ's availability and
# easily result in timeouts
- name: Run standard Qiskit plugin tests
# Run the standard tests with the most recent version of Qiskit
run: python -m pytest tests -k 'not test_ibmq.py and not test_runtime.py' --cov=pennylane_qiskit --cov-report=term-missing --cov-report=xml -p no:warnings --tb=native
env:
IBMQX_TOKEN: ${{ secrets.IBMQX_TOKEN_TEST }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down Expand Up @@ -72,19 +69,17 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install git+https://github.com/PennyLaneAI/pennylane.git
pip install -r requirements-ci-legacy.txt
pip install -r requirements-ci.txt
pip install wheel pytest pytest-cov pytest-mock pytest-benchmark flaky --upgrade
pip freeze

- name: Install Plugin
run: |
python setup.py bdist_wheel
pip install dist/PennyLane*.whl
pip freeze

- name: Run tests
run: |
pl-device-test --device=qiskit.basicaer --tb=short --skip-ops --shots=20000 --device-kwargs backend=qasm_simulator
pl-device-test --device=qiskit.basicsim --tb=short --skip-ops --shots=20000 --device-kwargs backend=basic_simulator
pl-device-test --device=qiskit.aer --tb=short --skip-ops --shots=20000 --device-kwargs backend=qasm_simulator
pl-device-test --device=qiskit.aer --tb=short --skip-ops --shots=None --device-kwargs backend=statevector_simulator
pl-device-test --device=qiskit.aer --tb=short --skip-ops --shots=None --device-kwargs backend=unitary_simulator
Expand Down
91 changes: 0 additions & 91 deletions .github/workflows/tests_qiskit_1.yml

This file was deleted.

29 changes: 28 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,40 @@

### New features since last release

* Qiskit Sessions can now be used for the ``qiskit.remote`` device with the ``qiskit_session`` context
manager.
[(#551)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/551)

### Improvements 🛠

* Qiskit Runtime Primitives are supported by the ``qiskit.remote`` device. Circuits ran using the ``qiskit.remote``
device will automatically call the SamplerV2 and EstimatorV2 primitives appropriately. Additionally, runtime options can be passed as keyword arguments directly to the ``qiskit.remote`` device.
[(#513)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/513)

### Breaking changes 💔
austingmhuang marked this conversation as resolved.
Show resolved Hide resolved

* Support has been removed for Qiskit versions below 0.46. The minimum required version for Qiskit is now 1.0.
If you want to continue to use older versions of Qiskit with the plugin, please use version 0.36 of
the Pennylane-Qiskit plugin.
[(#536)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/536)

* The test suite no longer runs for Qiskit versions below 0.46.
[(#536)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/536)

* The ``qiskit.basicaer`` device has been removed because it is not supported for versions of Qiskit above 0.46.
[(#546)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/546)

* The IBM quantum devices, ``qiskit.ibmq``, ``qiskit.ibmq.circuit_runner`` and ``qiskit.ibmq.sampler``, have been removed due to deprecations of the IBMProvider and the cloud simulator "ibmq_qasm_simulator".
[(#550)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/550)
austingmhuang marked this conversation as resolved.
Show resolved Hide resolved

### Deprecations 👋

### 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)

### Bug fixes 🐛

### Contributors ✍️
Expand All @@ -30,8 +56,9 @@ This release contains contributions from (in alphabetical order):
### Contributors ✍️

This release contains contributions from (in alphabetical order):

Utkarsh Azad
Lillian M. A. Frederiksen
Austin Huang
Mashhood Khan

---
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::

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
~~~~~~~~~~~~~~~~~~~~~~~~~~~

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):
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>`_.
Loading
Loading