Skip to content

Commit 2d67c97

Browse files
authored
Merge pull request #31 from CQCL/release/1.9.0
Release/1.9.0
2 parents 1c572c3 + 8e5cdac commit 2d67c97

18 files changed

+256
-46
lines changed

.github/workflows/build-test

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ cd ${GITHUB_WORKSPACE}/tests
5151

5252
python -m pip install --pre -r test-requirements.txt
5353

54+
# update the pytket version to the lastest (pre) release
55+
python -m pip install --upgrade --pre pytket~=1.0
56+
5457
pytest --doctest-modules
5558

5659
cd ..

.github/workflows/build_and_test.yml

+27-23
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
branches:
1010
- develop
1111
- 'wheel/**'
12+
- 'runci/**'
1213
release:
1314
types:
1415
- created
@@ -43,19 +44,18 @@ jobs:
4344
run: |
4445
./.github/workflows/build-test nomypy
4546
- name: Set up Python 3.9
46-
if: github.event_name == 'pull_request' || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel') || github.event_name == 'schedule'
4747
uses: actions/setup-python@v4
4848
with:
4949
python-version: '3.9'
5050
- name: Build and test including remote checks (3.9) mypy
51-
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' )
51+
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' )
5252
shell: bash
5353
run: |
5454
./.github/workflows/build-test mypy
5555
env:
5656
PYTKET_RUN_REMOTE_TESTS: 1
5757
- name: Build and test including remote checks (3.9) nomypy
58-
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' )
58+
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')
5959
shell: bash
6060
run: |
6161
./.github/workflows/build-test nomypy
@@ -108,8 +108,8 @@ jobs:
108108
password: ${{ secrets.PYPI_PYTKET_QISKIT_API_TOKEN }}
109109
verbose: true
110110

111-
docs:
112-
name: Build and publish docs
111+
build_docs:
112+
name: Build docs
113113
if: github.event_name == 'release'
114114
needs: publish_to_pypi
115115
runs-on: ubuntu-22.04
@@ -127,7 +127,7 @@ jobs:
127127
path: wheelhouse
128128
- name: Install pip, wheel
129129
run: pip install -U pip wheel
130-
- name: Install extensions
130+
- name: Install extension
131131
run: for w in `find wheelhouse/ -type f -name "*.whl"` ; do pip install $w ; done
132132
- name: Install docs dependencies
133133
run: |
@@ -137,20 +137,24 @@ jobs:
137137
run: |
138138
cd .github/workflows/docs
139139
mkdir extensions
140-
./build-docs -d ${GITHUB_WORKSPACE}/.github/workflows/docs/extensions
141-
- name: Configure git
142-
run: |
143-
git config --global user.email "tket-bot@cambridgequantum.com"
144-
git config --global user.name "«$GITHUB_WORKFLOW» github action"
145-
- name: Check out gh-pages branch
146-
run: git checkout gh-pages
147-
- name: Remove old docs
148-
run: git rm -r --ignore-unmatch docs/api
149-
- name: Add generated docs to repository
150-
run: |
151-
mkdir -p docs
152-
mv .github/workflows/docs/extensions docs/api
153-
git add -f docs/api
154-
git commit --allow-empty -m "Add generated documentation."
155-
- name: Publish docs
156-
run: git push origin gh-pages:gh-pages
140+
./build-docs -d ${GITHUB_WORKSPACE}/.github/workflows/docs/extensions/api
141+
- name: Upload docs as artefact
142+
uses: actions/upload-pages-artifact@v1
143+
with:
144+
path: .github/workflows/docs/extensions
145+
146+
publish_docs:
147+
name: Publish docs
148+
if: github.event_name == 'release'
149+
needs: build_docs
150+
runs-on: ubuntu-22.04
151+
permissions:
152+
pages: write
153+
id-token: write
154+
environment:
155+
name: github-pages
156+
url: ${{ steps.deployment.outputs.page_url }}
157+
steps:
158+
- name: Deploy to GitHub Pages
159+
id: deployment
160+
uses: actions/deploy-pages@v1

.github/workflows/issue.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ jobs:
1010
runs-on: ubuntu-22.04
1111
steps:
1212
- name: Login
13-
uses: atlassian/gajira-login@v2.0.0
13+
uses: atlassian/gajira-login@v3.0.0
1414
env:
1515
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
1616
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
1717
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
1818
- name: Create Bug
19-
uses: atlassian/gajira-create@v2.0.1
19+
uses: atlassian/gajira-create@v3.0.0
2020
if: contains(github.event.issue.labels.*.name, 'bug')
2121
with:
2222
project: TKET
2323
issuetype: Bug
2424
summary: « [pytket-qiskit] ${{ github.event.issue.title }}»
2525
description: ${{ github.event.issue.html_url }}
2626
- name: Create Task
27-
uses: atlassian/gajira-create@v2.0.1
27+
uses: atlassian/gajira-create@v3.0.0
2828
if: "! contains(github.event.issue.labels.*.name, 'bug')"
2929
with:
3030
project: TKET

_metadata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__extension_version__ = "0.30.0"
1+
__extension_version__ = "0.31.0"
22
__extension_name__ = "pytket-qiskit"

docs/changelog.rst

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
~~~~~~~~~
33

4+
0.31.0 (November 2022)
5+
----------------------
6+
7+
* Update ``TketBackend`` to support ``FullyConnected`` architecture.
8+
* Fix the issue that some qiskit methods can't retrieve results from ``TketJob``.
9+
* Updated pytket version requirement to 1.9.
10+
* Handle ``OpType.Phase`` when converting to qiskit.
11+
* Change default optimization level in ``default_compilation_pass()`` to 2.
12+
413
0.30.0 (November 2022)
514
----------------------
615

docs/intro.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ Every ``Backend`` in pytket has its own ``default_compilation_pass`` method. Thi
101101
:header-rows: 1
102102

103103
* - optimisation_level = 0
104-
- optimisation_level = 1 [1]
105-
- optimisation_level = 2
104+
- optimisation_level = 1
105+
- optimisation_level = 2 [1]
106106
* - `DecomposeBoxes <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.DecomposeBoxes>`_
107107
- `DecomposeBoxes <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.DecomposeBoxes>`_
108108
- `DecomposeBoxes <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.DecomposeBoxes>`_
@@ -134,7 +134,7 @@ Every ``Backend`` in pytket has its own ``default_compilation_pass`` method. Thi
134134
-
135135
- `SimplifyInitial <https://cqcl.github.io/tket/pytket/api/passes.html#pytket.passes.SimplifyInitial>`_ [4]
136136

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

pytket/extensions/qiskit/backends/aer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def required_predicates(self) -> List[Predicate]:
317317
),
318318
]
319319

320-
def default_compilation_pass(self, optimisation_level: int = 1) -> BasePass:
320+
def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
321321
assert optimisation_level in range(3)
322322
if optimisation_level == 0:
323323
return SequencePass([DecomposeBoxes(), self.rebase_pass()])
@@ -442,7 +442,7 @@ def required_predicates(self) -> List[Predicate]:
442442
pred_list.append(ConnectivityPredicate(arch))
443443
return pred_list
444444

445-
def default_compilation_pass(self, optimisation_level: int = 1) -> BasePass:
445+
def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
446446
assert optimisation_level in range(3)
447447
passlist = [DecomposeBoxes()]
448448
if optimisation_level == 0:

pytket/extensions/qiskit/backends/ibm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def required_predicates(self) -> List[Predicate]:
319319
] + predicates
320320
return predicates
321321

322-
def default_compilation_pass(self, optimisation_level: int = 1) -> BasePass:
322+
def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
323323
assert optimisation_level in range(3)
324324
passlist = [DecomposeBoxes()]
325325
# If you make changes to the default_compilation_pass,

pytket/extensions/qiskit/backends/ibmq_emulator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def rebase_pass(self) -> "BasePass":
102102
def required_predicates(self) -> List["Predicate"]:
103103
return list(self._ibmq.required_predicates)
104104

105-
def default_compilation_pass(self, optimisation_level: int = 1) -> "BasePass":
105+
def default_compilation_pass(self, optimisation_level: int = 2) -> "BasePass":
106106
return self._ibmq.default_compilation_pass(optimisation_level)
107107

108108
@property

pytket/extensions/qiskit/qiskit_convert.py

+10
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ def append_tk_command_to_qiskit(
464464
# subsequent conditional will handle it
465465
return Instruction("", 0, 0, [])
466466
if optype == OpType.Conditional:
467+
if op.op.type == OpType.Phase:
468+
# conditional phase not supported
469+
return InstructionSet()
467470
if args[0] in range_preds:
468471
assert op.value == 1
469472
condition_bits, value = range_preds[args[0]]
@@ -525,6 +528,13 @@ def append_tk_command_to_qiskit(
525528
qiskit_gates.UGate(params[1], params[0] - half, params[2] + half),
526529
qargs=qargs,
527530
)
531+
532+
if optype == OpType.Phase:
533+
params = _get_params(op, symb_map)
534+
assert len(params) == 1
535+
qcirc.global_phase += params[0]
536+
return InstructionSet()
537+
528538
# others are direct translations
529539
try:
530540
gatetype, phase = _known_gate_rev_phase[optype]

pytket/extensions/qiskit/tket_backend.py

+21-5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
GateSetPredicate,
2727
CompilationUnit,
2828
)
29+
from pytket.architecture import FullyConnected # type: ignore
2930

3031

3132
def _extract_basis_gates(backend: Backend) -> List[str]:
@@ -74,6 +75,19 @@ def __init__(self, backend: Backend, comp_pass: Optional[BasePass] = None):
7475
:type comp_pass: Optional[BasePass], optional
7576
"""
7677
arch = backend.backend_info.architecture if backend.backend_info else None
78+
coupling: Optional[List[List[Any]]]
79+
if isinstance(arch, FullyConnected):
80+
coupling = [
81+
[n1.index[0], n2.index[0]]
82+
for n1 in arch.nodes
83+
for n2 in arch.nodes
84+
if n1 != n2
85+
]
86+
else:
87+
coupling = (
88+
[[n.index[0], m.index[0]] for n, m in arch.coupling] if arch else None
89+
)
90+
7791
config = QasmBackendConfiguration(
7892
backend_name=("statevector_" if backend.supports_state else "")
7993
+ "pytket/"
@@ -93,9 +107,7 @@ def __init__(self, backend: Backend, comp_pass: Optional[BasePass] = None):
93107
open_pulse=False,
94108
memory=backend.supports_shots,
95109
max_shots=10000,
96-
coupling_map=[[n.index[0], m.index[0]] for n, m in arch.coupling]
97-
if arch
98-
else None,
110+
coupling_map=coupling,
99111
max_experiments=10000,
100112
)
101113
super().__init__(configuration=config, provider=None)
@@ -111,9 +123,13 @@ def run(
111123
) -> TketJob:
112124
if isinstance(run_input, QuantumCircuit):
113125
run_input = [run_input]
114-
circ_list = [qiskit_to_tk(qc) for qc in run_input]
115126
n_shots = options.get("shots", None)
116-
jobinfos = [JobInfo(circ.qubits, circ.bits, n_shots) for circ in circ_list]
127+
circ_list = []
128+
jobinfos = []
129+
for qc in run_input:
130+
tk_circ = qiskit_to_tk(qc)
131+
circ_list.append(tk_circ)
132+
jobinfos.append(JobInfo(qc.name, tk_circ.qubits, tk_circ.bits, n_shots))
117133
if self._comp_pass:
118134
final_maps = []
119135
compiled_list = []

pytket/extensions/qiskit/tket_job.py

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
@dataclass
3232
class JobInfo:
33+
circuit_name: str
3334
qbits: List[UnitID]
3435
cbits: List[UnitID]
3536
n_shots: Optional[int]
@@ -79,6 +80,7 @@ def result(self, **kwargs: KwargTypes) -> Result:
7980
tk_result, jobinfo.cbits, jobinfo.qbits, fm
8081
),
8182
"header": {
83+
"name": jobinfo.circuit_name,
8284
"creg_sizes": creg_sizes,
8385
"memory_slots": memory_slots,
8486
"clbit_labels": clbit_labels,

pytket/extensions/qiskit/tket_pass.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class TketAutoPass(TketPass):
7373
"aer_simulator_unitary": AerUnitaryBackend,
7474
}
7575

76-
def __init__(self, backend: BackendV1, optimisation_level: int = 1):
76+
def __init__(self, backend: BackendV1, optimisation_level: int = 2):
7777
"""Identifies a Qiskit backend and provides the corresponding default
7878
compilation pass from pytket as a
7979
:py:class:`qiskit.transpiler.TransformationPass`.
@@ -82,8 +82,7 @@ def __init__(self, backend: BackendV1, optimisation_level: int = 1):
8282
:param optimisation_level: The level of optimisation to perform during
8383
compilation. Level 0 just solves the device constraints without
8484
optimising. Level 1 additionally performs some light optimisations.
85-
Level 2 adds more intensive optimisations that can increase compilation
86-
time for large circuits. Defaults to 1.
85+
Level 2 adds more computationally intensive optimisations. Defaults to 2.
8786
:type optimisation_level: int, optional
8887
"""
8988
if isinstance(backend._provider, AerProvider):

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
license="Apache 2",
4444
packages=find_namespace_packages(include=["pytket.*"]),
4545
include_package_data=True,
46-
install_requires=["pytket ~= 1.8", "qiskit ~= 0.39.0"],
46+
install_requires=["pytket ~= 1.9", "qiskit ~= 0.39.0"],
4747
classifiers=[
4848
"Environment :: Console",
4949
"Programming Language :: Python :: 3.8",

tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)