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_adaptive |
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, level_limit_min=0, topology=None, config={}, accelerator_num=0) |
Constructor of the class. More... | |
def | add_Adaptive_Layers (self) |
Call to add adaptive layers to the gate structure stored by the class. More... | |
def | add_Finalyzing_Layer_To_Gate_Structure (self) |
Call to add finalyzing layer (single qubit rotations on all of the qubits) to the gate structure. More... | |
def | add_Gate_Structure_From_Binary (self, filename) |
Call to append custom layers to the gate structure that are intended to be used in the decomposition from a binary file created from SQUANDER. More... | |
def | add_Layer_To_Imported_Gate_Structure (self) |
Call to add an adaptive layer to the gate structure previously imported gate structure. More... | |
def | apply_Global_Phase_Factor (self) |
Call to apply global phase on Unitary matrix. More... | |
def | apply_Imported_Gate_Structure (self) |
Call to apply the imported gate structure on the unitary. More... | |
def | Compress_Circuit (self) |
Wrapper function to call the compress_circuit method of C++ class N_Qubit_Decomposition. More... | |
def | export_Unitary (self, filename) |
Call to export unitary matrix to binary file. More... | |
def | Finalize_Circuit (self) |
Wrapper function to call the finalize_circuit method of C++ class N_Qubit_Decomposition. More... | |
def | get_Circuit (self) |
Call to retrieve the incorporated quantum circuit (Squander format) More... | |
def | get_Cirq_Circuit (self) |
Export the unitary decomposition into Qiskit format. 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_Initial_Circuit (self) |
Wrapper function to call the get_initial_circuit method of C++ class N_Qubit_Decomposition. 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 | import_Qiskit_Circuit (self, qc_in) |
Call to import initial quantum circuit in QISKIT format to be further comporessed. 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_Gate_Structure (self, Gate_structure) |
Call to set custom gate structure to used in the decomposition. More... | |
def | set_Gate_Structure_From_Binary (self, filename) |
Call to set custom layers to the gate structure that are intended to be used in the decomposition from a binary file created from SQUANDER. More... | |
def | set_Global_Phase (self, new_global_phase) |
Call to set global phase. More... | |
def | set_Iteration_Threshold_of_Randomization (self, threshold=2500) |
Call to set the threshold value for the count of interations, above which the parameters are randomized if the cost function does not decreases fast enough. 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_Randomized_Radius (self, radius) |
Call to set the radius in which randomized parameters are generated around the current minimum duting the optimization process. 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 | set_Unitary_From_Binary (self, filename) |
Call to set unitary matrix from a binary file created from SQUANDER. More... | |
def | Start_Decomposition (self) |
Wrapper function to call the start_decomposition method of C++ class N_Qubit_Decomposition. More... | |
Variables | |
qbit_num | |
the number of qubits More... | |
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.__init__ | ( | self, | |
Umtx, | |||
level_limit_max = 8 , |
|||
level_limit_min = 0 , |
|||
topology = None , |
|||
config = {} , |
|||
accelerator_num = 0 |
|||
) |
Constructor of the class.
Umtx | The unitary matrix to be decomposed. |
optimize_layer_num | Set true to optimize the minimum number of operation layers required in the decomposition, or false when the predefined maximal number of layer gates is used (ideal for general unitaries). |
initial_guess | String indicating the method to guess initial values for the optimalization. Possible values: "zeros" ,"random", "close_to_zero". |
compression_enabled_in | Optional logical value. If True(1) begin decomposition function will compress the circuit. If False(0) it will not. Compression can still be called in seperate wrapper function. |
Definition at line 48 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.add_Adaptive_Layers | ( | self | ) |
Call to add adaptive layers to the gate structure stored by the class.
Definition at line 468 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.add_Finalyzing_Layer_To_Gate_Structure | ( | self | ) |
Call to add finalyzing layer (single qubit rotations on all of the qubits) to the gate structure.
Definition at line 474 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.add_Gate_Structure_From_Binary | ( | self, | |
filename | |||
) |
Call to append custom layers to the gate structure that are intended to be used in the decomposition from a binary file created from SQUANDER.
Definition at line 391 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.add_Layer_To_Imported_Gate_Structure | ( | self | ) |
Call to add an adaptive layer to the gate structure previously imported gate structure.
Definition at line 377 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.apply_Global_Phase_Factor | ( | self | ) |
Call to apply global phase on Unitary matrix.
Definition at line 462 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.apply_Imported_Gate_Structure | ( | self | ) |
Call to apply the imported gate structure on the unitary.
The transformed unitary is to be decomposed in the calculations, and the imported gate structure is released.
Definition at line 481 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.Compress_Circuit | ( | self | ) |
Wrapper function to call the compress_circuit method of C++ class N_Qubit_Decomposition.
Definition at line 95 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.export_Unitary | ( | self, | |
filename | |||
) |
Call to export unitary matrix to binary file.
filename | string |
Definition at line 425 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.Finalize_Circuit | ( | self | ) |
Wrapper function to call the finalize_circuit method of C++ class N_Qubit_Decomposition.
Definition at line 102 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Circuit | ( | self | ) |
Call to retrieve the incorporated quantum circuit (Squander format)
Definition at line 127 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Cirq_Circuit | ( | self | ) |
Export the unitary decomposition into Qiskit format.
Definition at line 151 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Decomposition_Error | ( | self | ) |
Call to get the error of the decomposition.
(i.e. the final value of the cost function)
Definition at line 631 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Global_Phase | ( | self | ) |
Call to get global phase.
Definition at line 438 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Initial_Circuit | ( | self | ) |
Wrapper function to call the get_initial_circuit method of C++ class N_Qubit_Decomposition.
Definition at line 88 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Matrix | ( | self, | |
parameters = None |
|||
) |
Call to retrieve the unitary of the circuit.
parameters | A float64 numpy array |
Definition at line 496 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Num_of_Iters | ( | self | ) |
Call to get the number of iterations.
Definition at line 609 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Optimized_Parameters | ( | self | ) |
Call to get the optimized parameters set in numpy array.
Definition at line 545 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Parameter_Num | ( | self | ) |
Call to get the number of free parameters in the gate structure used for the decomposition.
Definition at line 432 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Project_Name | ( | self | ) |
Call to get the name of the SQUANDER project.
Definition at line 450 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Qbit_Num | ( | self | ) |
Call to get the number of qubits in the circuit.
Definition at line 684 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Qiskit_Circuit | ( | self | ) |
Export the unitary decomposition into Qiskit format.
Definition at line 136 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.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 643 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.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 536 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.get_Unitary | ( | self | ) |
Call to get unitary matrix.
Definition at line 418 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.import_Qiskit_Circuit | ( | self, | |
qc_in | |||
) |
Call to import initial quantum circuit in QISKIT format to be further comporessed.
qc_in | The quantum circuit to be imported |
Definition at line 230 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.List_Gates | ( | self | ) |
Call to print the gates decomposing the initial unitary.
These gates brings the intial matrix into unity.
Definition at line 118 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.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 561 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.Optimization_Problem_Combined | ( | self, | |
parameters = None |
|||
) |
Call to evaluate the cost function and the gradient components.
parameters | A float64 numpy array |
Definition at line 594 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.Optimization_Problem_Grad | ( | self, | |
parameters = None |
|||
) |
Call to evaluate the gradient components.
parameters | A float64 numpy array |
Definition at line 577 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.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 110 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.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 508 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.set_Gate_Structure | ( | self, | |
Gate_structure | |||
) |
Call to set custom gate structure to used in the decomposition.
Gate_structure | An instance of SQUANDER Circuit |
Definition at line 357 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.set_Gate_Structure_From_Binary | ( | self, | |
filename | |||
) |
Call to set custom layers to the gate structure that are intended to be used in the decomposition from a binary file created from SQUANDER.
filename | String containing the filename |
Definition at line 370 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.set_Global_Phase | ( | self, | |
new_global_phase | |||
) |
Call to set global phase.
new_global_phase | New global phase (in radians) |
Definition at line 445 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.set_Iteration_Threshold_of_Randomization | ( | self, | |
threshold = 2500 |
|||
) |
Call to set the threshold value for the count of interations, above which the parameters are randomized if the cost function does not decreases fast enough.
threshold | The value of the threshold |
Definition at line 517 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.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 616 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.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 412 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.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 553 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.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 487 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.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 457 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.set_Randomized_Radius | ( | self, | |
radius | |||
) |
Call to set the radius in which randomized parameters are generated around the current minimum duting the optimization process.
Definition at line 385 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.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 527 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.set_Unitary | ( | self, | |
Umtx_arr | |||
) |
Call to set unitary matrix from a numpy array.
Umtx_arr | numpy complex array |
Definition at line 404 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.set_Unitary_From_Binary | ( | self, | |
filename | |||
) |
Call to set unitary matrix from a binary file created from SQUANDER.
Definition at line 397 of file qgd_N_Qubit_Decomposition_adaptive.py.
def squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.Start_Decomposition | ( | self | ) |
Wrapper function to call the start_decomposition method of C++ class N_Qubit_Decomposition.
Definition at line 82 of file qgd_N_Qubit_Decomposition_adaptive.py.
squander.decomposition.qgd_N_Qubit_Decomposition_adaptive.qbit_num |
the number of qubits
Definition at line 51 of file qgd_N_Qubit_Decomposition_adaptive.py.