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

Add kwargs to arguments for Backend.get_compiled_circuit #962

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
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
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.default_compilation_pass(optimisation_level, kwargs).apply(return_circuit)
self.default_compilation_pass(optimisation_level, **kwargs).apply(return_circuit)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.get_compiled_circuit(c, optimisation_level, kwargs) for c in circuits
self.get_compiled_circuit(c, optimisation_level, **kwargs) for c in circuits

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

]

@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
Loading