quri_parts.circuit package#

class quri_parts.circuit.QuantumGate(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]] = ())#

Bases: NamedTuple

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

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 quri_parts.circuit.ParametricQuantumGate(name: str, target_indices: Sequence[int], control_indices: Sequence[int] = (), pauli_ids: Sequence[int] = ())#

Bases: NamedTuple

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

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 quri_parts.circuit.QuantumCircuitProtocol(*args, **kwargs)#

Bases: Protocol

Interface 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 quri_parts.circuit.MutableQuantumCircuitProtocol(*args, **kwargs)#

Bases: QuantumCircuitProtocol, Protocol

Interface 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 method add_gate().

abstract add_gate(gate: QuantumGate, gate_index: int | None = None) None#

Add a (non-parametric) quantum gate to the circuit.

abstract extend(gates: NonParametricQuantumCircuit | Sequence[QuantumGate]) None#

Extend the circuit with given gate sequence.

add_Identity_gate(qubit_index: int) None#

Add an Identity gate to the circuit.

add_X_gate(qubit_index: int) None#

Add an X gate to the circuit.

add_Y_gate(qubit_index: int) None#

Add a Y gate to the circuit.

add_Z_gate(qubit_index: int) None#

Add a Z gate to the circuit.

add_H_gate(qubit_index: int) None#

Add an H gate to the circuit.

add_S_gate(index: int) None#

Add a S gate to the circuit.

add_Sdag_gate(index: int) None#

Add a Sdag gate to the circuit.

add_SqrtX_gate(index: int) None#

Add a SqrtX gate to the circuit.

add_SqrtXdag_gate(index: int) None#

Add a SqrtXdag gate to the circuit.

add_SqrtY_gate(index: int) None#

Add a SqrtY gate to the circuit.

add_SqrtYdag_gate(index: int) None#

Add a SqrtYdag gate to the circuit.

add_T_gate(index: int) None#

Add a T gate to the circuit.

add_Tdag_gate(index: int) None#

Add a Tdag gate to the circuit.

add_U1_gate(index: int, lmd: float) None#

Add an U1 gate to the circuit.

add_U2_gate(index: int, phi: float, lmd: float) None#

Add an U2 gate to the circuit.

add_U3_gate(index: int, theta: float, phi: float, lmd: float) None#

Add an U3 gate to the circuit.

add_RX_gate(index: int, angle: float) None#

Add a RX gate to the circuit.

add_RY_gate(index: int, angle: float) None#

Add a RY gate to the circuit.

add_RZ_gate(index: int, angle: float) None#

Add a RZ gate to the circuit.

add_CNOT_gate(control_index: int, target_index: int) None#

Add a CNOT gate to the circuit.

add_CZ_gate(control_qubit_index: int, target_qubit_index: int) None#

Add a Control-Z gate to the circuit.

add_SWAP_gate(target_index1: int, target_index2: int) None#

Add a SWAP gate to the circuit.

add_TOFFOLI_gate(control_index1: int, control_index2: int, target_index: int) None#

Add a TOFFOLI gate to the circuit.

add_UnitaryMatrix_gate(target_indices: Sequence[int], unitary_matrix: Sequence[Sequence[complex]]) None#

Add a UnitaryMatrix gate to the circuit.

add_SingleQubitUnitaryMatrix_gate(target_index: int, unitary_matrix: Sequence[Sequence[complex]]) None#

Add a single qubit UnitaryMatrix gate to the circuit.

add_TwoQubitUnitaryMatrix_gate(target_index1: int, target_index2: int, unitary_matrix: Sequence[Sequence[complex]]) None#

Add a two qubit UnitaryMatrix gate to the circuit.

add_Pauli_gate(target_indices: Sequence[int], pauli_ids: Sequence[int]) None#

Add a Pauli gate to the circuit.

add_PauliRotation_gate(target_qubits: Sequence[int], pauli_id_list: Sequence[int], angle: float) None#

Add a Pauli rotation gate to the circuit.

measure(qubit_indices: int | Sequence[int], classical_indices: int | Sequence[int]) None#

Adds measurement gate at selected qubits.

class quri_parts.circuit.NonParametricQuantumCircuit(*args, **kwargs)#

Bases: QuantumCircuitProtocol, ABC

A base class for quantum circuits having only non-parametric gates.

This class support + operator with GateSequence.

abstract property gates: Sequence[QuantumGate]#

Returns the gate sequence of the circuit.

property depth: int#

Returns circuit depth.

combine(gates: NonParametricQuantumCircuit | Sequence[QuantumGate]) QuantumCircuit#

Create a new circuit with itself and the given gates combined.

abstract freeze() ImmutableQuantumCircuit#

Returns a “freezed” version of itself.

The “freezed” version is an immutable object and can be reused safely without copying.

abstract get_mutable_copy() QuantumCircuit#

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.

class quri_parts.circuit.QuantumCircuit(qubit_count: int, cbit_count: int = 0, gates: Sequence[QuantumGate] = [])#

Bases: NonParametricQuantumCircuit, MutableQuantumCircuitProtocol

A mutable quantum circuit having only non-parametric gates.

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() ImmutableQuantumCircuit#

Returns a “freezed” version of itself.

The “freezed” version is an immutable object and can be reused safely without copying.

get_mutable_copy() QuantumCircuit#

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.

add_gate(gate: QuantumGate, gate_index: int | None = None) None#

Add a (non-parametric) quantum gate to the circuit.

extend(gates: NonParametricQuantumCircuit | Sequence[QuantumGate]) None#

Extend the circuit with given gate sequence.

class quri_parts.circuit.ImmutableQuantumCircuit(circuit: NonParametricQuantumCircuit)#

Bases: NonParametricQuantumCircuit

An immutable quantum circuit having only non-parametric gates.

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() ImmutableQuantumCircuit#

Returns a “freezed” version of itself.

The “freezed” version is an immutable object and can be reused safely without copying.

get_mutable_copy() QuantumCircuit#

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.

class quri_parts.circuit.Parameter(name: str = '')#

Bases: object

A class representing parameters in parametric quantum circuits.

A Parameter is 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 NamedTuple and 2) define __eq__ method.

class quri_parts.circuit.ParameterMapping(*args, **kwargs)#

Bases: Protocol

ParameterMapping 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 in_params: Sequence[Parameter]#

Returns a sequence of input Parameters.

abstract property out_params: Sequence[Parameter]#

Returns a sequence of output Parameters.

abstract property mapper: Callable[[Mapping[Parameter, float]], Mapping[Parameter, float]]#

Returns a function that maps an input ParameterValueAssignment to an output ParameterValueAssignment (i.e. \(f\)).

It is expected that the function captures the state of ParameterMapping at the time that this property is accessed and does not reflect subsequent changes in the state of the ParameterMapping instance.

abstract property seq_mapper: Callable[[Sequence[float]], Sequence[float]]#

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 ParameterMapping at the time that this property is accessed and does not reflect subsequent changes in the state of the ParameterMapping instance.

get_derivatives() Sequence[ParameterMapping]#

Returns a sequence of ParameterMappings of derivatives of the original ParameterMapping with 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 ParameterMapping docstring.

quri_parts.circuit.CONST = Parameter(name=)#

A placeholder representing a constant term.

class quri_parts.circuit.UnboundParametricQuantumCircuitProtocol(*args, **kwargs)#

Bases: QuantumCircuitProtocol, Protocol

Interface 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: Sequence[float]) ImmutableBoundParametricQuantumCircuit#

Returns a new circuit with the parameters assigned concrete values.

This method does not modify self but returns a newly created circuit.

abstract freeze() UnboundParametricQuantumCircuitProtocol#

Returns a “freezed” version of itself.

The “freezed” version is an immutable object and can be reused safely without copying.

abstract get_mutable_copy() MutableUnboundParametricQuantumCircuitProtocol#

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.

abstract primitive_circuit() ImmutableUnboundParametricQuantumCircuit#

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.

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 quri_parts.circuit.MutableUnboundParametricQuantumCircuitProtocol(*args, **kwargs)#

Bases: UnboundParametricQuantumCircuitProtocol, MutableQuantumCircuitProtocol, Protocol

class quri_parts.circuit.UnboundParametricQuantumCircuitBase(*args, **kwargs)#

Bases: UnboundParametricQuantumCircuitProtocol, ABC

A 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() ImmutableUnboundParametricQuantumCircuit#

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.

get_mutable_copy() UnboundParametricQuantumCircuit#

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.

combine(gates: NonParametricQuantumCircuit | Sequence[QuantumGate] | UnboundParametricQuantumCircuitBase) UnboundParametricQuantumCircuit#

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.

abstract freeze() ImmutableUnboundParametricQuantumCircuit#

Returns a “freezed” version of itself.

The “freezed” version is an immutable object and can be reused safely without copying.

bind_parameters(params: Sequence[float]) ImmutableBoundParametricQuantumCircuit#

Returns a new circuit with the parameters assigned concrete values.

This method does not modify self but returns a newly created circuit.

property parameter_count: int#
class quri_parts.circuit.UnboundParametricQuantumCircuit(qubit_count: int, cbit_count: int = 0)#

Bases: UnboundParametricQuantumCircuitBase, MutableUnboundParametricQuantumCircuitProtocol

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

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: QuantumGate, gate_index: int | None = None) None#

Add a (non-parametric) quantum gate to the circuit.

add_ParametricRX_gate(qubit_index: int) Parameter#

Add a parametric RX gate to the circuit.

add_ParametricRY_gate(qubit_index: int) Parameter#
add_ParametricRZ_gate(qubit_index: int) Parameter#
add_ParametricPauliRotation_gate(target_indices: Sequence[int], pauli_ids: Sequence[int]) Parameter#

Add a parametric Pauli rotation gate to the circuit.

extend(gates: NonParametricQuantumCircuit | Sequence[QuantumGate] | UnboundParametricQuantumCircuitBase) None#

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.

freeze() ImmutableUnboundParametricQuantumCircuit#

Returns a “freezed” version of itself.

The “freezed” version is an immutable object and can be reused safely without copying.

class quri_parts.circuit.ImmutableUnboundParametricQuantumCircuit(circuit: UnboundParametricQuantumCircuitBase)#

Bases: UnboundParametricQuantumCircuitBase

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

property qubit_count: int#

Number of qubits involved in the circuit.

property cbit_count: int#

Number of classical bits involved in the circuit.

freeze() ImmutableUnboundParametricQuantumCircuit#

Returns a “freezed” version of itself.

The “freezed” version is an immutable object and can be reused safely without copying.

class quri_parts.circuit.ImmutableBoundParametricQuantumCircuit(circuit: UnboundParametricQuantumCircuitBase, parameter_map: Mapping[Parameter, float])#

Bases: ImmutableQuantumCircuit

An immutable “bound” parametric quantum circuit, i.e. a parametric circuit with its parameters assigned concrete values.

property gates: Sequence[QuantumGate]#

Returns the gate sequence of the circuit.

freeze() ImmutableBoundParametricQuantumCircuit#

Returns a “freezed” version of itself.

The “freezed” version is an immutable object and can be reused safely without copying.

quri_parts.circuit.LinearParameterFunction#

A type representing a linear (affine) function of parameters. It is an alias for mapping from Parameter to float coefficients. A constant term can be represented as a coefficient for CONST.

class quri_parts.circuit.LinearParameterMapping(in_params: Sequence[Parameter] = (), out_params: Sequence[Parameter] = (), mapping: Mapping[Parameter, Parameter | Mapping[Parameter, float]] = {})#

Bases: ParameterMappingBase

A ParameterMapping representing a linear (affine) transformation of parameters.

The mapping is represented as a Mapping from Parameters to ParameterOrLinearFunctions. 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 mapping argument 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) and out_param_0(1) are input and output Parameter instances respectively.

with_data_updated(*, in_params_addition: Sequence[Parameter] = (), out_params_addition: Sequence[Parameter] = (), mapping_update: Mapping[Parameter, Parameter | Mapping[Parameter, float]] = {}) LinearParameterMapping#
property in_params: Sequence[Parameter]#
property out_params: Sequence[Parameter]#
property mapping: Mapping[Parameter, Parameter | Mapping[Parameter, float]]#
property mapper: Callable[[Mapping[Parameter, float]], Mapping[Parameter, float]]#
property is_trivial_mapping: bool#

Returns if the mapping is trivial one-to-one mapping (Identity function).

get_derivatives() Sequence[LinearParameterMapping]#

Returns a sequence of LinearParameterMappings of derivatives of the original LinearParameterMapping with 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}\]
combine(other: LinearParameterMapping) LinearParameterMapping#
class quri_parts.circuit.LinearMappedUnboundParametricQuantumCircuitBase(*args, **kwargs)#

Bases: UnboundParametricQuantumCircuitProtocol, ABC

A 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() ImmutableUnboundParametricQuantumCircuit#

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.

get_mutable_copy() LinearMappedUnboundParametricQuantumCircuit#

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.

combine(gates: NonParametricQuantumCircuit | Sequence[QuantumGate] | UnboundParametricQuantumCircuitProtocol) LinearMappedUnboundParametricQuantumCircuit#
bind_parameters(params: Sequence[float]) ImmutableBoundParametricQuantumCircuit#

Returns a new circuit with the parameters assigned concrete values.

This method does not modify self but returns a newly created circuit.

class quri_parts.circuit.LinearMappedUnboundParametricQuantumCircuit(qubit_count: int, cbit_count: int = 0)#

Bases: LinearMappedUnboundParametricQuantumCircuitBase, MutableUnboundParametricQuantumCircuitProtocol

A mutable parametric quantum circuit where parameters of parametric gates are given by linear functions of circuit parameters.

add_parameters(*names: str) Sequence[Parameter]#

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

add_parameter(name: str) Parameter#

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

add_gate(gate: QuantumGate, gate_index: int | None = None) None#

Add a (non-parametric) quantum gate to the circuit.

add_ParametricRX_gate(qubit_index: int, angle: Parameter | Mapping[Parameter, float]) None#

Add a parametric RX gate to the circuit.

add_ParametricRY_gate(qubit_index: int, angle: Parameter | Mapping[Parameter, float]) None#

Add a parametric RY gate to the circuit.

add_ParametricRZ_gate(qubit_index: int, angle: Parameter | Mapping[Parameter, float]) None#

Add a parametric RZ gate to the circuit.

add_ParametricPauliRotation_gate(qubit_indices: Sequence[int], pauli_ids: Sequence[int], angle: Parameter | Mapping[Parameter, float]) None#

Add a parametric Pauli rotation gate to the circuit.

extend(gates: NonParametricQuantumCircuit | Sequence[QuantumGate] | UnboundParametricQuantumCircuitProtocol) None#

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.

freeze() ImmutableLinearMappedUnboundParametricQuantumCircuit#

Returns a “freezed” version of itself.

The “freezed” version is an immutable object and can be reused safely without copying.

class quri_parts.circuit.ImmutableLinearMappedUnboundParametricQuantumCircuit(circuit: LinearMappedUnboundParametricQuantumCircuitBase)#

Bases: LinearMappedUnboundParametricQuantumCircuitBase

An immutable parametric quantum circuit where parameters of parametric gates are given by linear functions of circuit parameters.

freeze() ImmutableLinearMappedUnboundParametricQuantumCircuit#

Returns a “freezed” version of itself.

The “freezed” version is an immutable object and can be reused safely without copying.

quri_parts.circuit.inverse_gate(gate: QuantumGate) QuantumGate#
quri_parts.circuit.inverse_circuit(circuit: NonParametricQuantumCircuit) QuantumCircuit#
quri_parts.circuit.is_clifford(gate: QuantumGate, rtol: float = 1e-05, atol: float = 1e-08) bool#

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 – A gate to be checked whether Clifford or not.

  • rtol – The relative tolerance parameter determines how close the angle of rotation is to the angle in the Clifford angle set.

  • atol – The absolute tolerance parameter determines how close the angle of rotation is to the angle in the Clifford angle set.

Subpackages#

Submodules#