Skip to content

Commit

Permalink
Merge pull request #289 from CQCL/release/0.49.0
Browse files Browse the repository at this point in the history
release 0.49.0
  • Loading branch information
cqc-melf authored Mar 13, 2024
2 parents f488dc9 + 366ce0e commit 3f3b95c
Show file tree
Hide file tree
Showing 19 changed files with 540 additions and 230 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4.0.3
uses: actions/deploy-pages@v4.0.4
2 changes: 1 addition & 1 deletion _metadata.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__extension_version__ = "0.48.1rc1"
__extension_version__ = "0.49.0"
__extension_name__ = "pytket-qiskit"
8 changes: 5 additions & 3 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ API documentation
:show-inheritance:
:members:

.. autoclass:: pytket.extensions.qiskit.AerBackend
.. autoclass:: pytket.extensions.qiskit.IBMQLocalEmulatorBackend
:special-members: __init__
:show-inheritance:
:members:

.. autoclass:: pytket.extensions.qiskit.AerBackend
:special-members: __init__
:inherited-members:
:members:

.. autoclass:: pytket.extensions.qiskit.AerStateBackend
:special-members: __init__
:inherited-members:
:show-inheritance:
:members:

.. autoclass:: pytket.extensions.qiskit.AerUnitaryBackend
:special-members: __init__
:show-inheritance:
:inherited-members:
:members:

Expand Down
10 changes: 10 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
~~~~~~~~~

0.49.0 (March 2024)
-------------------

* Update pytket version requirement to 1.25.
* Update qiskit version requirement to 1.0.
* Update qiskit-ibm-provider version requirement to 0.10.
* Update qiskit-ibm-runtime version requirement to 0.21.
* Add ``IBMQLocalEmulatorBackend`` for running local emulation of
``IBMQBackend`` using ``AerBackend`` with a noise model.

0.48.1rc1
---------

Expand Down
156 changes: 99 additions & 57 deletions docs/intro.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pytket-qiskit
==================================
#############

IBM's `Qiskit <https://qiskit.org>`_ is an open-source framework for quantum
IBM's `Qiskit <https://www.ibm.com/quantum/qiskit>`_ is an open-source framework for quantum
computation, ranging from high-level algorithms to low-level circuit
representations, simulation and access to the `IBMQ <https://www.research.ibm.com/ibm-q/>`_ Experience devices.

Expand All @@ -19,6 +19,22 @@ Windows. To install, run:
This will install ``pytket`` if it isn't already installed, and add new classes
and methods into the ``pytket.extensions`` namespace.

Available IBM Backends
======================

.. currentmodule:: pytket.extensions.qiskit

.. autosummary::
:nosignatures:

IBMQBackend
IBMQEmulatorBackend
IBMQLocalEmulatorBackend
AerBackend
AerStateBackend
AerUnitaryBackend


An example using the shots-based :py:class:`AerBackend` simulator is shown below.

::
Expand Down Expand Up @@ -65,28 +81,11 @@ In this section we are assuming that you have set the following variables with t
group = '<your_group_here>'
project = '<your_project_here>'

.. note:: The documentation below is correct as of pytket-qiskit version 0.40.0 and newer. In the 0.40.0 release pytket-qiskit moved to using the `qiskit-ibm-provider <https://qiskit.org/ecosystem/ibm-provider/tutorials/Migration_Guide_from_qiskit-ibmq-provider.html>`_. In pytket-qiskit versions 0.39.0 and older the parameters ``hub``, ``group`` and ``project`` were handled separately instead of a single ``instance`` string as in 0.40.0 and newer.

::

from pytket.extensions.qiskit import set_ibmq_config

set_ibmq_config(ibmq_api_token=ibm_token)

After saving your credentials you can access ``pytket-qiskit`` backend repeatedly without having to re-initialise your credentials.

If you are a member of an IBM hub then you can add this information to ``set_ibmq_config`` as well.

::

from pytket.extensions.qiskit import set_ibmq_config

set_ibmq_config(ibmq_api_token=ibm_token, instance=f"{hub}/{group}/{project}")

Alternatively you can use the following qiskit commands to save your credentials
locally without saving the token in pytket config:
Method 1: Using :py:class:`IBMProvider`
---------------------------------------

.. note:: If using pytket-qiskit 0.39.0 or older you will have to use the deprecated :py:meth:`IBMQ.save_account` instead of :py:meth:`IBMProvider.save_account` in the code below.
You can use the following qiskit commands to save your IBM credentials
to disk:

::

Expand All @@ -106,42 +105,62 @@ To see which devices you can access you can use the ``available_devices`` method
my_instance=f"{hub}/{group}/{project}"
ibm_provider = IBMProvider(instance=my_instance)
backend = IBMQBackend("ibmq_nairobi") # Initialise backend for an IBM device

backendinfo_list = backend.available_devices(instance=my_instance, provider=ibm_provider)
print([backend.device_name for backend in backendinfo_list])


Backends Available Through pytket-qiskit
========================================

The ``pytket-qiskit`` extension has several types of available :py:class:`Backend`. These are the :py:class:`IBMQBackend`
and several types of simulator.
Method 2: Saving credentials in a local pytket config file
----------------------------------------------------------
Alternatively, you can store your credentials in local pytket config using the :py:meth:`set_ibmq_config` method.

.. list-table::
:widths: 25 25
:header-rows: 1
::

from pytket.extensions.qiskit import set_ibmq_config

set_ibmq_config(ibmq_api_token=ibm_token)

After saving your credentials you can access ``pytket-qiskit`` backend repeatedly without having to re-initialise your credentials.

If you are a member of an IBM hub then you can add this information to ``set_ibmq_config`` as well.

::

from pytket.extensions.qiskit import set_ibmq_config

set_ibmq_config(ibmq_api_token=ibm_token, instance=f"{hub}/{group}/{project}")

.. currentmodule:: pytket.extensions.qiskit.backends.config

.. autosummary::
:nosignatures:

QiskitConfig
set_ibmq_config

Converting circuits between pytket and qiskit
=============================================

Users may wish to port quantum circuits between pytket and qiskit. This allows the features of both libraries to be used.
For instance those familiar with qiskit may wish to convert their circuits to pytket and use the available compilation passes to optimise circuits.

.. currentmodule:: pytket.extensions.qiskit


.. autosummary::
:nosignatures:

qiskit_to_tk
tk_to_qiskit

* - Backend
- Type
* - `IBMQBackend <https://tket.quantinuum.com/extensions/pytket-qiskit/api/api.html#pytket.extensions.qiskit.IBMQBackend>`_
- Interface to an IBM quantum computer.
* - `IBMQEmulatorBackend <https://tket.quantinuum.com/extensions/pytket-qiskit/api/api.html#pytket.extensions.qiskit.IBMQEmulatorBackend>`_
- Emulator for a chosen ``IBMBackend`` (Device specific).
* - `AerBackend <https://tket.quantinuum.com/extensions/pytket-qiskit/api/api.html#pytket.extensions.qiskit.AerBackend>`_
- A noiseless, shots-based simulator for quantum circuits [1]
* - `AerStateBackend <https://tket.quantinuum.com/extensions/pytket-qiskit/api/api.html#pytket.extensions.qiskit.AerStateBackend>`_
- Statevector simulator.
* - `AerUnitaryBackend <https://tket.quantinuum.com/extensions/pytket-qiskit/api/api.html#pytket.extensions.qiskit.AerUnitaryBackend>`_
- Unitary simulator

* [1] :py:class:`AerBackend` is noiseless by default and has no architecture. However it can accept a user defined :py:class:`NoiseModel` and :py:class:`Architecture`.
* In addition to the backends above the ``pytket-qiskit`` extension also has the :py:class:`TketBackend`. This allows a tket :py:class:`Backend` to be used directly through qiskit. see the `notebook example <https://github.com/CQCL/pytket/blob/main/examples/qiskit_integration.ipynb>`_ on qiskit integration.

Default Compilation
===================

Every :py:class:`Backend` in pytket has its own ``default_compilation_pass`` method. This method applies a sequence of optimisations to a circuit depending on the value of an ``optimisation_level`` parameter. This default compilation will ensure that the circuit meets all the constraints required to run on the :py:class:`Backend`. The passes applied by different levels of optimisation are specified in the table below.

.. list-table:: **Default compilation pass for the IBMQBackend and IBMQEmulatorBackend**
.. list-table:: **Default compilation pass for the IBMQBackend, IBMQEmulatorBackend and IBMQLocalEmulatorBackend**
:widths: 25 25 25
:header-rows: 1

Expand Down Expand Up @@ -177,28 +196,51 @@ Every :py:class:`Backend` in pytket has its own ``default_compilation_pass`` met
- `RemoveRedundancies <https://tket.quantinuum.com/api-docs/passes.html#pytket.passes.RemoveRedundancies>`_

* [1] If no value is specified then ``optimisation_level`` defaults to a value of 2.
* [2] self.rebase_pass is a rebase to the gateset supported by the backend, For IBM quantum devices that is {X, SX, Rz, CX}.
* [2] self.rebase_pass is a rebase to the gateset supported by the backend. For IBM quantum devices and emulators that is either {X, SX, Rz, CX} or {X, SX, Rz, ECR}. The more idealised Aer simulators have a much broader range of supported gates.
* [3] Here :py:class:`CXMappingPass` maps program qubits to the architecture using a `NoiseAwarePlacement <https://tket.quantinuum.com/api-docs/placement.html#pytket.placement.NoiseAwarePlacement>`_


**Note:** The ``default_compilation_pass`` for :py:class:`AerBackend` is the same as above.


Backend Predicates
==================
Noise Modelling
===============

.. currentmodule:: pytket.extensions.qiskit.backends.crosstalk_model

.. autosummary::
:nosignatures:

CrosstalkParams


Using TKET directly on qiskit circuits
======================================

For usage of :py:class:`TketBackend` see the `qiskit integration notebook example <https://tket.quantinuum.com/examples/qiskit_integration.html>`_.

.. currentmodule:: pytket.extensions.qiskit.tket_backend

.. autosummary::
:nosignatures:

TketBackend

.. currentmodule:: pytket.extensions.qiskit.tket_pass

.. autosummary::
:nosignatures:

Circuits must satisfy certain conditions before they can be processed on a device or simulator. In pytket these conditions are called predicates.
TketPass
TketAutoPass

All ``pytket-qiskit`` backends have the following two predicates.
.. currentmodule:: pytket.extensions.qiskit.tket_job

* `GateSetPredicate <https://tket.quantinuum.com/api-docs/predicates.html#pytket.predicates.GateSetPredicate>`_ - The circuit must contain only operations supported by the :py:class`Backend`. To view supported Ops run ``BACKENDNAME.backend_info.gate_set``.
* `NoSymbolsPredicate <https://tket.quantinuum.com/api-docs/predicates.html#pytket.predicates.NoSymbolsPredicate>`_ - Parameterised gates must have numerical values when the circuit is executed.
.. autosummary::
:nosignatures:

The :py:class:`IBMQBackend` and :py:class:`IBMQEmulatorBackend` may also have the following predicates depending on the capabilities of the specified device.
TketJob

* `NoClassicalControlPredicate <https://tket.quantinuum.com/api-docs/predicates.html#pytket.predicates.NoClassicalControlPredicate>`_
* `NoMidMeasurePredicate <https://tket.quantinuum.com/api-docs/predicates.html#pytket.predicates.NoMidMeasurePredicatePredicate>`_
* `NoFastFeedforwardPredicate <https://tket.quantinuum.com/api-docs/predicates.html#pytket.predicates.NoFastFeedforwardPredicate>`_

.. toctree::
api.rst
Expand Down
1 change: 1 addition & 0 deletions pytket/extensions/qiskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
AerStateBackend,
AerUnitaryBackend,
IBMQEmulatorBackend,
IBMQLocalEmulatorBackend,
)
from .backends.config import set_ibmq_config
from .qiskit_convert import qiskit_to_tk, tk_to_qiskit, process_characterisation
Expand Down
1 change: 1 addition & 0 deletions pytket/extensions/qiskit/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
from .ibm import IBMQBackend, NoIBMQCredentialsError
from .aer import AerBackend, AerStateBackend, AerUnitaryBackend
from .ibmq_emulator import IBMQEmulatorBackend
from .ibmq_local_emulator import IBMQLocalEmulatorBackend
Loading

0 comments on commit 3f3b95c

Please sign in to comment.