quri_parts.circuit package#
- class QuantumGate(name, target_indices, control_indices=(), classical_indices=(), params=(), pauli_ids=(), unitary_matrix=())#
Bases:
NamedTupleNon-parametric quantum gate.
Not intended for direct use. Every gate is created by factory methods. A QuantumGate object contains information of gate name, control qubit, target qubit, classical bits, parameters, and pauli ids.
- Parameters:
name (str) –
target_indices (Sequence[int]) –
control_indices (Sequence[int]) –
classical_indices (Sequence[int]) –
params (Sequence[float]) –
pauli_ids (Sequence[int]) –
unitary_matrix (Sequence[Sequence[complex]]) –
- name: str#
Alias for field number 0
- target_indices: Sequence[int]#
Alias for field number 1
- control_indices: Sequence[int]#
Alias for field number 2
- classical_indices: Sequence[int]#
Alias for field number 3
- params: Sequence[float]#
Alias for field number 4
- pauli_ids: Sequence[int]#
Alias for field number 5
- unitary_matrix: Sequence[Sequence[complex]]#
Alias for field number 6
- class ParametricQuantumGate(name, target_indices, control_indices=(), pauli_ids=())#
Bases:
NamedTupleParametric quantum gate.
Not intended for direct use. Every gate is created through factory methods. A ParametricQuantumGate object contains information of gate name, control qubit, target qubit, and pauli ids.
- Parameters:
name (str) –
target_indices (Sequence[int]) –
control_indices (Sequence[int]) –
pauli_ids (Sequence[int]) –
- name: str#
Alias for field number 0
- target_indices: Sequence[int]#
Alias for field number 1
- control_indices: Sequence[int]#
Alias for field number 2
- pauli_ids: Sequence[int]#
Alias for field number 3
- class QuantumCircuitProtocol(*args, **kwargs)#
Bases:
ProtocolInterface protocol for a quantum circuit.
This interface covers all quantum circuit classes, including:
Non-parametric circuit, parametric circuit and linearly mapped parametric circuit
Mutable and immutable circuit classes
- abstract property qubit_count: int#
Number of qubits involved in the circuit.
- abstract property cbit_count: int#
Number of classical bits involved in the circuit.
- abstract property depth: int#
Returns circuit depth.
- class MutableQuantumCircuitProtocol(*args, **kwargs)#
Bases:
QuantumCircuitProtocol,ProtocolInterface protocol for a mutable quantum circuit.
This interface represents quantum circuits that can be modified by adding
QuantumGates (non-parametric gates).Some methods (
add_???_gate) have implementations using an abstract methodadd_gate().- abstract add_gate(gate, gate_index=None)#
Add a (non-parametric) quantum gate to the circuit.
- Parameters:
gate (QuantumGate) –
gate_index (int | None) –
- Return type:
None
- abstract extend(gates)#
Extend the circuit with given gate sequence.
- Parameters:
gates (circuit.circuit.GateSequence) –
- Return type:
None
- add_Identity_gate(qubit_index)#
Add an Identity gate to the circuit.
- Parameters:
qubit_index (int) –
- Return type:
None
- add_X_gate(qubit_index)#
Add an X gate to the circuit.
- Parameters:
qubit_index (int) –
- Return type:
None
- add_Y_gate(qubit_index)#
Add a Y gate to the circuit.
- Parameters:
qubit_index (int) –
- Return type:
None
- add_Z_gate(qubit_index)#
Add a Z gate to the circuit.
- Parameters:
qubit_index (int) –
- Return type:
None
- add_H_gate(qubit_index)#
Add an H gate to the circuit.
- Parameters:
qubit_index (int) –
- Return type:
None
- add_S_gate(index)#
Add a S gate to the circuit.
- Parameters:
index (int) –
- Return type:
None
- add_Sdag_gate(index)#
Add a Sdag gate to the circuit.
- Parameters:
index (int) –
- Return type:
None
- add_SqrtX_gate(index)#
Add a SqrtX gate to the circuit.
- Parameters:
index (int) –
- Return type:
None
- add_SqrtXdag_gate(index)#
Add a SqrtXdag gate to the circuit.
- Parameters:
index (int) –
- Return type:
None
- add_SqrtY_gate(index)#
Add a SqrtY gate to the circuit.
- Parameters:
index (int) –
- Return type:
None
- add_SqrtYdag_gate(index)#
Add a SqrtYdag gate to the circuit.
- Parameters:
index (int) –
- Return type:
None
- add_T_gate(index)#
Add a T gate to the circuit.
- Parameters:
index (int) –
- Return type:
None
- add_Tdag_gate(index)#
Add a Tdag gate to the circuit.
- Parameters:
index (int) –
- Return type:
None
- add_U1_gate(index, lmd)#
Add an U1 gate to the circuit.
- Parameters:
index (int) –
lmd (float) –
- Return type:
None
- add_U2_gate(index, phi, lmd)#
Add an U2 gate to the circuit.
- Parameters:
index (int) –
phi (float) –
lmd (float) –
- Return type:
None
- add_U3_gate(index, theta, phi, lmd)#
Add an U3 gate to the circuit.
- Parameters:
index (int) –
theta (float) –
phi (float) –
lmd (float) –
- Return type:
None
- add_RX_gate(index, angle)#
Add a RX gate to the circuit.
- Parameters:
index (int) –
angle (float) –
- Return type:
None
- add_RY_gate(index, angle)#
Add a RY gate to the circuit.
- Parameters:
index (int) –
angle (float) –
- Return type:
None
- add_RZ_gate(index, angle)#
Add a RZ gate to the circuit.
- Parameters:
index (int) –
angle (float) –
- Return type:
None
- add_CNOT_gate(control_index, target_index)#
Add a CNOT gate to the circuit.
- Parameters:
control_index (int) –
target_index (int) –
- Return type:
None
- add_CZ_gate(control_qubit_index, target_qubit_index)#
Add a Control-Z gate to the circuit.
- Parameters:
control_qubit_index (int) –
target_qubit_index (int) –
- Return type:
None
- add_SWAP_gate(target_index1, target_index2)#
Add a SWAP gate to the circuit.
- Parameters:
target_index1 (int) –
target_index2 (int) –
- Return type:
None
- add_TOFFOLI_gate(control_index1, control_index2, target_index)#
Add a TOFFOLI gate to the circuit.
- Parameters:
control_index1 (int) –
control_index2 (int) –
target_index (int) –
- Return type:
None
- add_UnitaryMatrix_gate(target_indices, unitary_matrix)#
Add a UnitaryMatrix gate to the circuit.
- Parameters:
target_indices (Sequence[int]) –
unitary_matrix (Sequence[Sequence[complex]]) –
- Return type:
None
- add_SingleQubitUnitaryMatrix_gate(target_index, unitary_matrix)#
Add a single qubit UnitaryMatrix gate to the circuit.
- Parameters:
target_index (int) –
unitary_matrix (Sequence[Sequence[complex]]) –
- Return type:
None
- add_TwoQubitUnitaryMatrix_gate(target_index1, target_index2, unitary_matrix)#
Add a two qubit UnitaryMatrix gate to the circuit.
- Parameters:
target_index1 (int) –
target_index2 (int) –
unitary_matrix (Sequence[Sequence[complex]]) –
- Return type:
None
- add_Pauli_gate(target_indices, pauli_ids)#
Add a Pauli gate to the circuit.
- Parameters:
target_indices (Sequence[int]) –
pauli_ids (Sequence[int]) –
- Return type:
None
- add_PauliRotation_gate(target_qubits, pauli_id_list, angle)#
Add a Pauli rotation gate to the circuit.
- Parameters:
target_qubits (Sequence[int]) –
pauli_id_list (Sequence[int]) –
angle (float) –
- Return type:
None
- measure(qubit_indices, classical_indices)#
Adds measurement gate at selected qubits.
- Parameters:
qubit_indices (int | Sequence[int]) –
classical_indices (int | Sequence[int]) –
- Return type:
None
- class NonParametricQuantumCircuit(*args, **kwargs)#
Bases:
QuantumCircuitProtocol,ABCA base class for quantum circuits having only non-parametric gates.
This class support
+operator withGateSequence.- abstract property gates: Sequence[QuantumGate]#
Returns the gate sequence of the circuit.
- property depth: int#
Returns circuit depth.
- combine(gates)#
Create a new circuit with itself and the given gates combined.
- Parameters:
gates (circuit.circuit.GateSequence) –
- Return type:
- abstract freeze()#
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.
- Return type:
- abstract get_mutable_copy()#
Returns a copy of itself that can be modified.
Use this method when you want to get a new circuit based on an existing circuit but don’t want to modify it.
- Return type:
- class QuantumCircuit(qubit_count, cbit_count=0, gates=[])#
Bases:
NonParametricQuantumCircuit,MutableQuantumCircuitProtocolA mutable quantum circuit having only non-parametric gates.
- Parameters:
qubit_count (int) –
cbit_count (int) –
gates (Sequence[QuantumGate]) –
- property qubit_count: int#
Number of qubits involved in the circuit.
- property cbit_count: int#
Number of classical bits involved in the circuit.
- property gates: Sequence[QuantumGate]#
Returns the gate sequence of the circuit.
- freeze()#
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.
- Return type:
- get_mutable_copy()#
Returns a copy of itself that can be modified.
Use this method when you want to get a new circuit based on an existing circuit but don’t want to modify it.
- Return type:
- add_gate(gate, gate_index=None)#
Add a (non-parametric) quantum gate to the circuit.
- Parameters:
gate (QuantumGate) –
gate_index (int | None) –
- Return type:
None
- extend(gates)#
Extend the circuit with given gate sequence.
- Parameters:
gates (circuit.circuit.GateSequence) –
- Return type:
None
- class ImmutableQuantumCircuit(circuit)#
Bases:
NonParametricQuantumCircuitAn immutable quantum circuit having only non-parametric gates.
- Parameters:
circuit (NonParametricQuantumCircuit) –
- property qubit_count: int#
Number of qubits involved in the circuit.
- property cbit_count: int#
Number of classical bits involved in the circuit.
- property gates: Sequence[QuantumGate]#
Returns the gate sequence of the circuit.
- property depth: int#
Returns circuit depth.
- freeze()#
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.
- Return type:
- get_mutable_copy()#
Returns a copy of itself that can be modified.
Use this method when you want to get a new circuit based on an existing circuit but don’t want to modify it.
- Return type:
- class Parameter(name='')#
Bases:
objectA class representing parameters in parametric quantum circuits.
A
Parameteris a placeholder and does not hold a concrete value in it.Implementation note: equality of Parameters is evaluated as identity of the objects. This means that even if two Parameters have the same name they are not equal if they are different objects. To achieve this behavior, it is avoided to 1) inherit
NamedTupleand 2) define__eq__method.- Parameters:
name (str) –
- class ParameterMapping(*args, **kwargs)#
Bases:
ProtocolParameterMapping represents a mapping of a set of parameters to another set of parameters.
It can be considered as a function mapping \(m\) input parameters to \(n\) output parameters:
\[(\theta^\text{(out)}_0, \ldots, \theta^\text{(out)}_{n-1}) = f(\theta^\text{(in)}_0, \ldots, \theta^\text{(in)}_{m-1})\]- abstract property mapper: circuit.parameter_mapping.Mapper#
Returns a function that maps an input
ParameterValueAssignmentto an outputParameterValueAssignment(i.e. \(f\)).It is expected that the function captures the state of
ParameterMappingat the time that this property is accessed and does not reflect subsequent changes in the state of theParameterMappinginstance.
- abstract property seq_mapper: circuit.parameter_mapping.SeqMapper#
Returns a function that maps a sequence of input parameter values to a sequence of output parameter values (i.e. \(f\)).
It is expected that the function captures the state of
ParameterMappingat the time that this property is accessed and does not reflect subsequent changes in the state of theParameterMappinginstance.
- get_derivatives()#
Returns a sequence of
ParameterMappings of derivatives of the originalParameterMappingwith respect to each input parameter.The returned sequence corresponds to
\[\left( \frac{\partial f}{\partial \theta^\text{(in)}_0}, \ldots, \frac{\partial f}{\partial \theta^\text{(in)}_{m-1}} \right),\]where \(f\) is defined as described in
ParameterMappingdocstring.- Return type:
Sequence[ParameterMapping]
- CONST = Parameter(name=)#
A placeholder representing a constant term.
- class UnboundParametricQuantumCircuitProtocol(*args, **kwargs)#
Bases:
QuantumCircuitProtocol,ProtocolInterface protocol for a quantum circuit containing unbound (i.e. not assigned values) parameters.
For circuit execution, the parameters need to be assigned concrete values by
bind_parameters()method.- abstract bind_parameters(params)#
Returns a new circuit with the parameters assigned concrete values.
This method does not modify self but returns a newly created circuit.
- Parameters:
params (Sequence[float]) –
- Return type:
- abstract freeze()#
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.
- Return type:
- abstract get_mutable_copy()#
Returns a copy of itself that can be modified.
Use this method when you want to get a new circuit based on an existing circuit but don’t want to modify it.
- Return type:
- abstract primitive_circuit()#
Returns the parametric circuit where each gate has an independent parameter.
Note that some parametric circuit, e.g.
LinearMappedUnboundParametricQuantumCircuit, can have non-trivial mapping of the parameters. In this “primitive circuit”, however, gate parameters are treated as independent, even if those in the original circuit depend on the same parameters. For example, if the parametric circuit is defined as:\[\begin{align} U_1(f(\theta_1, \theta_2)) U_2(g(\theta_1, \theta_2)) \end{align}\]the primitive circuit should be as the following:
\[\begin{align} U_1(\psi_1) U_2(\psi_2) \end{align}\]where U1, U2 are rotation gates and f, g are parameter mappings.
- Return type:
- abstract property parameter_count: int#
- abstract property gates: Sequence[QuantumGate | ParametricQuantumGate]#
Returns the gate sequence of the circuit.
- abstract property has_trivial_parameter_mapping: bool#
Returns if the input parameters are used for parametric gates without any conversions.
Note that some parametric circuit, e.g.
LinearMappedUnboundParametricQuantumCircuit, can have non-trivial mapping of the parameters.
- abstract property param_mapping: ParameterMapping#
Returns the parameter mapping of the circuit.
- class MutableUnboundParametricQuantumCircuitProtocol(*args, **kwargs)#
Bases:
UnboundParametricQuantumCircuitProtocol,MutableQuantumCircuitProtocol,Protocol
- class UnboundParametricQuantumCircuitBase(*args, **kwargs)#
Bases:
UnboundParametricQuantumCircuitProtocol,ABCA base class for quantum circuits having parametric gates with unbound parameters.
This class is for parametric circuits where all parametric gates have independent parameters, i.e., no two parametric gates share the same parameter. If you want to make dependency between parameters, see
LinearMappedUnboundParametricQuantumCircuitBase.- property depth: int#
Returns circuit depth.
- property gates: Sequence[QuantumGate | ParametricQuantumGate]#
Returns the gate sequence of the circuit.
- property gates_and_params: Sequence[tuple[QuantumGate, None] | tuple[ParametricQuantumGate, Parameter]]#
Returns the sequence of the tuples of gate and it’s parameter.
- property has_trivial_parameter_mapping: bool#
Returns if the input parameters are used for parametric gates without any conversions.
Note that some parametric circuit, e.g.
LinearMappedUnboundParametricQuantumCircuit, can have non-trivial mapping of the parameters.
- property param_mapping: LinearParameterMapping#
Returns the parameter mapping of the circuit.
- primitive_circuit()#
Returns the parametric circuit where each gate has an independent parameter.
Note that some parametric circuit, e.g.
LinearMappedUnboundParametricQuantumCircuit, can have non-trivial mapping of the parameters. In this “primitive circuit”, however, gate parameters are treated as independent, even if those in the original circuit depend on the same parameters. For example, if the parametric circuit is defined as:\[\begin{align} U_1(f(\theta_1, \theta_2)) U_2(g(\theta_1, \theta_2)) \end{align}\]the primitive circuit should be as the following:
\[\begin{align} U_1(\psi_1) U_2(\psi_2) \end{align}\]where U1, U2 are rotation gates and f, g are parameter mappings.
- Return type:
- get_mutable_copy()#
Returns a copy of itself that can be modified.
Use this method when you want to get a new circuit based on an existing circuit but don’t want to modify it.
- Return type:
- combine(gates)#
Create a new parametric circuit with itself and the given gates or an unbound parametric circuit combined.
All parameters in self and the other are treated as different ones. I.e. even if those two share the same instance of a parameter, it is copied into two independent parameters.
- Parameters:
gates (circuit.circuit.GateSequence | UnboundParametricQuantumCircuitBase) –
- Return type:
- abstract freeze()#
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.
- Return type:
- bind_parameters(params)#
Returns a new circuit with the parameters assigned concrete values.
This method does not modify self but returns a newly created circuit.
- Parameters:
params (Sequence[float]) –
- Return type:
- property parameter_count: int#
- class UnboundParametricQuantumCircuit(qubit_count, cbit_count=0)#
Bases:
UnboundParametricQuantumCircuitBase,MutableUnboundParametricQuantumCircuitProtocolA mutable unbound parametric quantum circuit.
This class is for parametric circuits where all parametric gates have independent parameters, i.e., no two parametric gates share the same parameter. If you want to make dependency between parameters, see
LinearMappedUnboundParametricQuantumCircuit.- Parameters:
qubit_count (int) –
cbit_count (int) –
- property qubit_count: int#
Number of qubits involved in the circuit.
- property cbit_count: int#
Number of classical bits involved in the circuit.
- add_gate(gate, gate_index=None)#
Add a (non-parametric) quantum gate to the circuit.
- Parameters:
gate (QuantumGate) –
gate_index (int | None) –
- Return type:
None
- add_ParametricRX_gate(qubit_index)#
Add a parametric RX gate to the circuit.
- Parameters:
qubit_index (int) –
- Return type:
- add_ParametricPauliRotation_gate(target_indices, pauli_ids)#
Add a parametric Pauli rotation gate to the circuit.
- Parameters:
target_indices (Sequence[int]) –
pauli_ids (Sequence[int]) –
- Return type:
- extend(gates)#
Extend the parametric circuit with given gates or an unbound parametric circuit.
All parameters in self and the other are treated as different ones. I.e. even if those two share the same instance of a parameter, it is copied into two independent parameters.
- Parameters:
gates (circuit.circuit.GateSequence | UnboundParametricQuantumCircuitBase) –
- Return type:
None
- freeze()#
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.
- Return type:
- class ImmutableUnboundParametricQuantumCircuit(circuit)#
Bases:
UnboundParametricQuantumCircuitBaseAn immutable unbound parametric quantum circuit.
This class is for parametric circuits where all parametric gates have independent parameters, i.e., no two parametric gates share the same parameter. If you want to make dependency between parameters, see
ImmutableLinearMappedUnboundParametricQuantumCircuit.- Parameters:
circuit (UnboundParametricQuantumCircuitBase) –
- property qubit_count: int#
Number of qubits involved in the circuit.
- property cbit_count: int#
Number of classical bits involved in the circuit.
- freeze()#
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.
- Return type:
- class ImmutableBoundParametricQuantumCircuit(circuit, parameter_map)#
Bases:
ImmutableQuantumCircuitAn immutable “bound” parametric quantum circuit, i.e. a parametric circuit with its parameters assigned concrete values.
- Parameters:
circuit (UnboundParametricQuantumCircuitBase) –
parameter_map (Mapping[Parameter, float]) –
- property gates: Sequence[QuantumGate]#
Returns the gate sequence of the circuit.
- freeze()#
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.
- Return type:
- LinearParameterFunction#
A type representing a linear (affine) function of parameters. It is an alias for mapping from
Parameterto float coefficients. A constant term can be represented as a coefficient forCONST.
- class LinearParameterMapping(in_params=(), out_params=(), mapping={})#
Bases:
ParameterMappingBaseA
ParameterMappingrepresenting a linear (affine) transformation of parameters.The mapping is represented as a
MappingfromParameters toParameterOrLinearFunctions. For example, if the mapping is defined as:\[\begin{split}\begin{align} \theta^\text{(out)}_0 &= 0.1\theta^\text{(in)}_1 + 0.2, \\ \theta^\text{(out)}_1 &= 0.3\theta^\text{(in)}_0 + 0.4\theta^\text{(in)}_1, \end{align}\end{split}\]the
mappingargument should be as the following:{ out_param_0: { in_param_1: 0.1, CONST: 0.2 }, out_param_1: { in_param_0: 0.3, in_param_1: 0.4 }, }
where
in_param_0(1)andout_param_0(1)are input and outputParameterinstances respectively.- Parameters:
- with_data_updated(*, in_params_addition=(), out_params_addition=(), mapping_update={})#
- Parameters:
- Return type:
- property mapper: circuit.parameter_mapping.Mapper#
- property is_trivial_mapping: bool#
Returns if the mapping is trivial one-to-one mapping (Identity function).
- get_derivatives()#
Returns a sequence of
LinearParameterMappings of derivatives of the originalLinearParameterMappingwith respect to each input parameter.Since the original mapping is linear, the returned mappings only contains constant terms. For example, for the linear mapping defined in the docstring of
LinearParameterMapping, the returned derivatives are as follows:\[\begin{split}\begin{align} \frac{\partial f}{\partial \theta^\text{(in)}_0} &= (0, 0.3)\\ \frac{\partial f}{\partial \theta^\text{(in)}_1} &= (0.1, 0.4) \end{align}\end{split}\]- Return type:
Sequence[LinearParameterMapping]
- combine(other)#
- Parameters:
other (LinearParameterMapping) –
- Return type:
- class LinearMappedUnboundParametricQuantumCircuitBase(*args, **kwargs)#
Bases:
UnboundParametricQuantumCircuitProtocol,ABCA base class for parametric quantum circuits where parameters of parametric gates are given by linear functions of circuit parameters.
- property qubit_count: int#
Number of qubits involved in the circuit.
- property cbit_count: int#
Number of classical bits involved in the circuit.
- property parameter_count: int#
- property depth: int#
Returns circuit depth.
- property gates: Sequence[QuantumGate | ParametricQuantumGate]#
Returns the gate sequence of the circuit.
- property has_trivial_parameter_mapping: bool#
Returns if the input parameters are used for parametric gates without any conversions.
Note that some parametric circuit, e.g.
LinearMappedUnboundParametricQuantumCircuit, can have non-trivial mapping of the parameters.
- property param_mapping: LinearParameterMapping#
Returns the parameter mapping of the circuit.
- primitive_circuit()#
Returns the parametric circuit where each gate has an independent parameter.
Note that some parametric circuit, e.g.
LinearMappedUnboundParametricQuantumCircuit, can have non-trivial mapping of the parameters. In this “primitive circuit”, however, gate parameters are treated as independent, even if those in the original circuit depend on the same parameters. For example, if the parametric circuit is defined as:\[\begin{align} U_1(f(\theta_1, \theta_2)) U_2(g(\theta_1, \theta_2)) \end{align}\]the primitive circuit should be as the following:
\[\begin{align} U_1(\psi_1) U_2(\psi_2) \end{align}\]where U1, U2 are rotation gates and f, g are parameter mappings.
- Return type:
- get_mutable_copy()#
Returns a copy of itself that can be modified.
Use this method when you want to get a new circuit based on an existing circuit but don’t want to modify it.
- Return type:
- combine(gates)#
- Parameters:
gates (circuit.circuit.GateSequence | UnboundParametricQuantumCircuitProtocol) –
- Return type:
- bind_parameters(params)#
Returns a new circuit with the parameters assigned concrete values.
This method does not modify self but returns a newly created circuit.
- Parameters:
params (Sequence[float]) –
- Return type:
- class LinearMappedUnboundParametricQuantumCircuit(qubit_count, cbit_count=0)#
Bases:
LinearMappedUnboundParametricQuantumCircuitBase,MutableUnboundParametricQuantumCircuitProtocolA mutable parametric quantum circuit where parameters of parametric gates are given by linear functions of circuit parameters.
- Parameters:
qubit_count (int) –
cbit_count (int) –
- add_parameters(*names)#
Add new parameters for the circuit.
Newly created parameters are returned as a sequence. Before adding a parametric gate to the circuit, all used parameters should be added by this method or
add_parameter().- Parameters:
names (str) –
- Return type:
Sequence[Parameter]
- add_parameter(name)#
Add a new parameter for the circuit.
Before adding a parametric gate to the circuit, all used parameters should be added by this method or
add_parametesr().- Parameters:
name (str) –
- Return type:
- add_gate(gate, gate_index=None)#
Add a (non-parametric) quantum gate to the circuit.
- Parameters:
gate (QuantumGate) –
gate_index (int | None) –
- Return type:
None
- add_ParametricRX_gate(qubit_index, angle)#
Add a parametric RX gate to the circuit.
- Parameters:
qubit_index (int) –
angle (circuit.parameter_mapping.ParameterOrLinearFunction) –
- Return type:
None
- add_ParametricRY_gate(qubit_index, angle)#
Add a parametric RY gate to the circuit.
- Parameters:
qubit_index (int) –
angle (circuit.parameter_mapping.ParameterOrLinearFunction) –
- Return type:
None
- add_ParametricRZ_gate(qubit_index, angle)#
Add a parametric RZ gate to the circuit.
- Parameters:
qubit_index (int) –
angle (circuit.parameter_mapping.ParameterOrLinearFunction) –
- Return type:
None
- add_ParametricPauliRotation_gate(qubit_indices, pauli_ids, angle)#
Add a parametric Pauli rotation gate to the circuit.
- Parameters:
qubit_indices (Sequence[int]) –
pauli_ids (Sequence[int]) –
angle (circuit.parameter_mapping.ParameterOrLinearFunction) –
- Return type:
None
- extend(gates)#
Extend the parametric circuit with given gates or a linear mapped unbound parametric circuit.
If the two linear mapped parametric circuit share the same parameters, they are treated as the same parameters, in contrast to the case of
UnboundParametricQuantumCircuit.- Parameters:
gates (circuit.circuit.GateSequence | UnboundParametricQuantumCircuitProtocol) –
- Return type:
None
- freeze()#
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.
- Return type:
- class ImmutableLinearMappedUnboundParametricQuantumCircuit(circuit)#
Bases:
LinearMappedUnboundParametricQuantumCircuitBaseAn immutable parametric quantum circuit where parameters of parametric gates are given by linear functions of circuit parameters.
- Parameters:
circuit (LinearMappedUnboundParametricQuantumCircuitBase) –
- freeze()#
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.
- Return type:
- inverse_gate(gate)#
- Parameters:
gate (QuantumGate) –
- Return type:
- inverse_circuit(circuit)#
- Parameters:
circuit (NonParametricQuantumCircuit) –
- Return type:
- is_clifford(gate, rtol=1e-05, atol=1e-08)#
Returns True if the input gate is Clifford, otherwise False. In the case of a rotation gate, whether it is a Clifford gate or not is determined by whether the rotation angle is in the Clifford angle set \(\{\pi n /2| n\in\mathbb{Z}\}\) or not. This can be applied only to the gates in the set CLIFFORD_GATE_NAMES and currently implemented rotation gates: {RX, RY, RZ, U1, U2, U3, PauliRotation}. Since newly defined gates (e.g. U’(a, b) = RZ(2*a)RY(a+2b)) may return the wrong result, in this case this function currently returns a NotImplementedError.
- Parameters:
gate (QuantumGate) – A gate to be checked whether Clifford or not.
rtol (float) – The relative tolerance parameter determines how close the angle of rotation is to the angle in the Clifford angle set.
atol (float) – The absolute tolerance parameter determines how close the angle of rotation is to the angle in the Clifford angle set.
- Return type:
bool
Subpackages#
- quri_parts.circuit.noise package
AmplitudeDampingNoiseBitFlipNoiseBitPhaseFlipNoiseCircuitNoiseInstructionProbabilisticNoiseDepolarizingNoiseDepthIntervalNoiseGateIntervalNoiseGateNoiseInstructionGeneralDepolarizingNoiseKrausNoiseAbstractKrausNoiseMeasurementNoiseNoiseModelNoiseInstructionPauliNoisePhaseAmplitudeDampingNoisePhaseAmplitudeDampingNoise.phase_damping_ratePhaseAmplitudeDampingNoise.amplitude_damping_ratePhaseAmplitudeDampingNoise.excited_state_populationPhaseAmplitudeDampingNoise.kraus_operatorsPhaseAmplitudeDampingNoise.namePhaseAmplitudeDampingNoise.qubit_countPhaseAmplitudeDampingNoise.paramsPhaseAmplitudeDampingNoise.qubit_indicesPhaseAmplitudeDampingNoise.target_gates
PhaseDampingNoisePhaseFlipNoiseQubitNoisePairResetNoiseThermalRelaxationNoiseThermalRelaxationNoise.t1ThermalRelaxationNoise.t2ThermalRelaxationNoise.gate_timeThermalRelaxationNoise.excited_state_populationThermalRelaxationNoise.kraus_operatorsThermalRelaxationNoise.nameThermalRelaxationNoise.qubit_countThermalRelaxationNoise.paramsThermalRelaxationNoise.qubit_indicesThermalRelaxationNoise.target_gates
CircuitNoiseResolverProtocol- Submodules
- quri_parts.circuit.noise.noise_instruction module
NoiseInstructionCircuitNoiseInstructionCircuitNoiseResolverProtocolGateNoiseInstructionGateIntervalNoiseDepthIntervalNoiseMeasurementNoiseBitFlipNoisePhaseFlipNoiseBitPhaseFlipNoiseDepolarizingNoisePauliNoiseGeneralDepolarizingNoiseProbabilisticNoiseAbstractKrausNoiseKrausNoiseResetNoisePhaseDampingNoiseAmplitudeDampingNoisePhaseAmplitudeDampingNoiseThermalRelaxationNoise
- quri_parts.circuit.noise.noise_model module
- quri_parts.circuit.noise.noise_instruction module
- quri_parts.circuit.topology package
- quri_parts.circuit.transpile package
CliffordConversionTranspilerCliffordRZSetTranspilerCliffordApproximationTranspilerCircuitTranspilerProtocolCNOT2CZHTranspilerCZ2CNOTHTranspilerCZ2RXRYCNOTTranspilerCNOTHCNOTFusingTranspilerFuseRotationTranspilerGateDecomposerGateKindDecomposerGateSetConversionTranspilerH2RXRYTranspilerH2RZSqrtXTranspilerIdentityEliminationTranspilerIdentityInsertionTranspilerIdentity2RZTranspilerNormalizeRotationTranspilerParallelDecomposerPauliDecomposeTranspilerPauliRotationDecomposeTranspilerQubitRemappingTranspilerRotationConversionTranspilerRX2RYRZTranspilerRX2RZHTranspilerRY2RXRZTranspilerRY2RZHTranspilerRZ2RXRYTranspilerRZSetTranspiler()RotationSetTranspiler()Rotation2NamedTranspilerRX2RZSqrtXTranspilerRY2RZSqrtXTranspilerRX2NamedTranspilerRY2NamedTranspilerRZ2NamedTranspilerSequentialTranspilerS2RZTranspilerSdag2RZTranspilerSingleQubitUnitaryMatrix2RYRZTranspilerSqrtX2RXTranspilerSqrtX2RZHTranspilerSqrtXdag2RXTranspilerSqrtXdag2RZSqrtXTranspilerSqrtY2RYTranspilerSqrtY2RZSqrtXTranspilerSqrtYdag2RYTranspilerSqrtYdag2RZSqrtXTranspilerSWAP2CNOTTranspilerSTARSetTranspiler()T2RZTranspilerTdag2RZTranspilerTOFFOLI2HTTdagCNOTTranspilerTwoQubitUnitaryMatrixKAKTranspilerU1ToRZTranspilerU2ToRXRZTranspilerU2ToRZSqrtXTranspilerU3ToRXRZTranspilerU3ToRZSqrtXTranspilerX2HZTranspilerX2RXTranspilerX2SqrtXTranspilerY2RYTranspilerY2RZXTranspilerZ2HXTranspilerZ2RZTranspilerZeroRotationEliminationTranspilersu2_decompose()su4_decompose()- Submodules
- quri_parts.circuit.transpile.clifford_approximation module
- quri_parts.circuit.transpile.fuse module
- quri_parts.circuit.transpile.gate_kind_decomposer module
CNOT2CZHTranspilerCZ2CNOTHTranspilerCZ2RXRYCNOTTranspilerH2RZSqrtXTranspilerH2RXRYTranspilerIdentity2RZTranspilerRX2RZSqrtXTranspilerRY2RZSqrtXTranspilerS2RZTranspilerSdag2RZTranspilerSqrtX2RXTranspilerSqrtX2RZHTranspilerSqrtXdag2RXTranspilerSqrtXdag2RZSqrtXTranspilerSqrtY2RYTranspilerSqrtY2RZSqrtXTranspilerSqrtYdag2RYTranspilerSqrtYdag2RZSqrtXTranspilerSWAP2CNOTTranspilerT2RZTranspilerTdag2RZTranspilerTOFFOLI2HTTdagCNOTTranspilerU1ToRZTranspilerU2ToRZSqrtXTranspilerU2ToRXRZTranspilerU3ToRZSqrtXTranspilerU3ToRXRZTranspilerX2HZTranspilerX2RXTranspilerX2SqrtXTranspilerY2RZXTranspilerY2RYTranspilerZ2RZTranspilerZ2HXTranspiler
- quri_parts.circuit.transpile.gateset module
- quri_parts.circuit.transpile.identity_manipulation module
- quri_parts.circuit.transpile.multi_pauli_decomposer module
- quri_parts.circuit.transpile.qubit_remapping module
- quri_parts.circuit.transpile.transpiler module
- quri_parts.circuit.transpile.unitary_matrix_decomposer module
- quri_parts.circuit.utils namespace
Submodules#
- quri_parts.circuit.circuit module
is_gate_sequence()QuantumCircuitProtocolMutableQuantumCircuitProtocolMutableQuantumCircuitProtocol.add_gate()MutableQuantumCircuitProtocol.extend()MutableQuantumCircuitProtocol.add_Identity_gate()MutableQuantumCircuitProtocol.add_X_gate()MutableQuantumCircuitProtocol.add_Y_gate()MutableQuantumCircuitProtocol.add_Z_gate()MutableQuantumCircuitProtocol.add_H_gate()MutableQuantumCircuitProtocol.add_S_gate()MutableQuantumCircuitProtocol.add_Sdag_gate()MutableQuantumCircuitProtocol.add_SqrtX_gate()MutableQuantumCircuitProtocol.add_SqrtXdag_gate()MutableQuantumCircuitProtocol.add_SqrtY_gate()MutableQuantumCircuitProtocol.add_SqrtYdag_gate()MutableQuantumCircuitProtocol.add_T_gate()MutableQuantumCircuitProtocol.add_Tdag_gate()MutableQuantumCircuitProtocol.add_U1_gate()MutableQuantumCircuitProtocol.add_U2_gate()MutableQuantumCircuitProtocol.add_U3_gate()MutableQuantumCircuitProtocol.add_RX_gate()MutableQuantumCircuitProtocol.add_RY_gate()MutableQuantumCircuitProtocol.add_RZ_gate()MutableQuantumCircuitProtocol.add_CNOT_gate()MutableQuantumCircuitProtocol.add_CZ_gate()MutableQuantumCircuitProtocol.add_SWAP_gate()MutableQuantumCircuitProtocol.add_TOFFOLI_gate()MutableQuantumCircuitProtocol.add_UnitaryMatrix_gate()MutableQuantumCircuitProtocol.add_SingleQubitUnitaryMatrix_gate()MutableQuantumCircuitProtocol.add_TwoQubitUnitaryMatrix_gate()MutableQuantumCircuitProtocol.add_Pauli_gate()MutableQuantumCircuitProtocol.add_PauliRotation_gate()MutableQuantumCircuitProtocol.measure()
NonParametricQuantumCircuitQuantumCircuitImmutableQuantumCircuit
- quri_parts.circuit.circuit_linear_mapped module
LinearMappedUnboundParametricQuantumCircuitBaseLinearMappedUnboundParametricQuantumCircuitBase.qubit_countLinearMappedUnboundParametricQuantumCircuitBase.cbit_countLinearMappedUnboundParametricQuantumCircuitBase.parameter_countLinearMappedUnboundParametricQuantumCircuitBase.depthLinearMappedUnboundParametricQuantumCircuitBase.gatesLinearMappedUnboundParametricQuantumCircuitBase.has_trivial_parameter_mappingLinearMappedUnboundParametricQuantumCircuitBase.param_mappingLinearMappedUnboundParametricQuantumCircuitBase.primitive_circuit()LinearMappedUnboundParametricQuantumCircuitBase.get_mutable_copy()LinearMappedUnboundParametricQuantumCircuitBase.combine()LinearMappedUnboundParametricQuantumCircuitBase.bind_parameters()
LinearMappedUnboundParametricQuantumCircuitLinearMappedUnboundParametricQuantumCircuit.add_parameters()LinearMappedUnboundParametricQuantumCircuit.add_parameter()LinearMappedUnboundParametricQuantumCircuit.add_gate()LinearMappedUnboundParametricQuantumCircuit.add_ParametricRX_gate()LinearMappedUnboundParametricQuantumCircuit.add_ParametricRY_gate()LinearMappedUnboundParametricQuantumCircuit.add_ParametricRZ_gate()LinearMappedUnboundParametricQuantumCircuit.add_ParametricPauliRotation_gate()LinearMappedUnboundParametricQuantumCircuit.extend()LinearMappedUnboundParametricQuantumCircuit.freeze()
ImmutableLinearMappedUnboundParametricQuantumCircuit
- quri_parts.circuit.circuit_parametric module
UnboundParametricQuantumCircuitProtocolUnboundParametricQuantumCircuitProtocol.bind_parameters()UnboundParametricQuantumCircuitProtocol.freeze()UnboundParametricQuantumCircuitProtocol.get_mutable_copy()UnboundParametricQuantumCircuitProtocol.primitive_circuit()UnboundParametricQuantumCircuitProtocol.parameter_countUnboundParametricQuantumCircuitProtocol.gatesUnboundParametricQuantumCircuitProtocol.has_trivial_parameter_mappingUnboundParametricQuantumCircuitProtocol.param_mappingUnboundParametricQuantumCircuitProtocol.bind_parameters_by_dict()
MutableUnboundParametricQuantumCircuitProtocolUnboundParametricQuantumCircuitBaseUnboundParametricQuantumCircuitBase.depthUnboundParametricQuantumCircuitBase.gatesUnboundParametricQuantumCircuitBase.gates_and_paramsUnboundParametricQuantumCircuitBase.has_trivial_parameter_mappingUnboundParametricQuantumCircuitBase.param_mappingUnboundParametricQuantumCircuitBase.primitive_circuit()UnboundParametricQuantumCircuitBase.get_mutable_copy()UnboundParametricQuantumCircuitBase.combine()UnboundParametricQuantumCircuitBase.freeze()UnboundParametricQuantumCircuitBase.bind_parameters()UnboundParametricQuantumCircuitBase.parameter_count
UnboundParametricQuantumCircuitUnboundParametricQuantumCircuit.qubit_countUnboundParametricQuantumCircuit.cbit_countUnboundParametricQuantumCircuit.add_gate()UnboundParametricQuantumCircuit.add_ParametricRX_gate()UnboundParametricQuantumCircuit.add_ParametricRY_gate()UnboundParametricQuantumCircuit.add_ParametricRZ_gate()UnboundParametricQuantumCircuit.add_ParametricPauliRotation_gate()UnboundParametricQuantumCircuit.extend()UnboundParametricQuantumCircuit.freeze()
ImmutableUnboundParametricQuantumCircuitImmutableBoundParametricQuantumCircuit
- quri_parts.circuit.clifford_gate module
- quri_parts.circuit.gate module
- quri_parts.circuit.gate_names module
- quri_parts.circuit.gates module
IdentityFactoryIdentityXFactoryXYFactoryYZFactoryZHFactoryHSFactorySSdagFactorySdagSqrtXFactorySqrtXSqrtXdagFactorySqrtXdagSqrtYFactorySqrtYSqrtYdagFactorySqrtYdagTFactoryTTdagFactoryTdagRXFactoryRXRYFactoryRYRZFactoryRZU1FactoryU1U2FactoryU2U3FactoryU3CNOTFactoryCNOTCZFactoryCZSWAPFactorySWAPTOFFOLIFactoryTOFFOLIUnitaryMatrixFactoryUnitaryMatrixSingleQubitUnitaryMatrixFactorySingleQubitUnitaryMatrixTwoQubitUnitaryMatrixFactoryTwoQubitUnitaryMatrixPauliFactoryPauliPauliRotationFactoryPauliRotationParametricRXFactoryParametricRXParametricRYFactoryParametricRYParametricRZFactoryParametricRZParametricPauliRotationFactoryParametricPauliRotationMeasurementFactoryMeasurement
- quri_parts.circuit.inverse module
- quri_parts.circuit.parameter module
- quri_parts.circuit.parameter_mapping module
- quri_parts.circuit.parameter_shift module