LLY-DML is part of the LILY project and is a Quantum Machine Learning model. It uses so-called L-Gates. These gates are Machine Learning gates that modify their state based on an input to map to a desired state of an input.
The Circuit class creates a quantum circuit that uses special L-Gates, consisting of training and activation phases. These L-Gates are applied for each depth and each qubit. The class also provides functions to measure the circuit, either once or repeatedly, until every state has been observed at least once.
Attributes:
qubits (Integer): The number of qubits in the quantum circuit.
depth (Integer): The depth of the circuit, i.e., how many L-Gates are applied to each qubit.
training_phases (Matrix): A matrix containing the training phases for each L-Gate. Each phase is defined per depth and qubit.
activation_phases (Matrix): A matrix containing the activation phases for each L-Gate. Each phase is defined per depth and qubit.
circuit (QuantumCircuit): The quantum circuit containing the L-Gates and measurements.
Method: __init__
Purpose:
Initializes the Circuit class with the number of qubits, the circuit's depth, and the training and activation phases for the L-Gates.
Input Parameters:
qubits (Integer): The number of qubits.
depth (Integer): The depth of the circuit.
training_phases (Matrix): The training phases as a matrix.
activation_phases (Matrix): The activation phases as a matrix.
Workflow:
The class stores the provided parameters and sets the attribute values.
The quantum circuit (circuit) is initialized as None to be later created in the create method.
Method: create
Purpose:
Creates the quantum circuit with L-Gates based on the provided training and activation phases. The method applies a sequence of L-Gates to each depth and qubit, consisting of phase gates and Hadamard gates.
Input Parameters:
None, uses the class attributes.
Return Value:
Returns the created quantum circuit.
Workflow:
The quantum circuit is initialized based on the specified number of qubits.
The training_phases and activation_phases are validated to ensure they are correctly dimensioned.
The L-Gates are applied for each depth and qubit in three phases:
The phase gates (p-gates) for training and activation.
Hadamard gates between the second and third phases.
After completion, the method returns the finalized quantum circuit.
Method: measure
Purpose:
Measures the quantum circuit either once or repeatedly until every possible state has been measured at least once. There is an option to limit the maximum number of iterations or let the measurement run indefinitely until all states have occurred.
Input Parameters:
c (Optional, Boolean): Specifies whether continuous measurement is performed. If True, the circuit is measured until every state has occurred at least once. By default, it measures only once.
max_iterations (Optional, Integer or 'i'): Specifies the maximum number of measurements when c=True. It can be an integer (maximum number of iterations) or 'i' for infinite (runs until every state has been measured at least once).
Return Value:
A dictionary containing the measured states (bitstrings) and their frequency.
Workflow:
Single Measurement:
If c=False or not provided, the quantum circuit is measured once, and the result is returned as a dictionary.
Continuous Measurement:
If c=True, the circuit is measured repeatedly until each state has occurred at least once or the maximum number of iterations is reached.
The method checks after each measurement which states have been observed and counts their frequencies.
If max_iterations is 'i', the measurement runs indefinitely until all states have occurred.
The result is returned as a dictionary of the observed states and their frequencies.
This class provides the foundation for working with a quantum circuit that uses L-Gates, along with flexible measurement methods.
Class:
Circuit
Purpose:
The
Circuit
class creates a quantum circuit that uses special L-Gates, consisting of training and activation phases. These L-Gates are applied for each depth and each qubit. The class also provides functions to measure the circuit, either once or repeatedly, until every state has been observed at least once.Attributes:
Method:
__init__
Purpose:
Initializes the
Circuit
class with the number of qubits, the circuit's depth, and the training and activation phases for the L-Gates.Input Parameters:
Workflow:
circuit
) is initialized asNone
to be later created in thecreate
method.Method:
create
Purpose:
Creates the quantum circuit with L-Gates based on the provided training and activation phases. The method applies a sequence of L-Gates to each depth and qubit, consisting of phase gates and Hadamard gates.
Input Parameters:
None, uses the class attributes.
Return Value:
Workflow:
training_phases
andactivation_phases
are validated to ensure they are correctly dimensioned.p
-gates) for training and activation.Method:
measure
Purpose:
Measures the quantum circuit either once or repeatedly until every possible state has been measured at least once. There is an option to limit the maximum number of iterations or let the measurement run indefinitely until all states have occurred.
Input Parameters:
True
, the circuit is measured until every state has occurred at least once. By default, it measures only once.'i'
): Specifies the maximum number of measurements whenc=True
. It can be an integer (maximum number of iterations) or'i'
for infinite (runs until every state has been measured at least once).Return Value:
Workflow:
Single Measurement:
c=False
or not provided, the quantum circuit is measured once, and the result is returned as a dictionary.Continuous Measurement:
c=True
, the circuit is measured repeatedly until each state has occurred at least once or the maximum number of iterations is reached.max_iterations
is'i'
, the measurement runs indefinitely until all states have occurred.The result is returned as a dictionary of the observed states and their frequencies.
This class provides the foundation for working with a quantum circuit that uses L-Gates, along with flexible measurement methods.