modules.applications.qml.qleet.interface.circuit.CircuitDescriptor
- class CircuitDescriptor(circuit: QuantumCircuit, params: List[Symbol | Parameter], cost_function: PauliList | None = None)
Bases:
objectThe interface for users to provide a circuit in any framework and visualize it in qLEET.
It consists of 3 parts: * Circuit: which has the full ansatz preparation from the start where * Params: list of parameters which are used to parameterize the circuit * Cost Function: presently a pauli string, which we measure to get the
output we are optimizing over
Combined they form the full the parameterized quantum circuit from the initial qubits to the end measurement.
- __init__(circuit: QuantumCircuit, params: List[Symbol | Parameter], cost_function: PauliList | None = None)
Constructor for the CircuitDescriptor
- Parameters:
circuit (Circuit in any supported library) -- The full circuit which generates the required quantum state
params (list[sympy.Symbol]) -- The list of parameters to optimize over
cost_function (PauliSum in any supported library) -- The measurement operation as a PauliString
If you are not providing the full list of parameters of the circuit because you don't want to optimize over some of those parameters, because use a Parameter Resolver to resolve those parameter values before you pass in the lists. The list of parameters passed in here ought to be complete.
Methods
__init__(circuit, params[, cost_function])Constructor for the CircuitDescriptor
from_qasm(qasm_str, params, cost_function[, ...])Generate the descriptor from OpenQASM string
Attributes
Returns the backend in which the user had provided the circuit.
Get the number of qubits for a circuit :return: the number of qubits in the circuit :rtype: int :raises ValueError: if unsupported circuit framework is given
The list of sympy symbols to resolve as parameters, will be swept from 0 to 2*pi :return: list of parameters
Get the circuit in qiskit :return: the qiskit representation of the circuit :rtype: qiskit.QuantumCircuit
- property default_backend: str
Returns the backend in which the user had provided the circuit. :returns: The name of the default backend :rtype: str :raises ValueError: if the given circuit is not from a supported library
- classmethod from_qasm(qasm_str: str, params: List[Symbol | Parameter], cost_function: PauliList | None, backend: str = 'qiskit')
Generate the descriptor from OpenQASM string
- Parameters:
qasm_str (str) -- OpenQASM string for each part of the circuit
params (list[sympy.Symbol]) -- list of sympy symbols which act as parameters for the PQC
cost_function (PauliSum) -- pauli-string operator to implement cost function
backend (str) -- backend for the circuit descriptor objects
- Returns:
The CircuitDescriptor object
- Return type:
- Raises:
ValueError -- if one of the 3 supported backends is not the input
- property num_qubits: int
Get the number of qubits for a circuit :return: the number of qubits in the circuit :rtype: int :raises ValueError: if unsupported circuit framework is given
- property parameters: List[Symbol | Parameter]
The list of sympy symbols to resolve as parameters, will be swept from 0 to 2*pi :return: list of parameters
- property qiskit_circuit: QuantumCircuit
Get the circuit in qiskit :return: the qiskit representation of the circuit :rtype: qiskit.QuantumCircuit