Sequential Quantum Gate Decomposer
v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
|
Classes | |
class | qgd_N_Qubit_Decomposition_Tree_Search |
A QGD Python interface class for the decomposition of N-qubit unitaries into U3 and CNOT gates. More... | |
Functions | |
def | __init__ (self, Umtx, level_limit_max=8, topology=None, config={}, accelerator_num=0) |
Constructor of the class. More... | |
def | apply_Global_Phase_Factor (self) |
Call to apply global phase on Unitary matrix. More... | |
def | export_Unitary (self, filename) |
Call to export unitary matrix to binary file. More... | |
def | get_Decomposition_Error (self) |
Call to get the error of the decomposition. More... | |
def | get_Global_Phase (self) |
Call to get global phase. More... | |
def | get_Matrix (self, parameters=None) |
Call to retrieve the unitary of the circuit. More... | |
def | get_Num_of_Iters (self) |
Call to get the number of iterations. More... | |
def | get_Optimized_Parameters (self) |
Call to get the optimized parameters set in numpy array. More... | |
def | get_Parameter_Num (self) |
Call to get the number of free parameters in the gate structure used for the decomposition. More... | |
def | get_Project_Name (self) |
Call to get the name of the SQUANDER project. More... | |
def | get_Qbit_Num (self) |
Call to get the number of qubits in the circuit. More... | |
def | get_Qiskit_Circuit (self) |
Export the unitary decomposition into Qiskit format. More... | |
def | get_Second_Renyi_Entropy (self, parameters=None, input_state=None, qubit_list=None) |
Call to get the second Rényi entropy. More... | |
def | get_Trace_Offset (self) |
Call to get the trace offset used in the cost function. More... | |
def | get_Unitary (self) |
Call to get unitary matrix. More... | |
def | List_Gates (self) |
Call to print the gates decomposing the initial unitary. More... | |
def | Optimization_Problem (self, parameters=None) |
Call to evaluate the cost function. More... | |
def | Optimization_Problem_Combined (self, parameters=None) |
Call to evaluate the cost function and the gradient components. More... | |
def | Optimization_Problem_Grad (self, parameters=None) |
Call to evaluate the gradient components. More... | |
def | Reorder_Qubits (self, qbit_list) |
Call to reorder the qubits in the matrix of the gate. More... | |
def | set_Cost_Function_Variant (self, costfnc=0) |
Call to set the optimizer used in the gate synthesis process. More... | |
def | set_Global_Phase (self, new_global_phase) |
Call to set global phase. More... | |
def | set_Max_Iterations (self, max_iters) |
Call to set the maximum number of iterations for each optimization loop. More... | |
def | set_Optimization_Tolerance (self, tolerance) |
Call to set the error tolerance of the decomposition. More... | |
def | set_Optimized_Parameters (self, new_params) |
Call to set the parameters which are used as a starting point in the optimization. More... | |
def | set_Optimizer (self, optimizer="BFGS") |
Call to set the optimizer used in the gate synthesis process. More... | |
def | set_Project_Name (self, project_name_new) |
Call to set the name of the SQUANDER project. More... | |
def | set_Trace_Offset (self, trace_offset=0) |
Call to set the trace offset used in the cost function. More... | |
def | set_Unitary (self, Umtx_arr) |
Call to set unitary matrix from a numpy array. More... | |
def | Start_Decomposition (self) |
Wrapper function to call the start_decomposition method of C++ class. More... | |
Variables | |
qbit_num | |
the number of qubits More... | |
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.__init__ | ( | self, | |
Umtx, | |||
level_limit_max = 8 , |
|||
topology = None , |
|||
config = {} , |
|||
accelerator_num = 0 |
|||
) |
Constructor of the class.
Umtx_in | The unitary matrix to be decomposed |
qbit_num_in | The number of qubits spanning the unitary Umtx |
level_limit_max | The maximal number of two-qubit gates in the decomposition |
topology_in | A list of <target_qubit, control_qubit> pairs describing the connectivity between qubits. |
config | std::map conatining custom config parameters |
accelerator_num | The number of DFE accelerators used in the calculations |
Definition at line 50 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.apply_Global_Phase_Factor | ( | self | ) |
Call to apply global phase on Unitary matrix.
Definition at line 185 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.export_Unitary | ( | self, | |
filename | |||
) |
Call to export unitary matrix to binary file.
filename | string |
Definition at line 148 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Decomposition_Error | ( | self | ) |
Call to get the error of the decomposition.
(i.e. the final value of the cost function)
Definition at line 328 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Global_Phase | ( | self | ) |
Call to get global phase.
Definition at line 161 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Matrix | ( | self, | |
parameters = None |
|||
) |
Call to retrieve the unitary of the circuit.
parameters | A float64 numpy array |
Definition at line 202 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Num_of_Iters | ( | self | ) |
Call to get the number of iterations.
Definition at line 306 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Optimized_Parameters | ( | self | ) |
Call to get the optimized parameters set in numpy array.
Definition at line 242 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Parameter_Num | ( | self | ) |
Call to get the number of free parameters in the gate structure used for the decomposition.
Definition at line 155 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Project_Name | ( | self | ) |
Call to get the name of the SQUANDER project.
Definition at line 173 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Qbit_Num | ( | self | ) |
Call to get the number of qubits in the circuit.
Definition at line 382 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Qiskit_Circuit | ( | self | ) |
Export the unitary decomposition into Qiskit format.
Definition at line 111 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Second_Renyi_Entropy | ( | self, | |
parameters = None , |
|||
input_state = None , |
|||
qubit_list = None |
|||
) |
Call to get the second Rényi entropy.
parameters | A float64 numpy array |
input_state | A complex array storing the input state. If None |0> is created. |
qubit_list | A subset of qubits for which the Rényi entropy should be calculated. Returns with the calculated entropy |
Definition at line 340 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Trace_Offset | ( | self | ) |
Call to get the trace offset used in the cost function.
In this case Tr(A) = sum_(i-offset=j) A_{ij}
Definition at line 233 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Unitary | ( | self | ) |
Call to get unitary matrix.
Definition at line 141 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.List_Gates | ( | self | ) |
Call to print the gates decomposing the initial unitary.
These gates brings the intial matrix into unity.
Definition at line 103 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.Optimization_Problem | ( | self, | |
parameters = None |
|||
) |
Call to evaluate the cost function.
parameters | A float64 numpy array. The number of parameters can be retrieved with method get_Parameter_Num |
Definition at line 258 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.Optimization_Problem_Combined | ( | self, | |
parameters = None |
|||
) |
Call to evaluate the cost function and the gradient components.
parameters | A float64 numpy array |
Definition at line 291 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.Optimization_Problem_Grad | ( | self, | |
parameters = None |
|||
) |
Call to evaluate the gradient components.
parameters | A float64 numpy array |
Definition at line 274 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.Reorder_Qubits | ( | self, | |
qbit_list | |||
) |
Call to reorder the qubits in the matrix of the gate.
qbit_list | The reordered list of qubits spanning the matrix |
Definition at line 95 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Cost_Function_Variant | ( | self, | |
cost_func = 0 |
|||
) |
Call to set the optimizer used in the gate synthesis process.
call to set the cost function type of the optimization problem
costfnc | Variant of the cost function. Input argument 0 stands for FROBENIUS_NORM, 1 for FROBENIUS_NORM_CORRECTION1, 2 for FROBENIUS_NORM_CORRECTION2 |
cost_func | int argument 0 stands for FROBENIUS_NORM, 1 for FROBENIUS_NORM_CORRECTION1, 2 for FROBENIUS_NORM_CORRECTION2, 3 for HILBERT_SCHMIDT_TEST, 4 for HILBERT_SCHMIDT_TEST_CORRECTION1, 5 for HILBERT_SCHMIDT_TEST_CORRECTION2 see more at: https://arxiv.org/abs/2210.09191 |
Definition at line 214 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Global_Phase | ( | self, | |
new_global_phase | |||
) |
Call to set global phase.
new_global_phase | New global phase (in radians) |
Definition at line 168 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Max_Iterations | ( | self, | |
max_iters | |||
) |
Call to set the maximum number of iterations for each optimization loop.
max_iters | int number of maximum iterations each loop |
Definition at line 313 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Optimization_Tolerance | ( | self, | |
tolerance | |||
) |
Call to set the error tolerance of the decomposition.
tolerance | Error tolerance given as a floating point number |
Definition at line 135 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Optimized_Parameters | ( | self, | |
new_params | |||
) |
Call to set the parameters which are used as a starting point in the optimization.
A | numpy array containing the parameters. The number of parameters can be retrieved with method get_Parameter_Num |
Definition at line 250 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Optimizer | ( | self, | |
optimizer = "BFGS" |
|||
) |
Call to set the optimizer used in the gate synthesis process.
optimizer | String indicating the optimizer. Possible values: "BFGS" ,"ADAM", "BFGS2", "ADAM_BATCHED", "AGENTS", "COSINE", "AGENTS_COMBINED". |
Definition at line 193 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Project_Name | ( | self, | |
project_name_new | |||
) |
Call to set the name of the SQUANDER project.
project_name_new | new project name |
Definition at line 180 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Trace_Offset | ( | self, | |
trace_offset = 0 |
|||
) |
Call to set the trace offset used in the cost function.
In this case Tr(A) = sum_(i-offset=j) A_{ij}
trace_offset | The trace offset to be set |
Definition at line 224 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Unitary | ( | self, | |
Umtx_arr | |||
) |
Call to set unitary matrix from a numpy array.
Umtx_arr | numpy complex array |
Definition at line 127 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.Start_Decomposition | ( | self | ) |
Wrapper function to call the start_decomposition method of C++ class.
Definition at line 84 of file qgd_N_Qubit_Decomposition_Tree_Search.py.
squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.qbit_num |
the number of qubits
Definition at line 53 of file qgd_N_Qubit_Decomposition_Tree_Search.py.