Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
Classes | Functions | Variables
qgd_SABRE Namespace Reference

Classes

class  qgd_SABRE
 

Functions

def __init__ (self, quantum_circuit, topology, max_lookahead=4, max_E_size=20, W=0.5, alpha=0.9)
 Constructor of the class. More...
 
def calculate_gate_depth (self, gate_idx, IDAG, resolved_gates)
 Calculates the number of predecessing unresolved gates for a gate. More...
 
def check_dependencies (self, gate_idx, IDAG, resolved_gates)
 Checks if gate dependencies have been resolved. More...
 
def Floyd_Warshall (self)
 Floyd_warshall algorithm to calculate distance matrix. More...
 
def generate_DAG (self, circuit)
 generates DAG of input circuit More...
 
def generate_E (self, F, DAG, IDAG, resolved_gates)
 Generates lookahead extended layer containing all upcoming two qubit gates. More...
 
def generate_inverse_DAG (self, circuit)
 generates inverse DAG of input circuit More...
 
def geneterate_possible_connections (self)
 generate list of possible connections based on inputted topology More...
 
def get_initial_layer (self, circuit)
 generates initial layer of input circuit for more see at: https://arxiv.org/pdf/1809.02573 More...
 
def get_inverse_pi (self, pi)
 returns inverse pi mapping physical qubits Q to virtual qubits q More...
 
def get_mapped_circuit (self, circuit, init_pi, gate_order, flags, parameters)
 Returns mapped circuit on physical qubits Q with swaps included. More...
 
def get_reverse_circuit (self, circuit)
 generates reverse circuit More...
 
def H_basic (self, pi, q1, q2)
 basic cost function that returns distance of two virtual qubits q1 and q2 More...
 
def Heuristic_search (self, F, pi, DAG, IDAG)
 Heuristic search to map circuit to topology based on initial mapping pi this is an implementation of Algorithm 1 as seen in: https://arxiv.org/pdf/1809.02573. More...
 
def is_gate_possible (self, pi, q_target, q_control)
 checks if connection between two virtual qubits q_target and q_control is possible, if second return is 1 it means gate might need to be inverted (with H gates in the case of CNOT) More...
 
def map_circuit (self, parameters=np.array([]), iter_num=1)
 Returns mapped circuit on physical qubits Q with swaps included. More...
 
def obtain_SWAPS (self, F, pi, DAG)
 Get all possible swaps between all involved qubits in F F front layer containing unresolved gates. More...
 
def update_pi (self, pi, SWAP)
 basic cost function that returns distance of two virtual qubits q1 and q2 More...
 

Variables

 alpha
 
 circuit_qbit_num
 
 D
 
 initial_circuit
 
 max_E_size
 
 max_lookahead
 
 neighbours
 
 pi
 
 qbit_num
 
 topology
 
 W
 

Function Documentation

◆ __init__()

def qgd_SABRE.__init__ (   self,
  quantum_circuit,
  topology,
  max_lookahead = 4,
  max_E_size = 20,
  W = 0.5,
  alpha = 0.9 
)

Constructor of the class.

Parameters
quantum_circuitSQUANDER circuit to be mapped and routed
topologytarget topology for circuit to be routed to
max_E_sizeMaximum lookahead size for more see at: https://arxiv.org/pdf/1809.02573
Wlookahead cost function weight for more see at: https://arxiv.org/pdf/1809.02573

Definition at line 38 of file qgd_SABRE.py.

◆ calculate_gate_depth()

def qgd_SABRE.calculate_gate_depth (   self,
  gate_idx,
  IDAG,
  resolved_gates 
)

Calculates the number of predecessing unresolved gates for a gate.

Parameters
gate_idxgate to be calculated "distance for"
DAGcircuit DAG
resolved_gatesindicates whether gate at index is resolved or not
Ffront layer

Definition at line 228 of file qgd_SABRE.py.

◆ check_dependencies()

def qgd_SABRE.check_dependencies (   self,
  gate_idx,
  IDAG,
  resolved_gates 
)

Checks if gate dependencies have been resolved.

Parameters
gate_idxgate to check
IDAGinverse DAG of circuit
resolved_gatesindicates whether gate at index is resolved or not

Definition at line 246 of file qgd_SABRE.py.

◆ Floyd_Warshall()

def qgd_SABRE.Floyd_Warshall (   self)

Floyd_warshall algorithm to calculate distance matrix.

Definition at line 54 of file qgd_SABRE.py.

◆ generate_DAG()

def qgd_SABRE.generate_DAG (   self,
  circuit 
)

generates DAG of input circuit

Parameters
cirucitCircuit to generate DAG of

Definition at line 95 of file qgd_SABRE.py.

◆ generate_E()

def qgd_SABRE.generate_E (   self,
  F,
  DAG,
  IDAG,
  resolved_gates 
)

Generates lookahead extended layer containing all upcoming two qubit gates.

Parameters
Ffront layer containing unresolved gates
DAGdag to walk

Definition at line 199 of file qgd_SABRE.py.

Here is the call graph for this function:

◆ generate_inverse_DAG()

def qgd_SABRE.generate_inverse_DAG (   self,
  circuit 
)

generates inverse DAG of input circuit

Parameters
cirucitCircuit to generate inverse DAG of

Definition at line 104 of file qgd_SABRE.py.

◆ geneterate_possible_connections()

def qgd_SABRE.geneterate_possible_connections (   self)

generate list of possible connections based on inputted topology

Definition at line 70 of file qgd_SABRE.py.

◆ get_initial_layer()

def qgd_SABRE.get_initial_layer (   self,
  circuit 
)

generates initial layer of input circuit for more see at: https://arxiv.org/pdf/1809.02573

Parameters
cirucitCircuit to generate intial layer of

Definition at line 113 of file qgd_SABRE.py.

◆ get_inverse_pi()

def qgd_SABRE.get_inverse_pi (   self,
  pi 
)

returns inverse pi mapping physical qubits Q to virtual qubits q

Parameters
pimapping between virtual qubits q and physical qubits Q

Definition at line 161 of file qgd_SABRE.py.

◆ get_mapped_circuit()

def qgd_SABRE.get_mapped_circuit (   self,
  circuit,
  init_pi,
  gate_order,
  flags,
  parameters 
)

Returns mapped circuit on physical qubits Q with swaps included.

Parameters
circuitcircuit to be mapped
init_piintial mapping between virtual qubits q and physical qubits Q
gate_orderorder of gates to be excecuted on physical hardware (swaps included)
flagssign if flipping target and control in gate is necessary
parametersparameters belonging to the initial circuit

Definition at line 339 of file qgd_SABRE.py.

◆ get_reverse_circuit()

def qgd_SABRE.get_reverse_circuit (   self,
  circuit 
)

generates reverse circuit

Parameters
circuitCircuit to be reversed

Definition at line 84 of file qgd_SABRE.py.

◆ H_basic()

def qgd_SABRE.H_basic (   self,
  pi,
  q1,
  q2 
)

basic cost function that returns distance of two virtual qubits q1 and q2

Parameters
pimapping between virtual qubits q and physical qubits Q
q1virtual qubit that is the target of the gate
q2virtual qubit that is the control of the gate

Definition at line 144 of file qgd_SABRE.py.

◆ Heuristic_search()

def qgd_SABRE.Heuristic_search (   self,
  F,
  pi,
  DAG,
  IDAG 
)

Heuristic search to map circuit to topology based on initial mapping pi this is an implementation of Algorithm 1 as seen in: https://arxiv.org/pdf/1809.02573.

Parameters
Ffront layer containing unresolved gates
pimapping between virtual qubits q and physical qubits Q
DAGDAG of circuit
IDAGinverse DAG of circuit

Definition at line 266 of file qgd_SABRE.py.

◆ is_gate_possible()

def qgd_SABRE.is_gate_possible (   self,
  pi,
  q_target,
  q_control 
)

checks if connection between two virtual qubits q_target and q_control is possible, if second return is 1 it means gate might need to be inverted (with H gates in the case of CNOT)

Parameters
pimapping between virtual qubits q and physical qubits Q
q_targetvirtual qubit that is the target of the gate
q_controlvirtual qubit that is the control of the gate

Definition at line 126 of file qgd_SABRE.py.

◆ map_circuit()

def qgd_SABRE.map_circuit (   self,
  parameters = np.array([]),
  iter_num = 1 
)

Returns mapped circuit on physical qubits Q with swaps included.

Parameters
parametersparameters belonging to initial circuit defined in init
iter_numnumber of iterations to execute during reversal traversal to find optimal mapping, for more see at: https://arxiv.org/pdf/1809.02573

Definition at line 378 of file qgd_SABRE.py.

◆ obtain_SWAPS()

def qgd_SABRE.obtain_SWAPS (   self,
  F,
  pi,
  DAG 
)

Get all possible swaps between all involved qubits in F F front layer containing unresolved gates.

Parameters
pimapping between virtual qubits q and physical qubits Q
DAGDAG of circuit

Definition at line 173 of file qgd_SABRE.py.

◆ update_pi()

def qgd_SABRE.update_pi (   self,
  pi,
  SWAP 
)

basic cost function that returns distance of two virtual qubits q1 and q2

Parameters
pimapping between virtual qubits q and physical qubits Q
SWAPvirtual qubits to be swapped

Definition at line 152 of file qgd_SABRE.py.

Variable Documentation

◆ alpha

qgd_SABRE.alpha

Definition at line 48 of file qgd_SABRE.py.

◆ circuit_qbit_num

qgd_SABRE.circuit_qbit_num

Definition at line 39 of file qgd_SABRE.py.

◆ D

qgd_SABRE.D

Definition at line 45 of file qgd_SABRE.py.

◆ initial_circuit

qgd_SABRE.initial_circuit

Definition at line 41 of file qgd_SABRE.py.

◆ max_E_size

qgd_SABRE.max_E_size

Definition at line 46 of file qgd_SABRE.py.

◆ max_lookahead

qgd_SABRE.max_lookahead

Definition at line 50 of file qgd_SABRE.py.

◆ neighbours

qgd_SABRE.neighbours

Definition at line 49 of file qgd_SABRE.py.

◆ pi

qgd_SABRE.pi

Definition at line 42 of file qgd_SABRE.py.

◆ qbit_num

qgd_SABRE.qbit_num

Definition at line 40 of file qgd_SABRE.py.

◆ topology

qgd_SABRE.topology

Definition at line 44 of file qgd_SABRE.py.

◆ W

qgd_SABRE.W

Definition at line 47 of file qgd_SABRE.py.