LILY-QML / LLY-DML

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.
https://www.lilyqml.de
2 stars 5 forks source link

Circuit - DML #17

Closed xleonplayz closed 3 weeks ago

xleonplayz commented 2 months ago

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:


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:

  1. The quantum circuit is initialized based on the specified number of qubits.
  2. The training_phases and activation_phases are validated to ensure they are correctly dimensioned.
  3. 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.
  4. 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:

Return Value:

Workflow:

  1. Single Measurement:

    • If c=False or not provided, the quantum circuit is measured once, and the result is returned as a dictionary.
  2. 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.
  3. 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.