def __init__( self, basis_gates: List[str], approximation_degree: float = 1, coupling_map: CouplingMap = None, backend_props: BackendProperties = None, pulse_optimize: Union[bool, None] = None, natural_direction: Union[bool, None] = None, synth_gates: Union[List[str], None] = None, method: str = "default", min_qubits: int = None, ): """Synthesize unitaries over some basis gates. This pass can approximate 2-qubit unitaries given some approximation closeness measure (expressed as approximation_degree). Other unitaries are synthesized exactly. Args: basis_gates (list[str]): List of gate names to target. approximation_degree (float): Closeness of approximation (0: lowest, 1: highest). coupling_map (CouplingMap): the coupling map of the backend in case synthesis is done on a physical circuit. The directionality of the coupling_map will be taken into account if pulse_optimize is True/None and natural_direction is True/None. backend_props (BackendProperties): Properties of a backend to synthesize for (e.g. gate fidelities). pulse_optimize (bool): Whether to optimize pulses during synthesis. A value of None will attempt it but fall back if it doesn't succeed. A value of True will raise an error if pulse-optimized synthesis does not succeed. natural_direction (bool): Whether to apply synthesis considering directionality of 2-qubit gates. Only applies when `pulse_optimize` is True or None. The natural direction is determined by first checking to see whether the coupling map is unidirectional. If there is no coupling map or the coupling map is bidirectional, the gate direction with the shorter duration from the backend properties will be used. If set to True, and a natural direction can not be determined, raises TranspileError. If set to None, no exception will be raised if a natural direction can not be determined. synth_gates (list[str]): List of gates to synthesize. If None and `pulse_optimize` is False or None, default to ['unitary']. If None and `pulse_optimzie` == True, default to ['unitary', 'swap'] method (str): The unitary synthesis method plugin to use. min_qubits: The minimum number of qubits in the unitary to synthesize. If this is set and the unitary is less than the specified number of qubits it will not be synthesized. """ super().__init__() self._basis_gates = basis_gates self._approximation_degree = approximation_degree self._min_qubits = min_qubits self.method = method self.plugins = plugin.UnitarySynthesisPluginManager() self._coupling_map = coupling_map self._backend_props = backend_props self._pulse_optimize = pulse_optimize self._natural_direction = natural_direction if synth_gates: self._synth_gates = synth_gates else: if pulse_optimize: self._synth_gates = ["unitary", "swap"] else: self._synth_gates = ["unitary"]
def __init__( self, basis_gates: List[str] = None, approximation_degree: float = 1, coupling_map: CouplingMap = None, backend_props: BackendProperties = None, pulse_optimize: Union[bool, None] = None, natural_direction: Union[bool, None] = None, synth_gates: Union[List[str], None] = None, method: str = "default", min_qubits: int = None, plugin_config: dict = None, target: Target = None, ): """Synthesize unitaries over some basis gates. This pass can approximate 2-qubit unitaries given some approximation closeness measure (expressed as approximation_degree). Other unitaries are synthesized exactly. Args: basis_gates (list[str]): List of gate names to target. If this is not specified the ``target`` argument must be used. If both this and the ``target`` are specified the value of ``target`` will be used and this will be ignored. approximation_degree (float): Closeness of approximation (0: lowest, 1: highest). coupling_map (CouplingMap): the coupling map of the backend in case synthesis is done on a physical circuit. The directionality of the coupling_map will be taken into account if pulse_optimize is True/None and natural_direction is True/None. backend_props (BackendProperties): Properties of a backend to synthesize for (e.g. gate fidelities). pulse_optimize (bool): Whether to optimize pulses during synthesis. A value of None will attempt it but fall back if it doesn't succeed. A value of True will raise an error if pulse-optimized synthesis does not succeed. natural_direction (bool): Whether to apply synthesis considering directionality of 2-qubit gates. Only applies when `pulse_optimize` is True or None. The natural direction is determined by first checking to see whether the coupling map is unidirectional. If there is no coupling map or the coupling map is bidirectional, the gate direction with the shorter duration from the backend properties will be used. If set to True, and a natural direction can not be determined, raises TranspileError. If set to None, no exception will be raised if a natural direction can not be determined. synth_gates (list[str]): List of gates to synthesize. If None and `pulse_optimize` is False or None, default to ['unitary']. If None and `pulse_optimzie` == True, default to ['unitary', 'swap'] method (str): The unitary synthesis method plugin to use. min_qubits: The minimum number of qubits in the unitary to synthesize. If this is set and the unitary is less than the specified number of qubits it will not be synthesized. plugin_config: Optional extra configuration arguments (as a dict) which are passed directly to the specified unitary synthesis plugin. By default this will have no effect as the default plugin has no extra arguments. Refer to the documentation of your unitary synthesis plugin on how to use this. target: The optional :class:`~.Target` for the target device the pass is compiling for. If specified this will supersede the values set for ``basis_gates``, ``coupling_map``, and ``backend_props``. """ super().__init__() self._basis_gates = set(basis_gates or ()) self._approximation_degree = approximation_degree self._min_qubits = min_qubits self.method = method self.plugins = plugin.UnitarySynthesisPluginManager() self._coupling_map = coupling_map self._backend_props = backend_props self._pulse_optimize = pulse_optimize self._natural_direction = natural_direction self._plugin_config = plugin_config self._target = target if target is not None: self._coupling_map = self._target.build_coupling_map() if synth_gates: self._synth_gates = synth_gates else: if pulse_optimize: self._synth_gates = ["unitary", "swap"] else: self._synth_gates = ["unitary"] self._synth_gates = set(self._synth_gates) - self._basis_gates