GateDirection#

class qiskit.transpiler.passes.GateDirection(*args, **kwargs)[Quellcode]#

Bases: TransformationPass

Modify asymmetric gates to match the hardware coupling direction.

This pass makes use of the following identities:

                     β”Œβ”€β”€β”€β”β”Œβ”€β”€β”€β”β”Œβ”€β”€β”€β”
q_0: ──■──      q_0: ─ H β”œβ”€ X β”œβ”€ H β”œ
     β”Œβ”€β”΄β”€β”  =        β”œβ”€β”€β”€β”€β””β”€β”¬β”€β”˜β”œβ”€β”€β”€β”€
q_1: ─ X β”œ      q_1: ─ H β”œβ”€β”€β– β”€β”€β”€ H β”œ
     β””β”€β”€β”€β”˜           β””β”€β”€β”€β”˜     β””β”€β”€β”€β”˜

     β”Œβ”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”Œβ”€β”€β”€β”€β”€β”€β”β”Œβ”€β”€β”€β”
q_0: ─0     β”œ     q_0: ─ RY(-pi/2) β”œβ”€1     β”œβ”€ H β”œ
     β”‚  ECR β”‚  =       └┬───────────│  ECR β”‚β”œβ”€β”€β”€β”€
q_1: ─1     β”œ     q_1: ── RY(pi/2) β”œβ”€0     β”œβ”€ H β”œ
     β””β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β””β”€β”€β”€β”€β”€β”€β”˜β””β”€β”€β”€β”˜

     β”Œβ”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”β”Œβ”€β”€β”€β”€β”€β”€β”β”Œβ”€β”€β”€β”
q_0: ─0     β”œ     q_0: ─ H β”œβ”€1     β”œβ”€ H β”œ
     β”‚  RZX β”‚  =       β”œβ”€β”€β”€β”€β”‚  RZX β”‚β”œβ”€β”€β”€β”€
q_1: ─1     β”œ     q_1: ─ H β”œβ”€0     β”œβ”€ H β”œ
     β””β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”˜β””β”€β”€β”€β”€β”€β”€β”˜β””β”€β”€β”€β”˜

This pass assumes that the positions of the qubits in the DAGCircuit.qubits attribute are the physical qubit indicies. For example if dag.qubits[0] is qubit 0 in the CouplingMap or Target.

GateDirection pass.

Parameter:
  • coupling_map (CouplingMap) – Directed graph represented a coupling map.

  • target (Target) – The backend target to use for this pass. If this is specified it will be used instead of the coupling map

Attributes

is_analysis_pass#

Check if the pass is an analysis pass.

If the pass is an AnalysisPass, that means that the pass can analyze the DAG and write the results of that analysis in the property set. Modifications on the DAG are not allowed by this kind of pass.

is_transformation_pass#

Check if the pass is a transformation pass.

If the pass is a TransformationPass, that means that the pass can manipulate the DAG, but cannot modify the property set (but it can be read).

Methods

name()#

Return the name of the pass.

run(dag)[Quellcode]#

Run the GateDirection pass on dag.

Flips the cx nodes to match the directed coupling map. Modifies the input dag.

Parameter:

dag (DAGCircuit) – DAG to map.

RΓΌckgabe:

The rearranged dag for the coupling map

RΓΌckgabetyp:

DAGCircuit

Verursacht:

TranspilerError – If the circuit cannot be mapped just by flipping the cx nodes.