Skip to content

Commit 12ca6d7

Browse files
authored
Merge pull request #106 from CQCL/release/pytket-1.15.0
Release/pytket 1.15.0
2 parents a2b349b + d4ef967 commit 12ca6d7

File tree

7 files changed

+97
-21
lines changed

7 files changed

+97
-21
lines changed

_metadata.py

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

docs/changelog.rst

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

4+
0.39.0 (May 2023)
5+
-----------------
6+
7+
* Updated pytket version requirement to 1.15.
8+
* The get_compiled_circuit method now allows for optional arguments to override the default settings in the NoiseAwarePlacement
9+
410
0.38.0 (April 2023)
511
-------------------
612

docs/intro.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ and several types of simulator.
114114
* - `AerUnitaryBackend <https://cqcl.github.io/pytket-qiskit/api/api.html#pytket.extensions.qiskit.AerUnitaryBackend>`_
115115
- Unitary simulator
116116

117-
* [1] :py:class`AerBackend` is noiseless by default and has no architecture. However it can accept a user defined :py:class:`NoiseModel` and :py:class:`Architecture`.
117+
* [1] :py:class:`AerBackend` is noiseless by default and has no architecture. However it can accept a user defined :py:class:`NoiseModel` and :py:class:`Architecture`.
118118
* In addition to the backends above the ``pytket-qiskit`` extension also has the :py:class:`TketBackend`. This allows a tket :py:class:`Backend` to be used directly through qiskit. see the `notebook example <https://github.com/CQCL/pytket/blob/main/examples/qiskit_integration.ipynb>`_ on qiskit integration.
119119

120120
Default Compilation

pytket/extensions/qiskit/backends/aer.py

+28-9
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,32 @@ def rebase_pass(self) -> BasePass:
127127
)
128128

129129
def _arch_dependent_default_compilation_pass(
130-
self, arch: Architecture, optimisation_level: int = 2
130+
self,
131+
arch: Architecture,
132+
optimisation_level: int = 2,
133+
placement_options: Optional[Dict] = None,
131134
) -> BasePass:
132135
assert optimisation_level in range(3)
136+
if placement_options is not None:
137+
noise_aware_placement = NoiseAwarePlacement(
138+
arch,
139+
self._backend_info.averaged_node_gate_errors,
140+
self._backend_info.averaged_edge_gate_errors,
141+
self._backend_info.averaged_readout_errors,
142+
**placement_options,
143+
)
144+
else:
145+
noise_aware_placement = NoiseAwarePlacement(
146+
arch,
147+
self._backend_info.averaged_node_gate_errors,
148+
self._backend_info.averaged_edge_gate_errors,
149+
self._backend_info.averaged_readout_errors,
150+
)
151+
133152
arch_specific_passes = [
134153
CXMappingPass(
135154
arch,
136-
NoiseAwarePlacement(
137-
arch,
138-
self._backend_info.averaged_node_gate_errors,
139-
self._backend_info.averaged_edge_gate_errors,
140-
self._backend_info.averaged_readout_errors,
141-
),
155+
noise_aware_placement,
142156
directed_cx=True,
143157
delay_measures=False,
144158
),
@@ -182,11 +196,16 @@ def _arch_independent_default_compilation_pass(
182196
return SequencePass([DecomposeBoxes(), SynthesiseTket()])
183197
return SequencePass([DecomposeBoxes(), FullPeepholeOptimise()])
184198

185-
def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
199+
def default_compilation_pass(
200+
self, optimisation_level: int = 2, placement_options: Optional[Dict] = None
201+
) -> BasePass:
202+
"""
203+
See documentation for :py:meth:`IBMQBackend.default_compilation_pass`.
204+
"""
186205
arch = self._backend_info.architecture
187206
if arch.coupling and self._backend_info.get_misc("characterisation"):
188207
return self._arch_dependent_default_compilation_pass(
189-
arch, optimisation_level
208+
arch, optimisation_level, placement_options=placement_options
190209
)
191210

192211
return self._arch_independent_default_compilation_pass(optimisation_level)

pytket/extensions/qiskit/backends/ibm.py

+53-7
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,42 @@ def required_predicates(self) -> List[Predicate]:
346346
] + predicates
347347
return predicates
348348

349-
def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
349+
def default_compilation_pass(
350+
self, optimisation_level: int = 2, placement_options: Optional[Dict] = None
351+
) -> BasePass:
352+
"""
353+
A suggested compilation pass that will will, if possible, produce an equivalent
354+
circuit suitable for running on this backend.
355+
356+
At a minimum it will ensure that compatible gates are used and that all two-
357+
qubit interactions are compatible with the backend's qubit architecture. At
358+
higher optimisation levels, further optimisations may be applied.
359+
360+
This is a an abstract method which is implemented in the backend itself, and so
361+
is tailored to the backend's requirements.
362+
363+
The default compilation passes for the :py:class:`IBMQBackend`,
364+
:py:class:`IBMQEmulatorBackend` and the
365+
Aer simulators support an optional ``placement_options`` dictionary containing
366+
arguments to override the default settings in :py:class:`NoiseAwarePlacement`.
367+
368+
:param optimisation_level: The level of optimisation to perform during
369+
compilation.
370+
371+
- Level 0 does the minimum required to solves the device constraints,
372+
without any optimisation.
373+
- Level 1 additionally performs some light optimisations.
374+
- Level 2 (the default) adds more computationally intensive optimisations
375+
that should give the best results from execution.
376+
377+
:type optimisation_level: int, optional
378+
379+
:param placement_options: Optional argument allowing the user to override
380+
the default settings in :py:class:`NoiseAwarePlacement`.
381+
:type placement_options: Dict, optional
382+
:return: Compilation pass guaranteeing required predicates.
383+
:rtype: BasePass
384+
"""
350385
assert optimisation_level in range(3)
351386
passlist = [DecomposeBoxes()]
352387
# If you make changes to the default_compilation_pass,
@@ -363,15 +398,26 @@ def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
363398
mid_measure = self._backend_info.supports_midcircuit_measurement
364399
arch = self._backend_info.architecture
365400
if not isinstance(arch, FullyConnected):
401+
if placement_options is not None:
402+
noise_aware_placement = NoiseAwarePlacement(
403+
arch,
404+
self._backend_info.averaged_node_gate_errors,
405+
self._backend_info.averaged_edge_gate_errors,
406+
self._backend_info.averaged_readout_errors,
407+
**placement_options,
408+
)
409+
else:
410+
noise_aware_placement = NoiseAwarePlacement(
411+
arch,
412+
self._backend_info.averaged_node_gate_errors,
413+
self._backend_info.averaged_edge_gate_errors,
414+
self._backend_info.averaged_readout_errors,
415+
)
416+
366417
passlist.append(
367418
CXMappingPass(
368419
arch,
369-
NoiseAwarePlacement(
370-
arch,
371-
self._backend_info.averaged_node_gate_errors,
372-
self._backend_info.averaged_edge_gate_errors,
373-
self._backend_info.averaged_readout_errors,
374-
),
420+
noise_aware_placement,
375421
directed_cx=False,
376422
delay_measures=(not mid_measure),
377423
)

pytket/extensions/qiskit/backends/ibmq_emulator.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,14 @@ def backend_info(self) -> BackendInfo:
108108
def required_predicates(self) -> List[Predicate]:
109109
return self._ibmq.required_predicates
110110

111-
def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
111+
def default_compilation_pass(
112+
self, optimisation_level: int = 2, placement_options: Optional[Dict] = None
113+
) -> BasePass:
114+
"""
115+
See documentation for :py:meth:`IBMQBackend.default_compilation_pass`.
116+
"""
112117
return self._ibmq.default_compilation_pass(
113-
optimisation_level=optimisation_level
118+
optimisation_level=optimisation_level, placement_options=placement_options
114119
)
115120

116121
@property

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
packages=find_namespace_packages(include=["pytket.*"]),
4545
include_package_data=True,
4646
install_requires=[
47-
"pytket ~= 1.14",
47+
"pytket ~= 1.15",
4848
"qiskit ~= 0.42.1",
4949
"qiskit-ibm-runtime ~= 0.9.2",
5050
"qiskit-aer ~= 0.12.0",

0 commit comments

Comments
 (0)