Skip to content

Commit

Permalink
Merge pull request #106 from CQCL/release/pytket-1.15.0
Browse files Browse the repository at this point in the history
Release/pytket 1.15.0
  • Loading branch information
cqc-melf authored May 10, 2023
2 parents a2b349b + d4ef967 commit 12ca6d7
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 21 deletions.
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.38.0"
__extension_version__ = "0.39.0"
__extension_name__ = "pytket-qiskit"
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
~~~~~~~~~

0.39.0 (May 2023)
-----------------

* Updated pytket version requirement to 1.15.
* The get_compiled_circuit method now allows for optional arguments to override the default settings in the NoiseAwarePlacement

0.38.0 (April 2023)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/intro.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ and several types of simulator.
* - `AerUnitaryBackend <https://cqcl.github.io/pytket-qiskit/api/api.html#pytket.extensions.qiskit.AerUnitaryBackend>`_
- Unitary simulator

* [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`.
* [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`.
* 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.

Default Compilation
Expand Down
37 changes: 28 additions & 9 deletions pytket/extensions/qiskit/backends/aer.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,32 @@ def rebase_pass(self) -> BasePass:
)

def _arch_dependent_default_compilation_pass(
self, arch: Architecture, optimisation_level: int = 2
self,
arch: Architecture,
optimisation_level: int = 2,
placement_options: Optional[Dict] = None,
) -> BasePass:
assert optimisation_level in range(3)
if placement_options is not None:
noise_aware_placement = NoiseAwarePlacement(
arch,
self._backend_info.averaged_node_gate_errors,
self._backend_info.averaged_edge_gate_errors,
self._backend_info.averaged_readout_errors,
**placement_options,
)
else:
noise_aware_placement = NoiseAwarePlacement(
arch,
self._backend_info.averaged_node_gate_errors,
self._backend_info.averaged_edge_gate_errors,
self._backend_info.averaged_readout_errors,
)

arch_specific_passes = [
CXMappingPass(
arch,
NoiseAwarePlacement(
arch,
self._backend_info.averaged_node_gate_errors,
self._backend_info.averaged_edge_gate_errors,
self._backend_info.averaged_readout_errors,
),
noise_aware_placement,
directed_cx=True,
delay_measures=False,
),
Expand Down Expand Up @@ -182,11 +196,16 @@ def _arch_independent_default_compilation_pass(
return SequencePass([DecomposeBoxes(), SynthesiseTket()])
return SequencePass([DecomposeBoxes(), FullPeepholeOptimise()])

def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
def default_compilation_pass(
self, optimisation_level: int = 2, placement_options: Optional[Dict] = None
) -> BasePass:
"""
See documentation for :py:meth:`IBMQBackend.default_compilation_pass`.
"""
arch = self._backend_info.architecture
if arch.coupling and self._backend_info.get_misc("characterisation"):
return self._arch_dependent_default_compilation_pass(
arch, optimisation_level
arch, optimisation_level, placement_options=placement_options
)

return self._arch_independent_default_compilation_pass(optimisation_level)
Expand Down
60 changes: 53 additions & 7 deletions pytket/extensions/qiskit/backends/ibm.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,42 @@ def required_predicates(self) -> List[Predicate]:
] + predicates
return predicates

def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
def default_compilation_pass(
self, optimisation_level: int = 2, placement_options: Optional[Dict] = None
) -> BasePass:
"""
A suggested compilation pass that will will, if possible, produce an equivalent
circuit suitable for running on this backend.
At a minimum it will ensure that compatible gates are used and that all two-
qubit interactions are compatible with the backend's qubit architecture. At
higher optimisation levels, further optimisations may be applied.
This is a an abstract method which is implemented in the backend itself, and so
is tailored to the backend's requirements.
The default compilation passes for the :py:class:`IBMQBackend`,
:py:class:`IBMQEmulatorBackend` and the
Aer simulators support an optional ``placement_options`` dictionary containing
arguments to override the default settings in :py:class:`NoiseAwarePlacement`.
:param optimisation_level: The level of optimisation to perform during
compilation.
- Level 0 does the minimum required to solves the device constraints,
without any optimisation.
- Level 1 additionally performs some light optimisations.
- Level 2 (the default) adds more computationally intensive optimisations
that should give the best results from execution.
:type optimisation_level: int, optional
:param placement_options: Optional argument allowing the user to override
the default settings in :py:class:`NoiseAwarePlacement`.
:type placement_options: Dict, optional
:return: Compilation pass guaranteeing required predicates.
:rtype: BasePass
"""
assert optimisation_level in range(3)
passlist = [DecomposeBoxes()]
# If you make changes to the default_compilation_pass,
Expand All @@ -363,15 +398,26 @@ def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
mid_measure = self._backend_info.supports_midcircuit_measurement
arch = self._backend_info.architecture
if not isinstance(arch, FullyConnected):
if placement_options is not None:
noise_aware_placement = NoiseAwarePlacement(
arch,
self._backend_info.averaged_node_gate_errors,
self._backend_info.averaged_edge_gate_errors,
self._backend_info.averaged_readout_errors,
**placement_options,
)
else:
noise_aware_placement = NoiseAwarePlacement(
arch,
self._backend_info.averaged_node_gate_errors,
self._backend_info.averaged_edge_gate_errors,
self._backend_info.averaged_readout_errors,
)

passlist.append(
CXMappingPass(
arch,
NoiseAwarePlacement(
arch,
self._backend_info.averaged_node_gate_errors,
self._backend_info.averaged_edge_gate_errors,
self._backend_info.averaged_readout_errors,
),
noise_aware_placement,
directed_cx=False,
delay_measures=(not mid_measure),
)
Expand Down
9 changes: 7 additions & 2 deletions pytket/extensions/qiskit/backends/ibmq_emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,14 @@ def backend_info(self) -> BackendInfo:
def required_predicates(self) -> List[Predicate]:
return self._ibmq.required_predicates

def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
def default_compilation_pass(
self, optimisation_level: int = 2, placement_options: Optional[Dict] = None
) -> BasePass:
"""
See documentation for :py:meth:`IBMQBackend.default_compilation_pass`.
"""
return self._ibmq.default_compilation_pass(
optimisation_level=optimisation_level
optimisation_level=optimisation_level, placement_options=placement_options
)

@property
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
packages=find_namespace_packages(include=["pytket.*"]),
include_package_data=True,
install_requires=[
"pytket ~= 1.14",
"pytket ~= 1.15",
"qiskit ~= 0.42.1",
"qiskit-ibm-runtime ~= 0.9.2",
"qiskit-aer ~= 0.12.0",
Expand Down

0 comments on commit 12ca6d7

Please sign in to comment.