Skip to content

Commit

Permalink
Merge pull request #31 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 authored Nov 1, 2022
2 parents 6d11b2b + 04eea95 commit 50af3ac
Show file tree
Hide file tree
Showing 19 changed files with 187 additions and 6,807 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-alec
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"
1 change: 0 additions & 1 deletion .github/workflows/build-test
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ set -evu
# - mypy: include mypy check ("mypy" or "nomypy")
#
# Environment variables used:
# - MODULE: single module to test
# - GITHUB_WORKSPACE: workspace directory
#
# WARNING: running this locally will delete any local files that
Expand Down
33 changes: 19 additions & 14 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,53 @@ on:
types:
- created
- edited
schedule:
# 04:00 every Tuesday morning
- cron: '0 4 * * 2'

env:
PYTKET_REMOTE_IQM_AUTH_SERVER_URL: ${{ secrets.PYTKET_REMOTE_IQM_AUTH_SERVER_URL }}
PYTKET_REMOTE_IQM_USERNAME: ${{ secrets.PYTKET_REMOTE_IQM_USERNAME }}
PYTKET_REMOTE_IQM_APIKEY: ${{ secrets.PYTKET_REMOTE_IQM_APIKEY }}
PYTKET_REMOTE_IQM_PASSWORD: ${{ secrets.PYTKET_REMOTE_IQM_APIKEY }}

jobs:
iqm-checks:
name: IQM - 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.9
if: github.event_name == 'pull_request' || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel') || github.event_name == 'push'
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') || github.event_name == 'push')
if: (matrix.os == 'macos-12') && (github.event_name == 'pull_request' || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel') || github.event_name == 'schedule')
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') || github.event_name == 'push')
if: (matrix.os != 'macos-12') && (github.event_name == 'pull_request' || 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
- uses: actions/upload-artifact@v3
Expand All @@ -63,11 +68,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 @@ -76,7 +81,7 @@ jobs:
name: Publish to pypi
if: github.event_name == 'release'
needs: iqm-checks
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Download all wheels
uses: actions/download-artifact@v3
Expand All @@ -97,13 +102,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
9 changes: 4 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ 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
Binary file removed .github/workflows/docs/CQCLogo.png
Binary file not shown.
Binary file added .github/workflows/docs/Quantinuum_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions .github/workflows/docs/build-docs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ MODULES_DIR = DOCS_DIR.parent.parent.parent
PYTKET_DOCS_LINK = "https://cqcl.github.io/tket/pytket/api/index.html"
PYTKET_EX_DOCS_LINK = "https://cqcl.github.io/pytket-extensions/api/index.html"
MODULE = "iqm"
PYTKET_IQM_PYPI_LINK = "https://pypi.org/project/pytket-iqm/"
PYTKET_IQM_GITHUB = "https://github.com/CQCL/pytket-iqm"

def get_module_version():
m = import_module(f"pytket.extensions.{MODULE}")
Expand All @@ -37,9 +39,9 @@ def build_module_docs():
mod_docs = MODULES_DIR / "docs"
mod_build = mod_docs / "build"
conf_copy = mod_docs / "conf.py"
logo_copy = mod_docs / "CQCLogo.png"
logo_copy = mod_docs / "Quantinuum_logo.png"
shutil.copy(DOCS_DIR / "conf.py", conf_copy)
shutil.copy(DOCS_DIR / "CQCLogo.png", logo_copy)
shutil.copy(DOCS_DIR / "Quantinuum_logo.png", logo_copy)
remove_dir(mod_build)
index_rst = mod_docs / "index.rst"
with open(mod_docs / "intro.txt", "r") as f:
Expand All @@ -49,6 +51,13 @@ def build_module_docs():
)
content.append(f"\tpytket <{PYTKET_DOCS_LINK}>\n")
content.append(f"\tpytket extensions <{PYTKET_EX_DOCS_LINK}>\n")
content.append(
"\n.. toctree::\n\t:caption: Links:\n\t:maxdepth: 1\n\n"
)
content.append(f"\tbug tracker <{PYTKET_IQM_GITHUB}/issues>\n")
content.append(f"\tGitHub <{PYTKET_IQM_GITHUB}>\n")
content.append(f"\tPyPi <{PYTKET_IQM_PYPI_LINK}>\n")


with open(index_rst, "w") as f:
f.writelines(content)
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-iqm] ${{ 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-iqm] ${{ 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
92 changes: 71 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,71 @@
# Pytket Extensions

This repository contains the pytket-iqm extension, using CQC's
[pytket](https://cqcl.github.io/tket/pytket/api/index.html) quantum SDK.
The other pytket extensions can be found [here](https://github.com/CQCL/pytket-extensions)


# pytket-iqm

[Pytket](https://cqcl.github.io/tket/pytket/api/index.html) is a python module providing an
extensive set of tools for compiling and executing quantum circuits.
[Pytket](https://cqcl.github.io/tket/pytket/api/index.html) is a python module
providing an extensive set of tools for compiling and executing quantum circuits.

`pytket-iqm` is an extension to `pytket` that allows `pytket` circuits to be
executed on [IQM](https://meetiqm.com/)'s quantum devices and simulators.

## Getting started

`pytket-iqm` is available for Python 3.8, 3.9 and 3.10, on Linux, MacOS
`pytket-iqm` is available for Python 3.8, 3.9 and 3.10, on Linux, macOS
and Windows. To install, run:

```pip install pytket-iqm```
```shell
pip install pytket-iqm
```

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

API documentation is available
[here](https://cqcl.github.io/pytket-iqm/api/index.html).

Under the hood, `pytket-iqm` uses `iqm-client` to interact with the devices. See
the IQM Client [documentation](https://iqm-finland.github.io/iqm-client/) and
Pytket [documentation](https://cqcl.github.io/tket/pytket/api/) for more info.

To use the integration, initialise an `IQMBackend`, construct a Pytket circuit,
compile it and run. Here is a small example of running a GHZ state circuit:

```python
from pytket.extensions.iqm import IQMBackend
from pytket.circuit import Circuit

backend = IQMBackend(
url="https://cortex-demo.qc.iqm.fi",
auth_server_url="https://auth.demo.qc.iqm.fi",
username="USERNAME",
password="PASSWORD",
)

circuit = Circuit(3, 3)
circuit.H(0)
circuit.CX(0, 1)
circuit.CX(0, 2)
circuit.measure_all()
circuit = backend.get_compiled_circuit(circuit)

result = backend.run_circuit(c, n_shots=100)
print(result.get_shots())
```

The IQM Client documentation includes the [set of currently supported
instructions]
(https://iqm-finland.github.io/iqm-client/api/iqm_client.iqm_client.html).
`pytket-iqm` retrieves the set from the IQM backend during the initialisation;
then `get_compiled_circuit()` takes care of compiling the circuit into the
form suitable to run on the backend.

During the backend initialisation, `pytket-iqm` also retrieves the names of
physical qubits and qubit connectivity. You can override the qubit connectivity
by providing the `arch` parameter to the `IQMBackend` constructor, but it generally
does not make sense, since the IQM server reports the valid quantum architecture
relevant to the given backend URL.

## Bugs and feature requests

Please file bugs and feature requests on the Github
Please file bugs and feature requests on the GitHub
[issue tracker](https://github.com/CQCL/pytket-iqm/issues).

## Development
Expand All @@ -49,7 +89,7 @@ tests and is accepted after review, it will be merged in.

All code should be formatted using
[black](https://black.readthedocs.io/en/stable/), with default options. This is
checked on the CI. The CI is currently using version 20.8b1.
checked on the CI.

#### Type annotation

Expand All @@ -64,18 +104,28 @@ script requires `mypy` 0.800 or above.
#### Linting

We use [pylint](https://pypi.org/project/pylint/) on the CI to check compliance
with a set of style requirements (listed in `modules/.pylintrc`). You should run
`pylint` over any changed files from the `modules` directory before submitting a
PR, to catch any issues.
with a set of style requirements (listed in `.pylintrc`). You should run
`pylint` over any changed files before submitting a PR, to catch any issues.

### Tests

To run the tests for a module:
To run the tests:

```shell
cd tests
pip install -r test-requirements.txt
pytest
```

By default, the remote tests, which run against the real backend server, are
skipped. To enable them, set the following environment variables:

1. `cd` into that module's `tests` directory;
2. ensure you have installed `pytest`, `hypothesis`, and any modules listed in
the `test-requirements.txt` file (all via `pip`);
3. run `pytest`.
```shell
export PYTKET_RUN_REMOTE_TESTS=1
export PYTKET_REMOTE_IQM_AUTH_SERVER_URL=https://auth.demo.qc.iqm.fi
export PYTKET_REMOTE_IQM_USERNAME=YOUR_USERNAME
export PYTKET_REMOTE_IQM_PASSWORD=YOUR_PASSWORD
```

When adding a new feature, please add a test for it. When fixing a bug, please
add a test that demonstrates the fix.
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.4.0"
__extension_version__ = "0.5.0"
__extension_name__ = "pytket-iqm"
11 changes: 11 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Changelog
~~~~~~~~~

0.5.0 (November 2022)
---------------------

* Updated iqm-client version requirement to 9.1.
* IQMBackend initializer now does not accept a settings file.
* IQMBackend initializer now retrieves device name and qubit names from backend
server instead of configuration file.
* IQMBackend initializer now retrieves qubit coupling (connectivity) and native
gateset from backend server instead of hard-coded constants.
* Updated pytket version requirement to 1.8.

0.4.0 (August 2022)
-------------------

Expand Down
Loading

0 comments on commit 50af3ac

Please sign in to comment.