Sequential Quantum Gate Decomposer
v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
|
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 | |
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.
quantum_circuit | SQUANDER circuit to be mapped and routed |
topology | target topology for circuit to be routed to |
max_E_size | Maximum lookahead size for more see at: https://arxiv.org/pdf/1809.02573 |
W | lookahead cost function weight for more see at: https://arxiv.org/pdf/1809.02573 |
Definition at line 38 of file qgd_SABRE.py.
def qgd_SABRE.calculate_gate_depth | ( | self, | |
gate_idx, | |||
IDAG, | |||
resolved_gates | |||
) |
Calculates the number of predecessing unresolved gates for a gate.
gate_idx | gate to be calculated "distance for" |
DAG | circuit DAG |
resolved_gates | indicates whether gate at index is resolved or not |
F | front layer |
Definition at line 228 of file qgd_SABRE.py.
def qgd_SABRE.check_dependencies | ( | self, | |
gate_idx, | |||
IDAG, | |||
resolved_gates | |||
) |
Checks if gate dependencies have been resolved.
gate_idx | gate to check |
IDAG | inverse DAG of circuit |
resolved_gates | indicates whether gate at index is resolved or not |
Definition at line 246 of file qgd_SABRE.py.
def qgd_SABRE.Floyd_Warshall | ( | self | ) |
Floyd_warshall algorithm to calculate distance matrix.
Definition at line 54 of file qgd_SABRE.py.
def qgd_SABRE.generate_DAG | ( | self, | |
circuit | |||
) |
generates DAG of input circuit
cirucit | Circuit to generate DAG of |
Definition at line 95 of file qgd_SABRE.py.
def qgd_SABRE.generate_E | ( | self, | |
F, | |||
DAG, | |||
IDAG, | |||
resolved_gates | |||
) |
Generates lookahead extended layer containing all upcoming two qubit gates.
F | front layer containing unresolved gates |
DAG | dag to walk |
Definition at line 199 of file qgd_SABRE.py.
def qgd_SABRE.generate_inverse_DAG | ( | self, | |
circuit | |||
) |
generates inverse DAG of input circuit
cirucit | Circuit to generate inverse DAG of |
Definition at line 104 of file qgd_SABRE.py.
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.
def qgd_SABRE.get_initial_layer | ( | self, | |
circuit | |||
) |
generates initial layer of input circuit for more see at: https://arxiv.org/pdf/1809.02573
cirucit | Circuit to generate intial layer of |
Definition at line 113 of file qgd_SABRE.py.
def qgd_SABRE.get_inverse_pi | ( | self, | |
pi | |||
) |
returns inverse pi mapping physical qubits Q to virtual qubits q
pi | mapping between virtual qubits q and physical qubits Q |
Definition at line 161 of file qgd_SABRE.py.
def qgd_SABRE.get_mapped_circuit | ( | self, | |
circuit, | |||
init_pi, | |||
gate_order, | |||
flags, | |||
parameters | |||
) |
Returns mapped circuit on physical qubits Q with swaps included.
circuit | circuit to be mapped |
init_pi | intial mapping between virtual qubits q and physical qubits Q |
gate_order | order of gates to be excecuted on physical hardware (swaps included) |
flags | sign if flipping target and control in gate is necessary |
parameters | parameters belonging to the initial circuit |
Definition at line 339 of file qgd_SABRE.py.
def qgd_SABRE.get_reverse_circuit | ( | self, | |
circuit | |||
) |
generates reverse circuit
circuit | Circuit to be reversed |
Definition at line 84 of file qgd_SABRE.py.
def qgd_SABRE.H_basic | ( | self, | |
pi, | |||
q1, | |||
q2 | |||
) |
basic cost function that returns distance of two virtual qubits q1 and q2
pi | mapping between virtual qubits q and physical qubits Q |
q1 | virtual qubit that is the target of the gate |
q2 | virtual qubit that is the control of the gate |
Definition at line 144 of file qgd_SABRE.py.
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.
F | front layer containing unresolved gates |
pi | mapping between virtual qubits q and physical qubits Q |
DAG | DAG of circuit |
IDAG | inverse DAG of circuit |
Definition at line 266 of file qgd_SABRE.py.
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)
pi | mapping between virtual qubits q and physical qubits Q |
q_target | virtual qubit that is the target of the gate |
q_control | virtual qubit that is the control of the gate |
Definition at line 126 of file qgd_SABRE.py.
def qgd_SABRE.map_circuit | ( | self, | |
parameters = np.array([]) , |
|||
iter_num = 1 |
|||
) |
Returns mapped circuit on physical qubits Q with swaps included.
parameters | parameters belonging to initial circuit defined in init |
iter_num | number 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.
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.
pi | mapping between virtual qubits q and physical qubits Q |
DAG | DAG of circuit |
Definition at line 173 of file qgd_SABRE.py.
def qgd_SABRE.update_pi | ( | self, | |
pi, | |||
SWAP | |||
) |
basic cost function that returns distance of two virtual qubits q1 and q2
pi | mapping between virtual qubits q and physical qubits Q |
SWAP | virtual qubits to be swapped |
Definition at line 152 of file qgd_SABRE.py.
qgd_SABRE.alpha |
Definition at line 48 of file qgd_SABRE.py.
qgd_SABRE.circuit_qbit_num |
Definition at line 39 of file qgd_SABRE.py.
qgd_SABRE.D |
Definition at line 45 of file qgd_SABRE.py.
qgd_SABRE.initial_circuit |
Definition at line 41 of file qgd_SABRE.py.
qgd_SABRE.max_E_size |
Definition at line 46 of file qgd_SABRE.py.
qgd_SABRE.max_lookahead |
Definition at line 50 of file qgd_SABRE.py.
qgd_SABRE.neighbours |
Definition at line 49 of file qgd_SABRE.py.
qgd_SABRE.pi |
Definition at line 42 of file qgd_SABRE.py.
qgd_SABRE.qbit_num |
Definition at line 40 of file qgd_SABRE.py.
qgd_SABRE.topology |
Definition at line 44 of file qgd_SABRE.py.
qgd_SABRE.W |
Definition at line 47 of file qgd_SABRE.py.