Data Embedding techniques

Quantum Data Embedding Patterns for Quantum AI/ML algorithms #2

Shafi
8 min readFeb 13, 2022

How embedding patterns works to make Quantum Statevector

This article is sequence to Quantum Data and its Embeddings #1 article.

In this article, we discuss various quantum embedding algorithms in mathematical perspective. Quantum Encoding allows us to understand the data and mapping into qubits so that entangling exist in the Quantum data. In Quantum algorithms (or QML algorithms), preprocessing the data is essential in order to understand the data by Quantum computer in the form of Qubits.

In preprocessing there are two basic programming tasks: reading and loading data [1].

Loading Data

It is in the preprocessing step and the beginning of any Quantum algorithm. In loading process, the data is in the form of Qubits using any encoding or embedding algorithm. Quantum Algorithms expects certain encoding is used and preprocess the data by performing computations.

Loading the data might causes worst and best performance in the space and time complexity and it is not always be done efficiently. In the worst case, loading process requires exponential time and it causes to overall runtime is also exponential. To avoid this difficulty we use logarithmic or linear runtime.

Reading Data

Reading data from qubit, means its quantum state must be accessed programmatically and which is done by measuring Qubit. Measuring the qubit means collapsing to either state |0> and |1>.

Let us outline some of the important concepts and you can find QC concepts in this article.

Qubit It is a bit in QC and storing the information in one of the two basis states i.e., |0> or |1>. Sometimes it is a combination of two states at the same time is called Superposition of states.

Quantum Register Multiple qubits in a quantum computer can forma qubit register.

Quantum gates are operations on qubits and change quantum states.

Quantum Circuit arranging Quantum gates to perform calculations for the quantum Algorithm.

Encoding Techniques using Machine Learning

These days Machine Learning is the most preferred for any kind of tasks based on mathematical formulations. Machine Learning combining with Neural Network to achieve very effectively and accurately. Encoding process can be done using Neural Networks i.e., in Quantum world it is Quantum Neural Network.

Quantum Circuit designing and implementation in the form of Quantum Neural Network (QNN). QNN is the basic formulation for encoding, preprocessing, formatting, training, and prediction of results for Machine Learning algorithms.

Minimal circuit designing in Quantum computer is the challenging and most research field. This paper[6] explores about minimizing circuit design using deep reinforcement learning. The below diagram explores how AI/ML models integrate in Quantum Circuits.

Describing preprocessing in the Quantum Neural Network Circuit

Quantum embedding algorithms can be classified as Quantum State Preparations, and Unitary Transformations.

Quantum circuit for the state preparation and transformation. The below diagram describe follows this.

Source from Research Paper [4]

In this article, we discuss only Quantum state preparation encoding techniques mainly Basis encoding, Amplitude encoding, Angle encoding, QuAM encoding, and QRAM encoding. There are other encoding techniques present that will be discussed in the second part of this article.

Quantum State Preparation (QSP)

This routine, prepares the data using one of the data encoding patterns. QSP operates on a register of qubits and change the states either superposition or entanglement (properties of Quantum nature). In Superposition, all possible outcomes of the quantum register are equally likely.

In state preparation initially all qubits are initialized to |0>, so the overall quantum states can be denoted as |000…0>.

Once the state is prepared, the data is loaded into quantum computer. Quantum computer perform computations on the quantum register using unitary transformations and transformations represented as Quantum Gates.

An encoding can be defined as “loading” data points from memory into quantum states so that it can be processed Quantum Neural Networks.

The loading is accomplished by an encoding from the Input data points to n-qubit Quantum states.

Considerations for Data encoding patterns

Data encoding patterns is essentially a trade-off between three major points

  1. The number of qubits should be minimal to encode — due to the current devices contain a limited number of qubits.
  2. The number of parallel operations should be minimal in order to minimize the width of the quantum circuit.
  3. Data should be in a suitable manner or format — well suited for operations ex: arithmetic operations

Let us define few terms before starting Encoding techniques. Encoding uses these concepts in patterns.

Qubit Register

Multiple qubits can form a qubit register whose state is represented by a vector in a high dimensional complex vector space. Mathematically defining an n-qubit register is as follows:

Input data point

Data point is the actual input to the encoding algorithm and encoding patterns accept these in the form of Quantum Register. Quantum Register (set of qubits) describes the Quantum state.

State vector

Quantum states expressed using Quantum state vector.

Encoding Patterns

Basis Encoding

This encoding is primarily good for arithmetic operations. Basis states are represented as state vectors in Quantum Computing.

Image source from [6]

It is formulated as follows:

Every binary string has a unique integer representation i.e.,

It is illustrated as every input number ‘x’ is formulated into binary format and turned into the corresponding basis vector. i.e.,

How many Qubits required by Basis encoding?

It is required O(n) qubits.

Amplitude Encoding

Image source from [6]

It is also known as Wavefunction Encoding. Every quantum system is best described through its wavefunction which also defines the measurement probabilities. It is useful when quantum state vector do not require further calculations. It is formulated as follows:

The above formula can be modified if it is assumed that inputs are normalized as to 1 i.e.,

formula becomes

How many qubits required for Amplitude encoding?

This patterns requires log n qubits to encode the data into quantum state. O(log n) in the best case.

Angle Encoding

Image source from [6]

In this encoding technique each data point represented by a separate qubit. It is also known as Qubit Encoding. The result of this pattern is qubits are not entangled.

It has variants like General Qubit Encoding and Dense Angle Encoding.

For one qubit can handle one data point with many features as

another strategy encodes one feature per qubit and state preparation unitary is

Dense encoding derives from here by extending the above formula for two features by exploiting the relative phase degree of freedom, it can be defined is as follows:

How many Qubits required for Angle encoding?

O(1) required for each data point.

Dense Angle Encoding

The feature vector x, the dense angle encoding maps as

in the same the above can be defined for two features or two-dimensional data with a single qubit formulated as with features x1, x2

and the density matrix is

General Qubit Encoding

Given a feature vector ‘x’ with N features, and general qubit encoding defines as

QuAM Encoding (Quantum Associative memory)

Image source from [6]

The main intuition of this pattern is to prepare a superposition of basis encoded values in the same qubit register. Quantum register serves equally weighted superposition of the basis encoded values among the Qubits in register.

QuAM uses the following encoding formula

QuAM encoding formula

Let us consider an example of 3 data points are encoded using basis encoding and finally create a superposition of these 3 data points in a qubit register.

How many qubits are needed for QuAM encoding?

‘l’ qubits are required to represent , ‘l’ can be represented as number digits to represent ‘n’ numbers. It is O(‘l’) qubits required. In the above example totally 3 qubits required.

QRAM Encoding

Image source from [6]

The specialty of QRAM to access a superposition of data values at once. It is well suited to use the data values of the input. It takes the address and give the data value of the corresponding data value. It takes the address in the form of register and given the data in the form of register.

QRAM encoding using the following formula to encode the data into quantum state vector.

The below examples illustrates the QRAM encoding.

The above formula can be described as taking address register which contains superposition of all m addresses to be loaded in QRAM and second register the output of the register specifies the address of the i-th data value to loaded in the register is the data value associated with the address.

How many qubits are needed for QRAM encoding?

QRAM requires log n +l qubits to encode the data. O(log n +l ) qubits.

Conclusion

Data encoding techniques are most important in order to preprocess the data, deciding number of qubits, quantum data, designing quantum circuits and efficient execution of Quantum algorithms. This article helps to understand the internal stuff of encoding algorithms in a mathematical perspective.

Thanks for reading my article. Give a clap if it helps you. Give your valuable feedback, comments and Share.

References

  1. Data Encoding Patterns for Quantum Computing -https://hillside.net/plop/2020/papers/weigold.pdf
  2. Robust data encodings for quantum classifiers — https://arxiv.org/abs/2003.01695
  3. Quantum Random Access Memory (QRAM) — https://arxiv.org/pdf/0708.1879.pdf
  4. Expanding Data Encoding Patterns For Quantum Algorithms — https://www.iaas.uni-stuttgart.de/publications/Weigold2021_ExpandingDataEncodingPatterns.pdf
  5. Quantum circuit optimization with deep reinforcement learning- https://arxiv.org/abs/2103.07585
  6. https://quantumcomputingpatterns.org/

🟠 Become a Writer at MLearning.ai

--

--

Shafi

Researcher & Enthusiast in AI, Quantum Computing, and Astrophysics.