Skip to content

Commit

Permalink
Merge pull request #159 from CQCL/release/1-16-0
Browse files Browse the repository at this point in the history
Release/1 16 0
  • Loading branch information
cqc-melf authored Jun 20, 2023
2 parents b1b1ed3 + a4c1fdc commit 191f523
Show file tree
Hide file tree
Showing 24 changed files with 692 additions and 266 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/build-test
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ set -evu

# Usage:
#
# build-test [mypy|nomypy]
# build-test [mypy|nomypy] {integration}
#
# Arguments:
# - mypy: include mypy check ("mypy" or "nomypy")
# - integration (optional): run integration tests too
# (unit tests are always run)
#
# Environment variables used:
# - GITHUB_WORKSPACE: workspace directory
Expand All @@ -18,6 +20,12 @@ MODULE=pytket-quantinuum

MYPY=$1

INTEGRATION=''
if [[ $# -gt 1 ]]
then
INTEGRATION=$2
fi

PLAT=`python -c 'import platform; print(platform.system())'`

PYVER=`python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))'`
Expand Down Expand Up @@ -54,7 +62,13 @@ python -m pip install --pre -r test-requirements.txt
# update the pytket version to the lastest (pre) release
python -m pip install --upgrade --pre pytket~=1.0

pytest --doctest-modules
pytest --doctest-modules unit/

# integration tests are run if specified
if [[ ! -z "${INTEGRATION}" ]]
then
pytest --doctest-modules integration/
fi

cd ..

Expand Down
94 changes: 88 additions & 6 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- develop
push:
branches:
- main
- develop
- 'wheel/**'
- 'runci/**'
Expand All @@ -17,6 +18,13 @@ on:
schedule:
# 04:00 every Tuesday morning
- cron: '0 4 * * 2'
workflow_dispatch:
inputs:
run-integration-tests:
description: "Please type 'yes' to run also the integration tests (default 'no')."
required: true
default: "no"


env:
PYTKET_REMOTE_QUANTINUUM_USERNAME: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_USERNAME }}
Expand Down Expand Up @@ -48,27 +56,101 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build and test including remote checks (3.10) mypy
- name: Build and test (3.10) mypy
shell: bash
if: (matrix.os == 'macos-12') && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'release' || github.event_name == 'schedule' )
if: |
matrix.os == 'macos-12' &&
(
github.event_name == 'push' ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
) ||
github.event_name == 'release' ||
(
github.event_name == 'workflow_dispatch' &&
github.event.inputs.run-integration-tests == 'no'
)
)
run: |
./.github/workflows/build-test mypy
- name: Build and test including integration (3.10) mypy
shell: bash
if: |
matrix.os == 'macos-12' &&
(
(
github.event_name == 'push' &&
(
contains(github.ref_name, 'main') ||
contains(github.ref_name, 'runci/')
)
) ||
github.event_name == 'schedule' ||
(
github.event_name == 'workflow_dispatch' &&
github.event.inputs.run-integration-tests == 'yes'
)
)
run: |
./.github/workflows/build-test mypy integration
env:
PYTKET_RUN_REMOTE_TESTS: 1
- name: Build and test including remote checks (3.10) nomypy
if: (matrix.os != 'macos-12') && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'release' || github.event_name == 'schedule')
- name: Build and test (3.10) nomypy
if: |
matrix.os != 'macos-12' &&
(
github.event_name == 'push' ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
) ||
github.event_name == 'release' ||
(
github.event_name == 'workflow_dispatch' &&
github.event.inputs.run-integration-tests == 'no'
)
)
shell: bash
run: |
./.github/workflows/build-test nomypy
- name: Build and test including integration (3.10) nomypy
if: |
matrix.os != 'macos-12' &&
(
(
github.event_name == 'push' &&
(
contains(github.ref_name, 'main') ||
contains(github.ref_name, 'runci/')
)
) ||
github.event_name == 'schedule' ||
(
github.event_name == 'workflow_dispatch' &&
github.event.inputs.run-integration-tests == 'yes'
)
)
shell: bash
run: |
./.github/workflows/build-test nomypy integration
env:
PYTKET_RUN_REMOTE_TESTS: 1
- name: Set up Python 3.11
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'schedule'
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' ||
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch'
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Build and test (3.11)
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'schedule'
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' ||
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch'
shell: bash
run: |
./.github/workflows/build-test nomypy
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/check-examples.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Check example notebooks

on:
push:
branches:
- main
pull_request:
branches:
- main
Expand All @@ -27,15 +30,19 @@ jobs:
base: ${{ github.ref }}
filters: |
examples:
- 'setup.py'
- 'pytket/**'
- 'examples/**'
- '.github/workflows/check-examples.yml'
check:
name: Check notebooks
needs: changes
if: github.event_name == 'schedule' || needs.changes.outputs.examples == 'true'
if: |
github.event_name == 'schedule' ||
github.event_name == 'push' ||
(
github.event_name == 'pull_request' &&
needs.changes.outputs.examples == 'true'
)
runs-on: ubuntu-22.04
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs/build-docs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def build_module_docs():
"-D",
f"project=pytket-{MODULE}",
"-D",
f"copyright={datetime.date.today().year} Cambridge Quantum Computing",
f"copyright={datetime.date.today().year} Quantinuum",
"-D",
f"version={'.'.join(v[:2])}",
"-D",
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Configuration file for the Sphinx documentation builder.
# See https://www.sphinx-doc.org/en/master/usage/configuration.html

author = "Cambridge Quantum Computing Ltd"
copyright = "2023 Quantinuum"
author = "Quantinuum"

extensions = [
"sphinx.ext.autodoc",
Expand All @@ -13,8 +14,6 @@
"sphinx_copybutton",
]

pygments_style = "borland"

html_theme = "sphinx_book_theme"

html_theme_options = {
Expand Down Expand Up @@ -116,7 +115,6 @@ def correct_signature(
signature: str,
return_annotation: str,
) -> (str, str):

new_signature = signature
new_return_annotation = return_annotation
for k, v in app.config.custom_internal_mapping.items():
Expand Down
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.16.0"
__extension_version__ = "0.17.0"
__extension_name__ = "pytket-quantinuum"
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ API documentation

.. automodule:: pytket.extensions.quantinuum
:special-members:
:members: QuantinuumBackend, QuantinuumAPI, QuantinuumAPIOffline
:members: QuantinuumBackend, QuantinuumAPI, QuantinuumAPIOffline, Language

.. automodule:: pytket.extensions.quantinuum.backends.config
:members:
16 changes: 16 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
Changelog
~~~~~~~~~

0.17.0 (June 2023)
------------------

* Add ``Language`` enum to control language used for circuit submission, with
values ``Language.QASM`` and ``Language.QIR``.
* Renamed ``QuantinuumBackend.submit_qasm()`` to
``QuantinuumBackend.submit_program()``, with a ``language`` argument.
* Add a ``language`` kwarg to ``QuantinuumBackend.process_circuits()``,
defaulting to ``Language.QASM``. (Support for ``Language.QIR`` is
experimental and its use is not recommended; a warning will be emitted. You
must install the ``pytket-qir`` package separately in order to use this
feature.)
* Use "q" instead of "node" as the name of the single qubit register in compiled
circuits.
* Updated pytket version requirement to 1.16.

0.16.0 (May 2023)
-----------------

Expand Down
28 changes: 28 additions & 0 deletions docs/intro.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,34 @@ For the Quantinuum ``Backend``, ``process_circuits`` returns a ``ResultHandle``

The ``logout()`` method clears stored JSON web tokens and the user will have to sign in again to access the Quantinuum API.

Partial Results Retrieval
-------------------------

The :py:class:`QuantinuumBackend` also supports giving the user partial results from unfinished jobs.
This can be done as follows.

::

from pytket.extensions.quantinuum import QuantinuumBackend

# Submit circuit to QuantinuumBackend
backend = QuantinuumBackend('H1-1')
compiled_circ = backend.get_compiled_circuit(circ) # circ defined elsewhere
handle = backend.process_circuit(compiled_circ, n_shots=3000)

# Retrieve partial shots:counts from the handle of an unfinished job
partial_result, job_status = backend.get_partial_result(handle)
print(partial_result.get_counts())


This feature has a number of potential use cases.

Firstly partial results can be used to diagnose potential faults with submitted jobs.
For instance if the partial results look worse than expected this could indicate a bug in the submitted circuit(s). If this is the case the user may want to cancel the job to avoid using machine time and resubmit once the issue is resolved.
If partial results indicate that a job is taking longer run than anticipated then the user can cancel the job and consider redesigning their experiment.

Also partial results enable users to quickly validate basic execution for very large jobs which may take days to complete.

Batching
--------
Quantinuum backends (except syntax checkers) support batching of jobs (circuits). To create
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/quantinuum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

# _metadata.py is copied to the folder after installation.
from ._metadata import __extension_version__, __extension_name__ # type: ignore
from .backends import QuantinuumBackend, QuantinuumAPI, QuantinuumAPIOffline
from .backends import QuantinuumBackend, QuantinuumAPI, QuantinuumAPIOffline, Language
2 changes: 1 addition & 1 deletion pytket/extensions/quantinuum/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"""Backends for processing pytket circuits with Quantinuum devices
"""

from .quantinuum import QuantinuumBackend
from .quantinuum import QuantinuumBackend, Language
from .api_wrappers import QuantinuumAPI, QuantinuumAPIOffline
Loading

0 comments on commit 191f523

Please sign in to comment.