quri_parts.qulacs.circuit.compiled_circuit module#

compile_circuit(circuit)#

Compiles a quri-parts circuit into an ImmutableQuantumCircuit that holds the corresponding qulacs circuit on memory. The qulacs circuit can be accessed by the .qulacs_circuit property.

Example:

>>> circuit = QuantumCircuit(2)
>>> circuit.add_X_gate(0)
>>> circuit.add_X_gate(1)

Get compiled circuit

>>> compiled_circuit = compile_circuit(circuit)
>>> compiled_qulacs_circuit = compiled_circuit.qulacs_circuit
Parameters:

circuit (NonParametricQuantumCircuit) –

Return type:

_QulacsCircuit

compile_parametric_circuit(circuit: UnboundParametricQuantumCircuit) _QulacsUnboundParametricCircuit#
compile_parametric_circuit(circuit: LinearMappedUnboundParametricQuantumCircuit) _QulacsLinearMappedUnboundParametricCircuit

Compiles a:

  • quri-parts UnboundParametricQuantumCircuit into an

    ImmutableUnboundParametricQuantumCircuit that holds the corresponding qulacs parametric circuit on memory.

  • quri-parts LinearMappedUnboundParametricQuantumCircuit into an

    ImmutableUnboundParametricQuantumCircuit that holds the corresponding qulacs parametric circuit on memory.

The qulacs circuit can be accessed by the .qulacs_circuit property.

The parameter mapper that maps the quri-parts circuit parameters to qulacs parametric circuit parameters can be accessed by the .param_mapper property.

Example:

>>> parametric_circuit = UnboundParametricQuantumCircuit(2)
>>> parametric_circuit.add_ParametricRX_gate(0)
>>> parametric_circuit.add_ParametricRX_gate(1)
  1. Get compiled parametric circuit

>>> compiled_parametric_circuit = compile_circuit(circuit)
>>> compiled_qulacs_circuit = compiled_circuit.qulacs_circuit
  1. Get qulacs circuit parameters

>>> param_mapper = compiled_circuit.param_mapper
>>> quri_parts_circuit_param = [0, 1]
>>> qulacs_circuit_param = param_mapper(quri_parts_circuit_param)