data_loading

This module contains all the functions for creating quantum circuits that allow loading input data (as numpy arrays) into the amplitude of a quantum state. Two different implementations can be used:

brute force based

Original implementation based on the following paper: Grover, Lov and Rudolph, Terry. Creating superposition that correspond to efficiently integrable probability distributions. arXiv (2002). https://arxiv.org/abs/quant-ph/0208112

multiplexors based

The mandatory controlled rotations by state are implementd using (a non-recursive version of) the quantum Multiplexors proposed in: V.V. Shende, S.S. Bullock, and I.L. Markov. Synthesis of quantum-logic circuits. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, 25(6):1000ÔÇô1010, Jun 2006 arXiv:quant-ph/0406176v5

Authors: Alberto Pedro Manzano Herrero & Gonzalo Ferro

QQuantLib.DL.data_loading.load_angle(number_qubits: int, index: int, angle: float)

Creates an QLM Abstract Gate that apply a rotation of a given angle into a auxiliary qubit controlled by a given state of the measurement basis. Direct QLM multi controlled rotations were used for the implementation.

Notes

\[|\Psi\rangle = \sum_{j=0}^{2^n-1}\alpha_j|j\rangle\otimes|0\rangle\]
\[\mathcal{load\_angle}(\theta, |i\rangle)|\Psi\rangle \ =\sum_{j=0, j\ne i}^{2^n-1}\alpha_j|j\rangle\otimes|0\rangle+ \ \alpha_i|i\rangle\otimes\big(\cos(\theta)|0\rangle+\sin(\theta) \ |1\rangle\big)\]
Parameters:
  • number_qubits (int) – Number of qubits for the control register. The arity of the gate is number_qubits+1.

  • index (int) – Index of the state that we control.

  • angle (float) – Angle that we load.

QQuantLib.DL.data_loading.load_angles(angles: numpy.array, method: str = 'multiplexor')

This function serves as an interface for the two different implementations of multi controlled rotations: load_angles_brute_force and multiplexor_RY.

Notes

\[|\Psi\rangle = \sum_{j=0}^{2^n-1}\alpha_j|j\rangle\otimes|0\rangle\]
\[\mathcal{load\_angles}([\theta_j]_{j=0,1,2...2^n-1})|\Psi\rangle \ =\sum_{j=0}^{2^n-1}\alpha_j|j\rangle\otimes \ \big(\cos(\theta_j)|0\rangle+\sin(\theta_j)|1\rangle\big)\]
Parameters:
  • angles (numpy array) – Angles to load in the circuit. The arity of the gate is: int(np.log2(len(angle)))+1.

  • method (string) – Method used in the loading. Default method.

QQuantLib.DL.data_loading.load_angles_brute_force(angles: numpy.array)

Given a list of angles this function creates a QLM routine that applies rotations of each angle of the list, over an auxiliary qubit, controlled by the different states of the measurement basis. Direct QLM multi controlled rotations were used for the implementation.

Notes

\[|\Psi\rangle = \sum_{j=0}^{2^n-1}\alpha_j|j\rangle\otimes|0\rangle\]
\[\mathcal{load\_angles\_brute\_force} \ ([\theta_j]_{j=0,1,2...2^n-1}) |\Psi\rangle=\sum_{j=0}^{2^n-1} \ \alpha_j|j\rangle\otimes\big(\cos(\theta_j)|0\rangle+ \ \sin(\theta_j)|1\rangle\big)\]
Parameters:

angles (numpy array) – Angles to load in the circuit. The arity of the gate is: int(np.log2(len(angle)))+1.

QQuantLib.DL.data_loading.load_array(function_array: numpy.array, method: str = 'multiplexor', id_name: str | None = None)

Creates a QLM AbstractGate for loading a normalised array into a quantum state.

Parameters:
  • function_array (numpy array) – Numpy array with the normalised array to load. The arity of of the gate is int(np.log2(len(probability_array)))+1.

  • method (str) –

    type of loading method used:

    multiplexor : with quantum Multiplexors brute_force : using multicontrolled rotations by state

  • id_name (str) – name for the Abstract Gate

Returns:

f_gate – AbstractGate customized for loading a normalised array

Return type:

AbstractGate

QQuantLib.DL.data_loading.load_pf(p_gate, f_gate)

Create a QLM AbstractGate for applying two given operators consecutively. The operator to implement is: p_gate*f_gate

Parameters:
  • p_gate (QLM AbstractGate) – Customized AbstractGate for loading probability distribution.

  • f_gate (QLM AbstractGate) – Customized AbstractGatel for loading integral of a function f(x)

Returns:

pf_gate

Return type:

AbstractGate

QQuantLib.DL.data_loading.load_probability(probability_array: numpy.array, method: str = 'multiplexor', id_name: str | None = None)

Creates a QLM Abstract gate for loading a given discretized probability distribution using Quantum Multiplexors.

Parameters:
  • probability_array (numpy array) – Numpy array with the discretized probability to load. The arity of of the gate is int(np.log2(len(probability_array))).

  • method (str) –

    type of loading method used:

    multiplexor : with quantum Multiplexors brute_force : using multicontrolled rotations by state

  • id_name (str) – name for the Abstract Gate

Returns:

P_Gate – Customized Abstract Gate for Loading Probability array using Quantum Multiplexors

Return type:

AbstractGate

QQuantLib.DL.data_loading.multiplexor_ry(angles: numpy.array, ordering: str = 'sequency')

Given a list of angles this functions creates a QLM routine that applies rotations of each angle of the list, over an auxiliary qubit, controlled by the different states of the measurement basis. The multi-controlled rotations were implemented using Quantum Multiplexors.

Notes

\[|\Psi\rangle = \sum_{j=0}^{2^n-1}\alpha_j|j\rangle\otimes|0\rangle\]
\[\mathcal{multiplexor\_RY} \ ([\theta_j]_{j=0,1,2...2^n-1})|\Psi\rangle = \sum_{j=0}^{2^n-1} \ \alpha_j|j\rangle\otimes\big(\cos(\theta_j)|0\rangle+\sin(\theta_j)|1\rangle\big)\]
Parameters:

angles (numpy array) –

Angles to load in the circuit. The arity of the gate is:

int(np.log2(len(angle)))+1.

QQuantLib.DL.data_loading.step_array(index: int, size: int)

Creates are routine which loads an array of size “size”. This array has ones up to but not included the index position. The rest of the values are zero. This is why it is called step_array.

Parameters:
  • index (int) – position where the step is produced

  • size (int) – size of the array. It has to be a power of 2

Returns:

step_function_gate – gate which loads the corresponding array. Note that the arity is: np.log2(size)+1

Return type:

Abstract Gate

QQuantLib.DL.data_loading.uniform_distribution(number_qubits: int)

Function to load a uniform distribution in a quantum circuit.

Notes

\[\mathcal{H}^{\otimes n}|\Psi\rangle\]
Parameters:

number_qubits (int) – Arity of the output gate.