Skip to content

Commit

Permalink
Readd code change in Qiskit#10835
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
  • Loading branch information
nkanazawa1989 and mtreinish committed Oct 13, 2023
1 parent f3912e8 commit ae14aa7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
33 changes: 30 additions & 3 deletions qiskit/passmanager/passmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def append(
)
if isinstance(tasks, Sequence):
tasks = FlowControllerLinear(tasks)
self._flow_controller.tasks += (tasks, )
self._flow_controller.tasks += (tasks,)

def replace(
self,
Expand Down Expand Up @@ -162,14 +162,34 @@ def _passmanager_frontend(
input_program: Any,
**kwargs,
) -> PassManagerIR:
"""Convert input program into pass manager IR.
Args:
in_program: Input program.
Returns:
Pass manager IR.
"""
pass

@abstractmethod
def _passmanager_backend(
self,
passmanager_ir: PassManagerIR,
in_program: Any,
**kwargs,
) -> Any:
"""Convert pass manager IR into output program.
Args:
passmanager_ir: Pass manager IR after optimization.
in_program: The input program, this can be used if you need
any metadata about the original input for the output.
It should not be mutated.
Returns:
Output program.
"""
pass

def run(
Expand Down Expand Up @@ -272,13 +292,20 @@ def _run_workflow(
"""
flow_controller = pass_manager.to_flow_controller()

passmanager_ir = pass_manager._passmanager_frontend(input_program=program, **kwargs)
passmanager_ir = pass_manager._passmanager_frontend(
input_program=program,
**kwargs,
)
passmanager_ir = flow_controller.execute(
passmanager_ir=passmanager_ir,
property_set=pass_manager.property_set,
callback=kwargs.get("callback", None),
)
out_program = pass_manager._passmanager_backend(passmanager_ir, **kwargs)
out_program = pass_manager._passmanager_backend(
passmanager_ir=passmanager_ir,
in_program=program,
**kwargs,
)

return out_program

Expand Down
Empty file removed qiskit/passmanager/passrunner.py
Empty file.
3 changes: 3 additions & 0 deletions qiskit/transpiler/passmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def _passmanager_frontend(
def _passmanager_backend(
self,
passmanager_ir: DAGCircuit,
in_program: QuantumCircuit,
**kwargs,
) -> QuantumCircuit:
out_program = dag_to_circuit(passmanager_ir)
Expand All @@ -89,6 +90,8 @@ def _passmanager_backend(
initial_layout=self.property_set["layout"],
input_qubit_mapping=self.property_set["original_qubit_indices"],
final_layout=self.property_set["final_layout"],
_input_qubit_count=len(in_program.qubits),
_output_qubit_list=out_program.qubits,
)
out_program._clbit_write_latency = self.property_set["clbit_write_latency"]
out_program._conditional_latency = self.property_set["conditional_latency"]
Expand Down

0 comments on commit ae14aa7

Please sign in to comment.