qsearch.gatesets
¶
This module defines the Gateset class, which represents the allowed gates and topology for a specific quantum computer.
Several Implementations of Gateset are also defined here. Several aliases are also defined, for the most common use cases.
 qsearch.gatesets.ZXZXZCNOTLinear¶
A Gateset that uses CNOT and the ZXZXZ single qubit parameterization with the linear topology.
 qsearch.gatesets.U3CNOTLinear¶
A Gateset that uses CNOT and the U3 single qubit parameterization with the linear topology.
 qsearch.gatesets.QubitCNOTLinear¶
A Gateset that uses CNOT and the U3 single qubit parameterization with the linear topology, except it uses an XZXZ instead of a U3 after the control qubit of each CNOT. This results in a gateset that covers the same search space as U3CNOTLinear, but with fewer redundant parameters, and therefore faster runtime.
 qsearch.gatesets.QubitCNOTRing¶
Uses U3 and XZXZ like QubitCNOTLinear, but includes a NonadjacentCNOTGate to add a link from the last qubit to the 0th.
 qsearch.gatesets.QubitCNOTAdjacencyList¶
Similar to QubitCNOTLinear and QubitCNOTRing, but takes in an adjacency list which uses NonadjacentCNOTGate to define work with a custom topology.
 qsearch.gatesets.QutritCPIPhaseLinear¶
A qutrit gateset that uses the CPIPhase gate as its twoqutrit gate, with a linear topology.
 qsearch.gatesets.QutritCNOTLinear¶
A qutrit gateset that uses an upgraded version of the CNOT gate as its twoqutrit gate, with a linear topology.
 qsearch.gatesets.DefaultQubit¶
The default Gateset for working with qubits. Currently is equivalent to QubitCNOTLinear.
 qsearch.gatesets.DefaultQutrit¶
The default Gateset for working with qutrits. Currently is equivalent to QutritCPIPhaseLinear.
 qsearch.gatesets.Default¶
The overall default Gateset, which is equivalent to DefaultQubit.
Module Contents¶
Classes¶
This class defines the supported gates and topology for a specific quantum hardware. 

A Gateset for working with CNOT and singlequbit gates parameterized with ZXZXZGate on the linear topology. 

A Gateset for working with CNOT and singlequbit gates parameterized with U3Gate on the linear topology. 

A Gateset for working with CNOT and singlequbit gates parameterized with U3Gate and XZXZGate on the linear topology. This Gateset covers the same search space but uses fewer parameters than ZXZXZCNOTLinear and U3CNOTLinear. 

A Gateset for working with CNOT and singlequbit gates parameterized with U3Gate and XZXZGate on the ring topology. 

A Gateset for working with CZ and singlequbit gates parameterized with U3Gate and XZXZGate on the linear topology. 

A Gateset for working with ISwap and singlequbit gates parameterized with U3Gate and XZXZGate on the linear topology. 

A Gateset for working with ISwap and singlequbit gates parameterized with U3Gate and XZXZGate on the linear topology. 

A Gateset for working with CNOT and singlequbit gates parameterized with U3Gate and XZXZGate on a custom topology, specified in the initializer. 

A Gateset for working with CPIPhase and singlequtrit gates on the linear topology. 

A hybrid Gateset for working with CNOT and singlequtrit gates on the linear topology. 
Functions¶





Attributes¶
 class qsearch.gatesets.Gateset¶
This class defines the supported gates and topology for a specific quantum hardware.
Gatesets must set the value of d in their initializer, which represents the size of qudits that are supported (e.g. 2 for qubits or 3 for qutrits).
 initial_layer(self, qudits)¶
The initial layer in the compilation. Usually a layer of parameterized singlequdit gates.
 Parameters
qudits – The number of qudits in this circuit.
 Returns
A single Gate representing an initial layer for the circuit
 Return type
 search_layers(self, qudits)¶
A set of possible multiqubit gates for searching. Usually this is a twoqudit gate followed by two singlequdit gates, for every allowed placement of the twoqudit gate. This defines the branching factor of the search tree.
 Parameters
qudits – The number of qudits in this circuit
 Returns
A list of tuples of (gate,weight) where Gate is the Gate representing that possible placement of the twoqudit gate, and weight is the weight or cost of adding that gate in that placement to the final circuit.
 Return type
list
 branching_factor(self, qudits)¶
Returns an integer indicating the expected branching factor. Usually this is automatically determined from search_layers, but it may need to be overridden if successors is overridden.
 Parameters
qudits – The number of qudits in this circuit
 Returns
An integer indicating the expecte branching factor
 Return type
int
 successors(self, circ, qudits=None)¶
Returns a list of Gates that are successors in the search tree to the input Gate, circ, representing a current ansatz circuit.
 Parameters
circ – The curret ansatz Gate.
qudits – The number of qudits in this circuit.
 Returns
A list of tuples of (gate, weight) where gate is a Gate that is a successor to circ, and weight is the cost or weight of moving to gate from circ.
 Return type
list
 __eq__(self, other)¶
Return self==value.
 class qsearch.gatesets.ZXZXZCNOTLinear¶
Bases:
Gateset
A Gateset for working with CNOT and singlequbit gates parameterized with ZXZXZGate on the linear topology.
Gatesets must set the value of d in their initializer, which represents the size of qudits that are supported (e.g. 2 for qubits or 3 for qutrits).
 initial_layer(self, n)¶
The initial layer in the compilation. Usually a layer of parameterized singlequdit gates.
 Parameters
qudits – The number of qudits in this circuit.
 Returns
A single Gate representing an initial layer for the circuit
 Return type
 search_layers(self, n)¶
A set of possible multiqubit gates for searching. Usually this is a twoqudit gate followed by two singlequdit gates, for every allowed placement of the twoqudit gate. This defines the branching factor of the search tree.
 Parameters
qudits – The number of qudits in this circuit
 Returns
A list of tuples of (gate,weight) where Gate is the Gate representing that possible placement of the twoqudit gate, and weight is the weight or cost of adding that gate in that placement to the final circuit.
 Return type
list
 class qsearch.gatesets.U3CNOTLinear¶
Bases:
Gateset
A Gateset for working with CNOT and singlequbit gates parameterized with U3Gate on the linear topology.
Gatesets must set the value of d in their initializer, which represents the size of qudits that are supported (e.g. 2 for qubits or 3 for qutrits).
 initial_layer(self, n)¶
The initial layer in the compilation. Usually a layer of parameterized singlequdit gates.
 Parameters
qudits – The number of qudits in this circuit.
 Returns
A single Gate representing an initial layer for the circuit
 Return type
 search_layers(self, n)¶
A set of possible multiqubit gates for searching. Usually this is a twoqudit gate followed by two singlequdit gates, for every allowed placement of the twoqudit gate. This defines the branching factor of the search tree.
 Parameters
qudits – The number of qudits in this circuit
 Returns
A list of tuples of (gate,weight) where Gate is the Gate representing that possible placement of the twoqudit gate, and weight is the weight or cost of adding that gate in that placement to the final circuit.
 Return type
list
 class qsearch.gatesets.QubitCNOTLinear(single_gate=U3Gate(), single_alt=XZXZGate())¶
Bases:
Gateset
A Gateset for working with CNOT and singlequbit gates parameterized with U3Gate and XZXZGate on the linear topology. This Gateset covers the same search space but uses fewer parameters than ZXZXZCNOTLinear and U3CNOTLinear.
 Parameters
single_gate – A qsearch.gates.Gate object used as the singlequbit gate placed after the target side of a CNOT.
single_alt – A qsearch.gates.Gate object used as the singlequbit gate placed after the control side of a CNOT.
Gatesets must set the value of d in their initializer, which represents the size of qudits that are supported (e.g. 2 for qubits or 3 for qutrits).
 initial_layer(self, n)¶
The initial layer in the compilation. Usually a layer of parameterized singlequdit gates.
 Parameters
qudits – The number of qudits in this circuit.
 Returns
A single Gate representing an initial layer for the circuit
 Return type
 search_layers(self, n)¶
A set of possible multiqubit gates for searching. Usually this is a twoqudit gate followed by two singlequdit gates, for every allowed placement of the twoqudit gate. This defines the branching factor of the search tree.
 Parameters
qudits – The number of qudits in this circuit
 Returns
A list of tuples of (gate,weight) where Gate is the Gate representing that possible placement of the twoqudit gate, and weight is the weight or cost of adding that gate in that placement to the final circuit.
 Return type
list
 branching_factor(self, qudits)¶
Returns an integer indicating the expected branching factor. Usually this is automatically determined from search_layers, but it may need to be overridden if successors is overridden.
 Parameters
qudits – The number of qudits in this circuit
 Returns
An integer indicating the expecte branching factor
 Return type
int
 successors(self, circ, qudits=None)¶
Returns a list of Gates that are successors in the search tree to the input Gate, circ, representing a current ansatz circuit.
 Parameters
circ – The curret ansatz Gate.
qudits – The number of qudits in this circuit.
 Returns
A list of tuples of (gate, weight) where gate is a Gate that is a successor to circ, and weight is the cost or weight of moving to gate from circ.
 Return type
list
 class qsearch.gatesets.QubitCNOTRing(single_gate=U3Gate(), single_alt=XZXZGate())¶
Bases:
Gateset
A Gateset for working with CNOT and singlequbit gates parameterized with U3Gate and XZXZGate on the ring topology. :param single_gate: A qsearch.gates.Gate object used as the singlequbit gate placed after the target side of a CNOT. :param single_alt: A qsearch.gates.Gate object used as the singlequbit gate placed after the control side of a CNOT.
Gatesets must set the value of d in their initializer, which represents the size of qudits that are supported (e.g. 2 for qubits or 3 for qutrits).
 initial_layer(self, n)¶
The initial layer in the compilation. Usually a layer of parameterized singlequdit gates.
 Parameters
qudits – The number of qudits in this circuit.
 Returns
A single Gate representing an initial layer for the circuit
 Return type
 search_layers(self, n)¶
A set of possible multiqubit gates for searching. Usually this is a twoqudit gate followed by two singlequdit gates, for every allowed placement of the twoqudit gate. This defines the branching factor of the search tree.
 Parameters
qudits – The number of qudits in this circuit
 Returns
A list of tuples of (gate,weight) where Gate is the Gate representing that possible placement of the twoqudit gate, and weight is the weight or cost of adding that gate in that placement to the final circuit.
 Return type
list
 class qsearch.gatesets.QubitCZLinear¶
Bases:
Gateset
A Gateset for working with CZ and singlequbit gates parameterized with U3Gate and XZXZGate on the linear topology.
Gatesets must set the value of d in their initializer, which represents the size of qudits that are supported (e.g. 2 for qubits or 3 for qutrits).
 initial_layer(self, n)¶
The initial layer in the compilation. Usually a layer of parameterized singlequdit gates.
 Parameters
qudits – The number of qudits in this circuit.
 Returns
A single Gate representing an initial layer for the circuit
 Return type
 search_layers(self, n)¶
A set of possible multiqubit gates for searching. Usually this is a twoqudit gate followed by two singlequdit gates, for every allowed placement of the twoqudit gate. This defines the branching factor of the search tree.
 Parameters
qudits – The number of qudits in this circuit
 Returns
A list of tuples of (gate,weight) where Gate is the Gate representing that possible placement of the twoqudit gate, and weight is the weight or cost of adding that gate in that placement to the final circuit.
 Return type
list
 branching_factor(self, qudits)¶
Returns an integer indicating the expected branching factor. Usually this is automatically determined from search_layers, but it may need to be overridden if successors is overridden.
 Parameters
qudits – The number of qudits in this circuit
 Returns
An integer indicating the expecte branching factor
 Return type
int
 successors(self, circ, qudits=None)¶
Returns a list of Gates that are successors in the search tree to the input Gate, circ, representing a current ansatz circuit.
 Parameters
circ – The curret ansatz Gate.
qudits – The number of qudits in this circuit.
 Returns
A list of tuples of (gate, weight) where gate is a Gate that is a successor to circ, and weight is the cost or weight of moving to gate from circ.
 Return type
list
 class qsearch.gatesets.QubitISwapLinear¶
Bases:
Gateset
A Gateset for working with ISwap and singlequbit gates parameterized with U3Gate and XZXZGate on the linear topology.
Gatesets must set the value of d in their initializer, which represents the size of qudits that are supported (e.g. 2 for qubits or 3 for qutrits).
 initial_layer(self, n)¶
The initial layer in the compilation. Usually a layer of parameterized singlequdit gates.
 Parameters
qudits – The number of qudits in this circuit.
 Returns
A single Gate representing an initial layer for the circuit
 Return type
 search_layers(self, n)¶
A set of possible multiqubit gates for searching. Usually this is a twoqudit gate followed by two singlequdit gates, for every allowed placement of the twoqudit gate. This defines the branching factor of the search tree.
 Parameters
qudits – The number of qudits in this circuit
 Returns
A list of tuples of (gate,weight) where Gate is the Gate representing that possible placement of the twoqudit gate, and weight is the weight or cost of adding that gate in that placement to the final circuit.
 Return type
list
 branching_factor(self, qudits)¶
Returns an integer indicating the expected branching factor. Usually this is automatically determined from search_layers, but it may need to be overridden if successors is overridden.
 Parameters
qudits – The number of qudits in this circuit
 Returns
An integer indicating the expecte branching factor
 Return type
int
 successors(self, circ, qudits=None)¶
Returns a list of Gates that are successors in the search tree to the input Gate, circ, representing a current ansatz circuit.
 Parameters
circ – The curret ansatz Gate.
qudits – The number of qudits in this circuit.
 Returns
A list of tuples of (gate, weight) where gate is a Gate that is a successor to circ, and weight is the cost or weight of moving to gate from circ.
 Return type
list
 class qsearch.gatesets.QubitXXLinear¶
Bases:
Gateset
A Gateset for working with ISwap and singlequbit gates parameterized with U3Gate and XZXZGate on the linear topology.
Gatesets must set the value of d in their initializer, which represents the size of qudits that are supported (e.g. 2 for qubits or 3 for qutrits).
 initial_layer(self, n)¶
The initial layer in the compilation. Usually a layer of parameterized singlequdit gates.
 Parameters
qudits – The number of qudits in this circuit.
 Returns
A single Gate representing an initial layer for the circuit
 Return type
 search_layers(self, n)¶
A set of possible multiqubit gates for searching. Usually this is a twoqudit gate followed by two singlequdit gates, for every allowed placement of the twoqudit gate. This defines the branching factor of the search tree.
 Parameters
qudits – The number of qudits in this circuit
 Returns
A list of tuples of (gate,weight) where Gate is the Gate representing that possible placement of the twoqudit gate, and weight is the weight or cost of adding that gate in that placement to the final circuit.
 Return type
list
 branching_factor(self, qudits)¶
Returns an integer indicating the expected branching factor. Usually this is automatically determined from search_layers, but it may need to be overridden if successors is overridden.
 Parameters
qudits – The number of qudits in this circuit
 Returns
An integer indicating the expecte branching factor
 Return type
int
 successors(self, circ, qudits=None)¶
Returns a list of Gates that are successors in the search tree to the input Gate, circ, representing a current ansatz circuit.
 Parameters
circ – The curret ansatz Gate.
qudits – The number of qudits in this circuit.
 Returns
A list of tuples of (gate, weight) where gate is a Gate that is a successor to circ, and weight is the cost or weight of moving to gate from circ.
 Return type
list
 class qsearch.gatesets.QubitCNOTAdjacencyList(adjacency, single_gate=U3Gate(), single_alt=XZXZGate())¶
Bases:
Gateset
A Gateset for working with CNOT and singlequbit gates parameterized with U3Gate and XZXZGate on a custom topology, specified in the initializer.
Allows the specification of a custom topology through an adjacency list.
For example, this is how you would specifiy the ring topology for 3 qubits: [(0,1), (1,2), (2,1)]
It is not recommended to add bidirectional links, because with the arbitrary parameterized single qubit gates everywhere, such links would be redundant.
 Parameters
adjacency – A list of tuples specifying which CNOT placements are allowed. The tuples must be in the form of (control, target).
single_gate – A qsearch.gates.Gate object used as the singlequbit gate placed after the target side of a CNOT.
single_alt – A qsearch.gates.Gate object used as the singlequbit gate placed after the control side of a CNOT.
 initial_layer(self, n)¶
The initial layer in the compilation. Usually a layer of parameterized singlequdit gates.
 Parameters
qudits – The number of qudits in this circuit.
 Returns
A single Gate representing an initial layer for the circuit
 Return type
 search_layers(self, n)¶
A set of possible multiqubit gates for searching. Usually this is a twoqudit gate followed by two singlequdit gates, for every allowed placement of the twoqudit gate. This defines the branching factor of the search tree.
 Parameters
qudits – The number of qudits in this circuit
 Returns
A list of tuples of (gate,weight) where Gate is the Gate representing that possible placement of the twoqudit gate, and weight is the weight or cost of adding that gate in that placement to the final circuit.
 Return type
list
 class qsearch.gatesets.QutritCPIPhaseLinear¶
Bases:
Gateset
A Gateset for working with CPIPhase and singlequtrit gates on the linear topology.
Gatesets must set the value of d in their initializer, which represents the size of qudits that are supported (e.g. 2 for qubits or 3 for qutrits).
 initial_layer(self, n)¶
The initial layer in the compilation. Usually a layer of parameterized singlequdit gates.
 Parameters
qudits – The number of qudits in this circuit.
 Returns
A single Gate representing an initial layer for the circuit
 Return type
 search_layers(self, n)¶
A set of possible multiqubit gates for searching. Usually this is a twoqudit gate followed by two singlequdit gates, for every allowed placement of the twoqudit gate. This defines the branching factor of the search tree.
 Parameters
qudits – The number of qudits in this circuit
 Returns
A list of tuples of (gate,weight) where Gate is the Gate representing that possible placement of the twoqudit gate, and weight is the weight or cost of adding that gate in that placement to the final circuit.
 Return type
list
 class qsearch.gatesets.QutritCNOTLinear¶
Bases:
Gateset
A hybrid Gateset for working with CNOT and singlequtrit gates on the linear topology.
Gatesets must set the value of d in their initializer, which represents the size of qudits that are supported (e.g. 2 for qubits or 3 for qutrits).
 initial_layer(self, n)¶
The initial layer in the compilation. Usually a layer of parameterized singlequdit gates.
 Parameters
qudits – The number of qudits in this circuit.
 Returns
A single Gate representing an initial layer for the circuit
 Return type
 search_layers(self, n)¶
A set of possible multiqubit gates for searching. Usually this is a twoqudit gate followed by two singlequdit gates, for every allowed placement of the twoqudit gate. This defines the branching factor of the search tree.
 Parameters
qudits – The number of qudits in this circuit
 Returns
A list of tuples of (gate,weight) where Gate is the Gate representing that possible placement of the twoqudit gate, and weight is the weight or cost of adding that gate in that placement to the final circuit.
 Return type
list
 qsearch.gatesets.linear_topology(double_gate, single_gate, n, d, identity_gate=None, single_alt=None, double_weight=1, single_weight=0, skip_index=None)¶
 qsearch.gatesets.fill_row(gate, n)¶
 qsearch.gatesets.find_last_3_cnots_linear(circuit)¶
 qsearch.gatesets.DefaultQubit¶
 qsearch.gatesets.DefaultQutrit¶
 qsearch.gatesets.Default¶