Skip to content

Commit

Permalink
Update backend.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sjdilkes committed Aug 9, 2023
1 parent 7553dc7 commit 6f32d87
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions pytket/pytket/backends/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def valid_circuit(self, circuit: Circuit) -> bool:
def _check_all_circuits(
self, circuits: Iterable[Circuit], nomeasure_warn: Optional[bool] = None
) -> bool:

if nomeasure_warn is None:
nomeasure_warn = not (
self._supports_state
Expand Down Expand Up @@ -172,18 +171,19 @@ def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
...

def get_compiled_circuit(
self, circuit: Circuit, optimisation_level: int = 2
self, circuit: Circuit, optimisation_level: int = 2, **kwargs
) -> Circuit:
"""
Return a single circuit compiled with :py:meth:`default_compilation_pass`. See
:py:meth:`Backend.get_compiled_circuits`.
Return a single circuit compiled with :py:meth:`default_compilation_pass` See
:py:meth:`Backend.get_compiled_circuits`. Valid kwargs are Backend specific.
"""
return_circuit = circuit.copy()
self.default_compilation_pass(optimisation_level).apply(return_circuit)
self.default_compilation_pass(optimisation_level, kwargs).apply(return_circuit)
return return_circuit

def get_compiled_circuits(
self, circuits: Sequence[Circuit], optimisation_level: int = 2
self, circuits: Sequence[Circuit], optimisation_level: int = 2, **kwargs
) -> List[Circuit]:
"""Compile a sequence of circuits with :py:meth:`default_compilation_pass`
and return the list of compiled circuits (does not act in place).
Expand All @@ -204,6 +204,8 @@ def get_compiled_circuits(
backend, and running the :py:meth:`verify` method on each in turn with your
circuit.
Valid kwargs are backend specific.
:param circuits: The circuits to compile.
:type circuit: Sequence[Circuit]
:param optimisation_level: The level of optimisation to perform during
Expand All @@ -213,7 +215,9 @@ def get_compiled_circuits(
:return: Compiled circuits.
:rtype: List[Circuit]
"""
return [self.get_compiled_circuit(c, optimisation_level) for c in circuits]
return [
self.get_compiled_circuit(c, optimisation_level, kwargs) for c in circuits
]

@property
@abstractmethod
Expand Down Expand Up @@ -265,7 +269,6 @@ def process_circuits(
valid_check: bool = True,
**kwargs: KwargTypes,
) -> List[ResultHandle]:

"""
Submit circuits to the backend for running. The results will be stored
in the backend's result cache to be retrieved by the corresponding
Expand Down

0 comments on commit 6f32d87

Please sign in to comment.