quri_parts.circuit.circuit_linear_mapped module#

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

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:

ImmutableUnboundParametricQuantumCircuit

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:

LinearMappedUnboundParametricQuantumCircuit

combine(gates)#
Parameters:

gates (circuit.circuit.GateSequence | UnboundParametricQuantumCircuitProtocol) –

Return type:

LinearMappedUnboundParametricQuantumCircuit

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:

ImmutableBoundParametricQuantumCircuit

class LinearMappedUnboundParametricQuantumCircuit(qubit_count, cbit_count=0)#

Bases: LinearMappedUnboundParametricQuantumCircuitBase, MutableUnboundParametricQuantumCircuitProtocol

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

Parameter

add_gate(gate, gate_index=None)#

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

Parameters:
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:

ImmutableLinearMappedUnboundParametricQuantumCircuit

class ImmutableLinearMappedUnboundParametricQuantumCircuit(circuit)#

Bases: LinearMappedUnboundParametricQuantumCircuitBase

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

ImmutableLinearMappedUnboundParametricQuantumCircuit