Esempio n. 1
0
    def run(self, dag: Union[DAGCircuit,
                             Circuit]) -> Union[DAGCircuit, Circuit]:
        """Run the Mapping pass on `dag`.

        Args:
            dag (DAGCircuit): DAG to map.

        Returns:
            DAGCircuit: A mapped DAG.

        Raises:
            TranspilerError: if the coupling map or the layout are not
            compatible with the DAG.
        """
        if isinstance(dag, DAGCircuit):
            self._check_qiskit(dag)
            circuit = from_qiskit(dag)
        else:
            circuit = dag

        if self.method == "sabre":
            mapped_circuit, _ = sabre_map(self.device, circuit)
        elif self.method == "lazy":
            mapped_circuit, _ = jit_map(self.device, circuit)
        elif self.method == "bridge":
            mapped_circuit, _ = bridge_map(self.device, circuit)

        if isinstance(dag, DAGCircuit):
            return to_qiskit(mapped_circuit)
        return mapped_circuit
Esempio n. 2
0
    def run(self, dag: Union[DAGCircuit, Circuit]) -> Union[DAGCircuit, Circuit]:
        """Run the LinearResynth pass on a circuit.

        Args:
            dag (Union[DAGCircuit, Circuit]): A circuit to map.

        Returns:
            Union[DAGCircuit, Circuit]: An optimized circuit.
        """
        if isinstance(dag, DAGCircuit):
            circuit = from_qiskit(dag)
        else:
            circuit = dag

        opt_circuit = linear_resynth(circuit)

        if isinstance(dag, DAGCircuit):
            return to_qiskit(opt_circuit)
        return opt_circuit
Esempio n. 3
0
    def run(self, dag: Union[DAGCircuit,
                             Circuit]) -> Union[DAGCircuit, Circuit]:
        """Run the GateCancellation pass on a circuit.

        Args:
            dag (Union[DAGCircuit, Circuit]): A circuit to map.

        Returns:
            Union[DAGCircuit, Circuit]: An optimized circuit.
        """
        if isinstance(dag, DAGCircuit):
            circuit = from_qiskit(dag)
        else:
            circuit = dag

        opt_circuit = gate_cancellation(circuit)

        if isinstance(dag, DAGCircuit):
            return to_qiskit(opt_circuit)
        return opt_circuit
Esempio n. 4
0
    def run(self, dag: Union[DAGCircuit,
                             Circuit]) -> Union[DAGCircuit, Circuit]:
        """Run the PhaseFolding pass on a circuit.

        Args:
            dag (Union[DAGCircuit, Circuit]): A circuit to map.

        Returns:
            Union[DAGCircuit, Circuit]: An optimized circuit.
        """
        if isinstance(dag, DAGCircuit):
            circuit = from_qiskit(dag)
        else:
            circuit = dag

        opt_circuit = phase_folding(circuit)

        if isinstance(dag, DAGCircuit):
            return to_qiskit(opt_circuit)
        return opt_circuit
Esempio n. 5
0
    def run(self, dag: Union[DAGCircuit,
                             Circuit]) -> Union[DAGCircuit, Circuit]:
        """Run the BarencoDecomp pass on a circuit.

        Args:
            dag (Union[DAGCircuit, Circuit]): A circuit to map.

        Returns:
            Union[DAGCircuit, Circuit]: An optimized circuit.
        """
        if isinstance(dag, DAGCircuit):
            circuit = from_qiskit(dag)
        else:
            circuit = dag

        opt_circuit = barenco_decomp(circuit)

        if isinstance(dag, DAGCircuit):
            return to_qiskit(opt_circuit)
        return opt_circuit