Skip to content

Commit

Permalink
Merge pull request #16 from CQCL/release/1.8.0
Browse files Browse the repository at this point in the history
Release/1.8.0
  • Loading branch information
cqc-melf committed Nov 2, 2022
2 parents 5534620 + ae43455 commit 1c572c3
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 35 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @cqc-melf
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
35 changes: 19 additions & 16 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
types:
- created
- edited
schedule:
# 04:00 every Tuesday morning
- cron: '0 4 * * 2'

env:
PYTKET_REMOTE_QISKIT_TOKEN: ${{ secrets.PYTKET_REMOTE_QISKIT_TOKEN }}
Expand All @@ -22,49 +25,49 @@ jobs:
name: Qiskit - Build and test module
strategy:
matrix:
os: ['ubuntu-20.04', 'macos-11', 'windows-2019']
os: ['ubuntu-22.04', 'macos-12', 'windows-2022']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* +refs/heads/*:refs/remotes/origin/*
- name: Set up Python 3.8
if: github.event_name == 'push'
uses: actions/setup-python@v3
if: github.event_name == 'push' || github.event_name == 'schedule'
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Build and test (3.8)
if: github.event_name == 'push'
if: github.event_name == 'push' || github.event_name == 'schedule'
shell: bash
run: |
./.github/workflows/build-test nomypy
- name: Set up Python 3.9
if: github.event_name == 'pull_request' || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel')
uses: actions/setup-python@v3
if: github.event_name == 'pull_request' || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel') || github.event_name == 'schedule'
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Build and test including remote checks (3.9) mypy
if: (matrix.os == 'macos-11') && ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel'))
if: (matrix.os == 'macos-12') && ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel') || github.event_name == 'schedule' )
shell: bash
run: |
./.github/workflows/build-test mypy
env:
PYTKET_RUN_REMOTE_TESTS: 1
- name: Build and test including remote checks (3.9) nomypy
if: (matrix.os != 'macos-11') && ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel'))
if: (matrix.os != 'macos-12') && ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel') || github.event_name == 'schedule' )
shell: bash
run: |
./.github/workflows/build-test nomypy
env:
PYTKET_RUN_REMOTE_TESTS: 1
- name: Set up Python 3.10
if: github.event_name == 'push' || github.event_name == 'pull_request'
uses: actions/setup-python@v3
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'schedule'
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build and test (3.10)
if: github.event_name == 'push' || github.event_name == 'pull_request'
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'schedule'
shell: bash
run: |
./.github/workflows/build-test nomypy
Expand All @@ -74,11 +77,11 @@ jobs:
name: artefacts
path: wheelhouse/
- name: Install docs dependencies
if: (matrix.os == 'ubuntu-20.04') && (github.event_name == 'pull_request')
if: (matrix.os == 'ubuntu-22.04') && (github.event_name == 'pull_request' || github.event_name == 'schedule' )
run: |
pip install -r .github/workflows/docs/requirements.txt
- name: Build docs
if: (matrix.os == 'ubuntu-20.04') && (github.event_name == 'pull_request')
if: (matrix.os == 'ubuntu-22.04') && (github.event_name == 'pull_request' || github.event_name == 'schedule' )
timeout-minutes: 20
run: |
./.github/workflows/docs/check-build-docs
Expand All @@ -88,7 +91,7 @@ jobs:
name: Publish to pypi
if: github.event_name == 'release'
needs: qiskit-checks
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Download all wheels
uses: actions/download-artifact@v3
Expand All @@ -109,13 +112,13 @@ jobs:
name: Build and publish docs
if: github.event_name == 'release'
needs: publish_to_pypi
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Set up Python 3.9
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Download all wheels
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ on:
branches:
- 'docs/**'
schedule:
# 04:00 every weekday morning
- cron: '0 4 * * 1-5'
# 04:00 every Tuesday morning
- cron: '0 4 * * 2'

jobs:
docs:
name: build docs
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Upgrade pip and install wheel
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
jira_task:
name: Create Jira issue
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Login
uses: atlassian/gajira-login@v2.0.0
Expand All @@ -21,13 +21,13 @@ jobs:
with:
project: TKET
issuetype: Bug
summary: «${{ github.event.issue.title }}»
summary: « [pytket-qiskit] ${{ github.event.issue.title }}»
description: ${{ github.event.issue.html_url }}
- name: Create Task
uses: atlassian/gajira-create@v2.0.1
if: "! contains(github.event.issue.labels.*.name, 'bug')"
with:
project: TKET
issuetype: Task
summary: «${{ github.event.issue.title }}»
summary: « [pytket-qiskit] ${{ github.event.issue.title }}»
description: ${{ github.event.issue.html_url }}
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ on:
jobs:
lint:

runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Update pip
Expand Down
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.29.0"
__extension_version__ = "0.30.0"
__extension_name__ = "pytket-qiskit"
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
~~~~~~~~~

0.30.0 (November 2022)
----------------------

* Update qiskit version to 0.39.
* ``tk_to_qiskit`` now performs a rebase pass prior to conversion. Previously an error was returned if a ``Circuit`` contained gates such as ``OpType.ZZMax`` which have no exact replacement in qiskit. Now the unsupported gate will be implemented in terms of gates supported in qiskit rather than returning an error.
* Updated pytket version requirement to 1.8.

0.29.0 (October 2022)
---------------------

Expand Down
134 changes: 132 additions & 2 deletions docs/intro.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,138 @@ representations.
Windows. To install, run:

::

pip install pytket-qiskit

pip install pytket-qiskit

This will install `pytket` if it isn't already installed, and add new classes
and methods into the `pytket.extensions` namespace.

Access and Credentials
======================

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.

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

::

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.

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

To see which devices you can access you can use the ``available_devices`` method on the ``IBMQBackend`` or ``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.

::

from pytket.extensions.qiskit import IBMQBackend

backend = IBMQBackend # Initialise backend for an IBM device
backend.available_devices(hub='your hub', group='your group', project='your project')


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

The ``pytket-qiskit`` extension has several types of available ``Backend``. These are the ``IBMQBackend``
and several types of simulator.

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

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

* [1] ``AerBackend`` is noiseless by default and has no architecture. However it can accept a user defined ``NoiseModel`` and ``Architecture``.
* In addition to the backends above the pytket-qiskit extension also has the ``TketBackend``. This allows a tket ``Backend``s and compilation passes 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 ``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 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**
:widths: 25 25 25
:header-rows: 1

* - optimisation_level = 0
- optimisation_level = 1 [1]
- optimisation_level = 2
* - `DecomposeBoxes <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.DecomposeBoxes>`_
- `DecomposeBoxes <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.DecomposeBoxes>`_
- `DecomposeBoxes <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.DecomposeBoxes>`_
* - self.rebase_pass [2]
- `SynthesiseTket <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.SynthesiseTket>`_
- `FullPeepholeOptimise <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.FullPeepholeOptimise>`_
* - `CXMappingPass <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.CXMappingPass>`_ [3]
- `CXMappingPass <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.CXMappingPass>`_ [3]
- `CXMappingPass <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.CXMappingPass>`_ [3]
* - `NaivePlacementPass <https://cqcl.github.io/tket/pytket/api/placement.html#pytket.passes.NaivePlacementPass>`_
- `NaivePlacementPass <https://cqcl.github.io/tket/pytket/api/placement.html#pytket.passes.NaivePlacementPass>`_
- `NaivePlacementPass <https://cqcl.github.io/tket/pytket/api/placement.html#pytket.passes.NaivePlacementPass>`_
* - self.rebase_pass [2]
- `SynthesiseTket <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.SynthesiseTket>`_
- `KAKDecomposition(allow_swaps=False) <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.KAKDecomposition>`_
* - `RemoveRedundancies <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.RemoveRedundancies>`_
- `RemoveRedundancies <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.RemoveRedundancies>`_
- `CliffordSimp(allow_swaps=False) <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.CliffordSimp>`_
* -
- self.rebase_pass [2]
- `SynthesiseTket <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.SynthesiseTket>`_
* -
- `SimplifyInitial <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.SimplifyInitial>`_ [4]
- self.rebase_pass [2]
* -
-
- `RemoveRedundancies <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.RemoveRedundancies>`_
* -
-
- `SimplifyInitial <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.SimplifyInitial>`_ [4]

* [1] If no value is specified then ``optimisation_level`` defaults to a value of 1.
* [2] self.rebase_pass is a rebase to the gateset supported by the backend, For IBM quantum devices that is {X, SX, Rz, CX}.
* [3] Here ``CXMappingPass`` maps program qubits to the architecture using a `NoiseAwarePlacement <https://cqcl.github.io/tket/pytket/api/placement.html#pytket.placement.NoiseAwarePlacement>`_
* [4] ``SimplifyInitial`` has arguments ``allow_classical=False`` and ``create_all_qubits=True``.


**Note:** The ``default_compilation_pass`` for ``AerBackend`` is the same as above except it doesn't use ``SimplifyInitial``.


Backend Predicates
==================

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

All pytket-qiskit backends have the following two predicates.

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

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

* `NoClassicalControlPredicate <https://cqcl.github.io/tket/pytket/api/predicates.html#pytket.predicates.NoClassicalControlPredicate>`_
* `NoMidMeasurePredicate <https://cqcl.github.io/tket/pytket/api/predicates.html#pytket.predicates.NoMidMeasurePredicatePredicate>`_
* `NoFastFeedforwardPredicate <https://cqcl.github.io/tket/pytket/api/predicates.html#pytket.predicates.NoFastFeedforwardPredicate>`_

.. toctree::
api.rst
Expand Down
6 changes: 5 additions & 1 deletion pytket/extensions/qiskit/backends/ibm.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def _get_backend_info(cls, backend: "_QiskIBMQBackend") -> BackendInfo:
k: v for k, v in characterisation.items() if k in characterisation_keys
}
supports_mid_measure = config.simulator or config.multi_meas_enabled
supports_fast_feedforward = supports_mid_measure
supports_fast_feedforward = False
# simulator i.e. "ibmq_qasm_simulator" does not have `supported_instructions`
# attribute
gate_set = _tk_gate_set(backend)
Expand Down Expand Up @@ -322,6 +322,10 @@ def required_predicates(self) -> List[Predicate]:
def default_compilation_pass(self, optimisation_level: int = 1) -> BasePass:
assert optimisation_level in range(3)
passlist = [DecomposeBoxes()]
# If you make changes to the default_compilation_pass,
# then please update this page accordingly
# https://cqcl.github.io/pytket-qiskit/api/index.html#default-compilation
# Edit this docs source file -> pytket-qiskit/docs/intro.txt
if optimisation_level == 0:
if self._standard_gateset:
passlist.append(self.rebase_pass())
Expand Down
Loading

0 comments on commit 1c572c3

Please sign in to comment.