Skip to content

Commit

Permalink
Merge pull request #128 from CQCL/release/0.40.0
Browse files Browse the repository at this point in the history
Release/0.40.0
  • Loading branch information
cqc-melf authored Jun 22, 2023
2 parents 12ca6d7 + bcdb062 commit 5c03735
Show file tree
Hide file tree
Showing 18 changed files with 500 additions and 212 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/docs/intro.txt

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx ~= 4.3.2
sphinx >= 4.3.2, <6.2.0
sphinx_book_theme >= 1.0.1, <2.0
sphinx-copybutton
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.39.0"
__extension_version__ = "0.40.0"
__extension_name__ = "pytket-qiskit"
16 changes: 15 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
Changelog
~~~~~~~~~

0.40.0 (June 2023)
------------------

* IBM devices are now accessed using the `qiskit-ibm-provider <https://github.com/Qiskit/qiskit-ibm-provider>`_ instead of the deprecated :py:class:`IBMQ`. This allows the newest IBM devices and simulators to be accessed through ``pytket-qiskit``. See the updated documentation on `credentials <https://cqcl.github.io/pytket-qiskit/api/index.html#access-and-credentials>`_.
* The parameters ``hub``, ``group`` and ``project`` are no longer handled as separate arguments in :py:class:`IBMQBackend` and :py:meth:`IBMQBackend.available_devices`. Use ``"instance=f"{hub}/{group}/{project}"`` instead.
* Added support for the {X, SX, Rz, ECR} in the default compilation pass for :py:class:`IBMQBackend` and :py:class:`IBMQEmulatorBackend`. This is the set of gates used by some of the new IBM devices.
* Fix to the :py:meth:`tk_to_qiskit` converter to prevent cancellation of redundant gates when converting to qiskit.
* Handle qiskit circuits with :py:class:`Initialize` and :py:class:`StatePreparation` instructions in the :py:meth:`qiskit_to_tk` converter. The :py:meth:`tk_to_qiskit` converter now handles :py:class:`StatePreparationBox`.
* Fix handling of control state in :py:meth:`qiskit_to_tk`.
* Update qiskit version to 0.43.1
* Update qiskit-ibm-runtime version to 0.11.1
* Update qiskit-ibm-provider version to 0.6.1
* Update pytket version to 1.16

0.39.0 (May 2023)
-----------------

* Updated pytket version requirement to 1.15.
* The get_compiled_circuit method now allows for optional arguments to override the default settings in the NoiseAwarePlacement
* The :py:meth:`IBMQBackend.get_compiled_circuit` method now allows for optional arguments to override the default settings in the :py:class:`NoiseAwarePlacement`.

0.38.0 (April 2023)
-------------------
Expand Down
24 changes: 16 additions & 8 deletions docs/intro.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,53 @@ The :py:class:`AerBackend` also supports GPU simulation which can be configured
Access and Credentials
======================

With the exception of the Aer simulators, accessing devices and simulators through the ``pytket-qiskit`` extension requires an IBMQ account. An account can be set up here: https://quantum-computing.ibm.com/login.
With the exception of the Aer simulators, accessing devices and simulators through the ``pytket-qiskit`` extension requires an IBM account. An account can be set up here: https://quantum-computing.ibm.com/login.

Once you have created an account you can obtain an API token which you can use to configure your credentials locally.

.. note:: The documentation below is correct as of pytket-qiskit version 0.40.0. 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)

This will save your IBMQ credentials locally. After saving your credentials you can access ``pytket-qiskit`` backend repeatedly without having to re-initialise your credentials.
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, hub='your hub', group='your group', project='your project')
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:

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

::

from qiskit import IBMQ
from qiskit_ibm_provider import IBMProvider
from qiskit_ibm_runtime import QiskitRuntimeService

IBMQ.save_account(token=ibm_token)
IBMProvider.save_account(token=ibm_token)
QiskitRuntimeService.save_account(channel="ibm_quantum", token=ibm_token)

To see which devices you can access you can use the ``available_devices`` method on the :py:class:`IBMQBackend` or :py:class:`IBMQEmulatorBackend`. Note that it is possible to pass ``hub``, ``group`` and ``project`` parameters to this method. This allows you to see which devices are accessible through your IBM hub.
To see which devices you can access you can use the ``available_devices`` method on the :py:class:`IBMQBackend` or :py:class:`IBMQEmulatorBackend`. Note that it is possible to pass optional ``instance`` and ``provider`` arguments to this method. This allows you to see which devices are accessible through your IBM hub.

::

from pytket.extensions.qiskit import IBMQBackend
from qiskit_ibm_provider import IBMProvider

backend = IBMQBackend # Initialise backend for an IBM device
backend.available_devices(hub='your hub', group='your group', project='your project')
my_instance=f"{hub}/{group}/{project}"
ibm_provider = IBMProvider(instance=my_instance)
backend = IBMQBackend("ibmq_belem") # 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
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ._metadata import __extension_version__, __extension_name__ # type: ignore
from .backends import (
IBMQBackend,
NoIBMQAccountError,
NoIBMQCredentialsError,
AerBackend,
AerStateBackend,
AerUnitaryBackend,
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
# limitations under the License.
"""Backends for connecting to IBM devices and simulators directly from pytket"""

from .ibm import IBMQBackend, NoIBMQAccountError
from .ibm import IBMQBackend, NoIBMQCredentialsError
from .aer import AerBackend, AerStateBackend, AerUnitaryBackend
from .ibmq_emulator import IBMQEmulatorBackend
20 changes: 5 additions & 15 deletions pytket/extensions/qiskit/backends/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,29 @@ class QiskitConfig(PytketExtConfig):

ext_dict_key: ClassVar[str] = "qiskit"

hub: Optional[str]
group: Optional[str]
project: Optional[str]
instance: Optional[str]
ibmq_api_token: Optional[str]

@classmethod
def from_extension_dict(
cls: Type["QiskitConfig"], ext_dict: Dict[str, Any]
) -> "QiskitConfig":
return cls(
ext_dict.get("hub", None),
ext_dict.get("group", None),
ext_dict.get("project", None),
ext_dict.get("instance", None),
ext_dict.get("ibmq_api_token", None),
)


def set_ibmq_config(
hub: Optional[str] = None,
group: Optional[str] = None,
project: Optional[str] = None,
instance: Optional[str] = None,
ibmq_api_token: Optional[str] = None,
) -> None:
"""Set default values for any of hub, group, project or API token
for your IBMQ provider. Can be overridden in backend construction."""

config = QiskitConfig.from_default_config_file()
if hub is not None:
config.hub = hub
if group is not None:
config.group = group
if project is not None:
config.project = project
if instance is not None:
config.instance = instance
if ibmq_api_token is not None:
config.ibmq_api_token = ibmq_api_token
config.update_default_config_file()
Loading

0 comments on commit 5c03735

Please sign in to comment.