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

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...
 

Function Documentation

◆ __init__()

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.

Parameters
Umtx_inThe unitary matrix to be decomposed
qbit_num_inThe number of qubits spanning the unitary Umtx
level_limit_maxThe maximal number of two-qubit gates in the decomposition
topology_inA list of <target_qubit, control_qubit> pairs describing the connectivity between qubits.
configstd::map conatining custom config parameters
accelerator_numThe number of DFE accelerators used in the calculations
Returns
An instance of the class

Definition at line 50 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ apply_Global_Phase_Factor()

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.

◆ export_Unitary()

def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.export_Unitary (   self,
  filename 
)

Call to export unitary matrix to binary file.

Parameters
filenamestring

Definition at line 148 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ get_Decomposition_Error()

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)

Returns
Returns with the error of the decmposition

Definition at line 328 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ get_Global_Phase()

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.

◆ get_Matrix()

def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Matrix (   self,
  parameters = None 
)

Call to retrieve the unitary of the circuit.

Parameters
parametersA float64 numpy array

Definition at line 202 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ get_Num_of_Iters()

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.

◆ get_Optimized_Parameters()

def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Optimized_Parameters (   self)

Call to get the optimized parameters set in numpy array.

Returns
Returns with the optimized parameters

Definition at line 242 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ get_Parameter_Num()

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.

◆ get_Project_Name()

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.

◆ get_Qbit_Num()

def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Qbit_Num (   self)

Call to get the number of qubits in the circuit.

Returns
Returns with the number of qubits

Definition at line 382 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ get_Qiskit_Circuit()

def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.get_Qiskit_Circuit (   self)

Export the unitary decomposition into Qiskit format.

Returns
Return with a Qiskit compatible quantum circuit.

Definition at line 111 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ get_Second_Renyi_Entropy()

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
parametersA float64 numpy array
input_stateA complex array storing the input state. If None |0> is created.
qubit_listA 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.

◆ get_Trace_Offset()

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}

Returns
Returns with the trace offset

Definition at line 233 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ get_Unitary()

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.

◆ List_Gates()

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.

◆ Optimization_Problem()

def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.Optimization_Problem (   self,
  parameters = None 
)

Call to evaluate the cost function.

Parameters
parametersA 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.

◆ Optimization_Problem_Combined()

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
parametersA float64 numpy array

Definition at line 291 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ Optimization_Problem_Grad()

def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.Optimization_Problem_Grad (   self,
  parameters = None 
)

Call to evaluate the gradient components.

Parameters
parametersA float64 numpy array

Definition at line 274 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ Reorder_Qubits()

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.

Parameters
qbit_listThe reordered list of qubits spanning the matrix

Definition at line 95 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ set_Cost_Function_Variant()

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

Parameters
costfncVariant of the cost function. Input argument 0 stands for FROBENIUS_NORM, 1 for FROBENIUS_NORM_CORRECTION1, 2 for FROBENIUS_NORM_CORRECTION2
cost_funcint 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.

Here is the caller graph for this function:

◆ set_Global_Phase()

def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Global_Phase (   self,
  new_global_phase 
)

Call to set global phase.

Parameters
new_global_phaseNew global phase (in radians)

Definition at line 168 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ set_Max_Iterations()

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.

Parameters
max_itersint number of maximum iterations each loop

Definition at line 313 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

Here is the call graph for this function:

◆ set_Optimization_Tolerance()

def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Optimization_Tolerance (   self,
  tolerance 
)

Call to set the error tolerance of the decomposition.

Parameters
toleranceError tolerance given as a floating point number

Definition at line 135 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ set_Optimized_Parameters()

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.

Parameters
Anumpy 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.

◆ set_Optimizer()

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.

Parameters
optimizerString 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.

◆ set_Project_Name()

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.

Parameters
project_name_newnew project name

Definition at line 180 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ set_Trace_Offset()

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}

Parameters
trace_offsetThe trace offset to be set

Definition at line 224 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ set_Unitary()

def squander.decomposition.qgd_N_Qubit_Decomposition_Tree_Search.set_Unitary (   self,
  Umtx_arr 
)

Call to set unitary matrix from a numpy array.

Parameters
Umtx_arrnumpy complex array

Definition at line 127 of file qgd_N_Qubit_Decomposition_Tree_Search.py.

◆ Start_Decomposition()

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.

Variable Documentation

◆ qbit_num

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.