Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.48.0 #246

Merged
merged 7 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,38 +33,38 @@ jobs:
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
- name: Set up Python 3.10
if: github.event_name == 'push' || github.event_name == 'schedule'
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Build and test (3.9)
python-version: '3.10'
- name: Build and test (3.10)
if: github.event_name == 'push' || github.event_name == 'schedule'
shell: bash
run: |
./.github/workflows/build-test nomypy
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build and test including remote checks (3.10) mypy
python-version: '3.11'
- name: Build and test including remote checks (3.11) mypy
if: (matrix.os == 'ubuntu-22.04') && (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' )
shell: bash
run: |
./.github/workflows/build-test mypy
env:
PYTKET_RUN_REMOTE_TESTS: 1
- name: Build and test (3.10) nomypy
- name: Build and test (3.11) 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')
shell: bash
run: |
./.github/workflows/build-test nomypy
- name: Set up Python 3.11
- name: Set up Python 3.12
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'schedule'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build and test (3.11)
python-version: '3.12'
- name: Build and test (3.12)
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'schedule'
shell: bash
run: |
Expand Down Expand Up @@ -119,10 +119,10 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.11'
- name: Download all wheels
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -159,4 +159,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/[email protected].1
uses: actions/[email protected].3
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.11'
- name: Upgrade pip and install wheel
run: pip install --upgrade pip wheel
- name: Install pytket qiskit
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Configuration file for the Sphinx documentation builder.
# See https://www.sphinx-doc.org/en/master/usage/configuration.html

copyright = "2023 Quantinuum"
copyright = "2024 Quantinuum"
author = "Quantinuum"

extensions = [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ representations.

## Getting started

`pytket-qiskit` is available for Python 3.9, 3.10 and 3.11, on Linux, MacOS
`pytket-qiskit` is available for Python 3.10, 3.11 and 3.12, on Linux, MacOS
and Windows. To install, run:

```shell
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.47.0"
__extension_version__ = "0.48.0"
__extension_name__ = "pytket-qiskit"
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
~~~~~~~~~

0.48.0 (January 2024)
---------------------

* Updated pytket version requirement to 1.24.
* Python 3.12 support added, 3.9 dropped.
* fix conditional bit in pytket to qiskit conversion
* fix symbolic conversion of parameter in conversion

0.47.0 (January 2024)
---------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/intro.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ representations, simulation and access to the `IBMQ <https://www.research.ibm.co
run on IBM backends and simulators, as well as conversion to and from Qiskit
representations.

``pytket-qiskit`` is available for Python 3.9, 3.10 and 3.11, on Linux, MacOS and
``pytket-qiskit`` is available for Python 3.10, 3.11 and 3.12, on Linux, MacOS and
Windows. To install, run:

::
Expand Down
2 changes: 1 addition & 1 deletion ecosystem.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"language": {
"name": "python",
"versions": ["3.9"]
"versions": ["3.10"]
},
"tests_command": [
"/bin/bash -ec 'cd tests && pytest'"
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
python_version = 3.9
python_version = 3.10
warn_unused_configs = True

disallow_untyped_decorators = False
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 Cambridge Quantum Computing
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 Cambridge Quantum Computing
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/aer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 Cambridge Quantum Computing
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/crosstalk_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 Cambridge Quantum Computing
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/ibm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 Cambridge Quantum Computing
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/ibmq_emulator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 Cambridge Quantum Computing
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
57 changes: 40 additions & 17 deletions pytket/extensions/qiskit/qiskit_convert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 Cambridge Quantum Computing
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -52,6 +52,7 @@
Parameter,
ParameterExpression,
Reset,
Clbit,
)
from qiskit.circuit.library import (
CRYGate,
Expand Down Expand Up @@ -342,11 +343,23 @@ def add_qiskit_data(self, data: "QuantumCircuitData") -> None:
for instr, qargs, cargs in data:
condition_kwargs = {}
if instr.condition is not None:
cond_reg = self.cregmap[instr.condition[0]]
condition_kwargs = {
"condition_bits": [cond_reg[k] for k in range(len(cond_reg))],
"condition_value": instr.condition[1],
}
if type(instr.condition[0]) == ClassicalRegister:
cond_reg = self.cregmap[instr.condition[0]]
condition_kwargs = {
"condition_bits": [cond_reg[k] for k in range(len(cond_reg))],
"condition_value": instr.condition[1],
}
elif type(instr.condition[0]) == Clbit:
cond_reg = self.cregmap[instr.condition[0].register]
condition_kwargs = {
"condition_bits": [cond_reg[instr.condition[0].index]],
"condition_value": instr.condition[1],
}
else:
raise NotImplementedError(
"condition must contain classical bit or register"
)

# Controlled operations may be controlled on values other than all-1. Handle
# this by prepending and appending X gates on the control qubits.
ctrl_state, num_ctrl_qubits = None, None
Expand Down Expand Up @@ -653,22 +666,29 @@ def append_tk_command_to_qiskit(
width = op.width # type: ignore
value = op.value # type: ignore
regname = args[0].reg_name
if len(cregmap[regname]) != width:
raise NotImplementedError("OpenQASM conditions must be an entire register")
for i, a in enumerate(args[:width]):
if a.reg_name != regname:
raise NotImplementedError(
"OpenQASM conditions can only use a single register"
)
if a.index != [i]:
raise NotImplementedError(
"OpenQASM conditions must be an entire register in order"
)
raise NotImplementedError("Conditions can only use a single register")
instruction = append_tk_command_to_qiskit(
op.op, args[width:], qcirc, qregmap, cregmap, symb_map, range_preds # type: ignore
)
if len(cregmap[regname]) == width:
for i, a in enumerate(args[:width]):
if a.index != [i]:
raise NotImplementedError(
"""Conditions must be an entire register in\
order or only one bit of one register"""
)

instruction.c_if(cregmap[regname], value)
elif width == 1:
instruction.c_if(cregmap[regname][args[0].index[0]], value)
else:
raise NotImplementedError(
"""Conditions must be an entire register in\
order or only one bit of one register"""
)

instruction.c_if(cregmap[regname], value)
return instruction
# normal gates
qargs = [qregmap[q.reg_name][q.index[0]] for q in args]
Expand Down Expand Up @@ -719,7 +739,10 @@ def append_tk_command_to_qiskit(
) from error
params = _get_params(op, symb_map)
g = gatetype(*params)
qcirc.global_phase += phase * sympy.pi
if type(phase) == float:
qcirc.global_phase += phase * np.pi
else:
qcirc.global_phase += phase * sympy.pi
return qcirc.append(g, qargs=qargs)


Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/result_convert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 Cambridge Quantum Computing
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/tket_backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Cambridge Quantum Computing
# Copyright 2020-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/tket_job.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Cambridge Quantum Computing
# Copyright 2020-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/tket_pass.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 Cambridge Quantum Computing
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Cambridge Quantum Computing
# Copyright 2020-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,7 @@
version=metadata["__extension_version__"],
author="TKET development team",
author_email="[email protected]",
python_requires=">=3.9",
python_requires=">=3.10",
project_urls={
"Documentation": "https://tket.quantinuum.com/extensions/pytket-qiskit/index.html",
"Source": "https://github.com/CQCL/pytket-qiskit",
Expand All @@ -44,7 +44,7 @@
packages=find_namespace_packages(include=["pytket.*"]),
include_package_data=True,
install_requires=[
"pytket ~= 1.23",
"pytket ~= 1.24",
"qiskit ~= 0.45.0",
"qiskit-algorithms ~= 0.2.1",
"qiskit-ibm-runtime ~= 0.17.0",
Expand All @@ -54,9 +54,9 @@
],
classifiers=[
"Environment :: Console",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: Apache Software License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
Expand Down
2 changes: 1 addition & 1 deletion tests/backend_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 Cambridge Quantum Computing
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Cambridge Quantum Computing
# Copyright 2020-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_pytket_backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 Cambridge Quantum Computing
# Copyright 2019-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 1 addition & 3 deletions tests/qiskit_backend_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Cambridge Quantum Computing
# Copyright 2020-2024 Cambridge Quantum Computing
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,8 +22,6 @@
from qiskit.primitives import BackendSampler # type: ignore
from qiskit.providers import JobStatus # type: ignore
from qiskit_algorithms import Grover, AmplificationProblem, AlgorithmError # type: ignore
from qiskit.transpiler import PassManager # type: ignore
from qiskit.transpiler.passes import Unroller # type: ignore
from qiskit_aer import Aer # type: ignore

from qiskit_ibm_provider import IBMProvider # type: ignore
Expand Down
Loading