layout: true
--- class: title-slide, center, middle
--- # Motivation .darkblue[Design Patterns] .reference[Software Design Pattern:
Panel
Book
Web
Web
Quantum Patterns:
Paper
ArXiv
Web
Hybrid Quantum:
Paper
Preprint
] .more-more-condensed[ - .darkblue[Software design patterns] - .darkblue[structured document containing a]n abstract .darkblue[description of a] proven .darkblue[solution of a recurring problem] - .darkblue[refers to other patterns] that may jointly contribute to an encompassing solution of a complex problem
.darkblue[$\Rightarrow$] network of related patterns, i.e. a .darkblue[pattern language] - .darkblue[.bold[Example:] Singleton], Definition:
Link 1
Link 2
-
creational design pattern
that lets you ensure
that a class has only one instance
, while providing a global access point to this instance - .darkblue[.bold[Solution]] - Make the .darkblue[default constructor private], to prevent other objects from using the new operator with the Singleton class - Create a .darkblue[static creation method that acts as] a .darkblue[constructor]. Under the hood, this method calls the private constructor to create an object and saves it in a static field. All following calls to this method return the cached object. - .darkblue[Quantum Patterns] - .darkblue[Design patterns using quantum algorithms] ] --- # .darkblue[Pattern Format] .reference[Software Design Pattern:
Panel
Book
Web
Web
Quantum Patterns:
Paper
ArXiv
Web
] .more-more-condensed[ - .darkblue[differs depending on the domain] - .darkblue[Format] example: - .darkblue[Name and icon] that serves as a graphical representation of the pattern - .darkblue[Intent] that briefly summarizes the purpose of the pattern - .darkblue[Alias]: other used names of the pattern - .darkblue[Context]: problem and the circumstances of the pattern - .darkblue[Forces]: trade-offs or considerations that must be taken into account for solving the problem - .darkblue[Solution]: description in an abstract manner and often visualized by a solution sketch - .darkblue[Result]: consequences of the solution - optional section for .darkblue[variants] of the pattern - .darkblue[Related patterns]: Connections between patterns, as patterns are often applied in combination or solve similar problems - .darkblue[Known uses] of the pattern in quantum algorithms and concrete implementations ] --- # .darkblue[Typical Structure of] a .darkblue[Quantum Calculation] .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
] .more-more-condensed[ - Typical .darkblue[phases of quantum calculations]: ]
.more-more-condensed[ - .darkblue.bold[How to prepare the states for data loading?] ] --- #
.darkblue[Initialization aka State Preparation] 1/2 .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
] .more-more-condensed[ - .darkblue[Intent] - .darkblue[Initialize the input of a quantum register], taking into account the prerequisites of the subsequent steps of the algorithm - .darkblue[Context] - .darkblue[Specific parameters must be typically given as input data] to a quantum algorithm in order to solve a given problem - .darkblue[The first unitary transformations of a quantum circuit] typically .darkblue[encode] the .darkblue[input data] into the quantum register according to a defined encoding - .darkblue[Solution] - .darkblue[.smaller-font[$\left|0\cdots 0\right\rangle$] and .smaller-font[$\left|0\cdots 01\right\rangle$] are frequently used as initialization] of quantum registers - .darkblue[Some qubits as ancilla bits], which may be used for the storage of intermediate results or quantum error correction - Example - for a function table of a Boolean function $f:\\{0, 1\\}^n \rightarrow \\{0, 1\\}^m$, the overall register is initialized as $\left| 0 \right\rangle^{\otimes n}\left| 0 \right\rangle^{\otimes m}$ (including $m$ ancilla bits) ] --- #
.darkblue[Initialization aka State Preparation] 2/2 .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
1
ArXiv
2
Paper
3
ArXiv
4
ArXiv
] .more-more-condensed[ - .darkblue[Result] - .darkblue[Preparing more advanced states] built on the previously described initialization techniques - .darkblue[Examples of loading into quantum registers] -
Loading classical bits
1
-
Loading of complex vectors
2
-
Loading of real-valued vectors
3
-
Loading of matrices
that are represented as sets of vectors
4
- .darkblue[Related Patterns] -
.darkblue[Uniform superposition]:
- .darkblue[Refinements] of initialization:
- Initialized register may be used to compute a
.darkblue[function table]
.blue-border.round-border.small-font.small-padding[For other patterns we do not present all items...] ] --- # .darkblue[Data Encoding] .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
] .more-more-condensed[ - .darkblue[define how data is represented by the state] of a quantum system - .darkblue[Data encoding patterns] describe a particular encoding .darkblue[as] a .darkblue[trade-off] between: - .darkblue[Minimize \#qubits] needed for the encoding - because
current devices
are of intermediate size and thus only
support a limited \#qubits
- .darkblue[Minimize \#parallel operations] needed to realize the encoding - to
minimize the width
of the quantum circuit - the .darkblue[loading routine is] ideally .darkblue[of constant or logarithmic complexity] - .darkblue[Data must be represented] in a suitable manner .darkblue[for further calculations], e.g., arithmetic operations - .darkblue[Patterns] for Data Encoding:
] --- #
.darkblue[Basis Encoding] .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[LB'20]
[VBE'96]
ArXiv
[CB'18]
] .more-more-condensed[ - .darkblue[Intent] - .darkblue[Represent data in a quantum computer] for performing calculations - .darkblue[Context] - .darkblue[Quantum algorithm requires numerical input data] .small-font[$X$] for further calculations - .darkblue[Solution] - use the .darkblue[computational basis $|0...00\rangle, |0...01\rangle, \ldots, |1...11\rangle$] -
For example:
decimal $2$ in binary format $10$ encoded by $|10\rangle$ -
Classical data: integer number $x := b_{n-1}\ldots b_1 b_0$
with $n$ bits $b_i$ -
Corresponding quantum data: $|x \rangle:=|b_{n-1} \ldots b_1 b_0\rangle$
- .darkblue[Result] - .darkblue[suitable for arithmetic computations] .smaller-font[[LB'20][VBE'96][CB'18]] .darkblue[$\Rightarrow$ digital encoding] - .darkblue[Space requirements: $n$ qubits] - Initial .darkblue[$|0\rangle$ state] of qubits that represent a $1$ bit .darkblue[must be flipped into $|1\rangle$]
.darkblue[$\Rightarrow O(n)$ NOT-gates in parallel $\Rightarrow O(1)$ preparation time] ] --- #
.darkblue[Quantum Associative Memory (QuAM)] .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[LB'20]
[VM'00]
ArXiv
] .more-more-condensed[ - .darkblue[Context] - A quantum algorithm requires .darkblue[multiple numerical values .small-font[$X:=${$x_1,\ldots,x_k$}]] as input for further calculations. - .darkblue[Solution] - Use a .darkblue[quantum associative memory (QuAM)] [VM'00] .darkblue[to prepare a superposition of basis encoded values in the same qubit register] [LB'20]
.darkblue[$\Rightarrow$] quantum register is an .darkblue[equally weighted superposition .small-font[$\frac{1}{\sqrt{k}}\sum_{i=1}^k |x_i\rangle$] of all basis encoded values .small-font[$|x_1\rangle,\ldots,|x_k\rangle$]]
.small-font[.darkblue[Basic steps] .smaller-font[[VM'00] (using modified parts of Grover)].darkblue[:].smaller-font[
.darkblue[(1) Additional element is prepared] in both branches.
.darkblue[(2)] Processing branch is split in such a manner, that the new .darkblue[element gets a proper amplitude] such that
(3) it can be brought .darkblue[into superposition with the already added elements].
.darkblue[(4) Uncompute cleans for the next iteration].]]
] --- #
.darkblue[Quantum Associative Memory (QuAM)] .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[LB'20]
[VM'00]
ArXiv
[SP'18]
] .more-more-condensed[ - .darkblue[Result] - .darkblue[digital encoding and] therefore .darkblue[suitable for arithmetic computations] [LB'20] - .darkblue[Space:] For $k$ input numbers each with $n$ bits, .darkblue[$n$ qubits] are needed - Each of encoded input values is represented by a basis vector with an amplitude of $\frac{1}{\sqrt{k}}$ and all other amplitudes of the register are $0$
$\Rightarrow$ The .darkblue[amplitude vector] therefore .darkblue[often sparse] [SP'18] - .darkblue[Preparation time depends on number $k$] of input numbers ] --- #
.darkblue[Angle Encoding] 1/3 .reference[Data Encoding:
[WBLS'21]
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[LB'20]
[LC'20]
ArXiv
] .more-more-condensed[ - .darkblue[Intent] - "Represent each data point by a separate qubit" [WBLS'21] - .darkblue[Alias] - .darkblue[Qubit Encoding]: since each qubit represents a single data point [LC'20] - .darkblue[(Tensor) Product Encoding]: since the resulting encoding of this pattern is not entangled [LB'20] - .darkblue[Context] - .darkblue[Encoding is efficient in terms of operations to perform] more operations .darkblue[within the decoherence time of] noisy intermediate-scale quantum computers (.darkblue[NISQ]) after encoding the data ] --- #
.darkblue[Angle Encoding] 2/3 .reference[Data Encoding:
[WBLS'21]
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[LB'20]
[LC'20]
ArXiv
] .more-more-condensed[ - .darkblue[Solution] [LB'20]
Each data point of the .darkblue[input is normalized to the interval $[0,\frac{\pi}{2}]$]
.darkblue[Encoding] the data points .darkblue[by rotating around the y-axis] with an angle depending on the value of the normalized data point
] --- #
.darkblue[Angle Encoding] 3/3 .reference[Data Encoding:
[WBLS'21]
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[LB'20]
[LC'20]
ArXiv
[G+'18]
] .more-more-condensed[ - .darkblue[Result] - .darkblue[Space requirements: $n+1$ qubits for $n+1$ data points] - Initial .darkblue[$|0\rangle$ state] of qubits that represent a $1$ data point .darkblue[must be rotated according to data point]
.darkblue[$\Rightarrow O(n)$ Rotation-gates in parallel $\Rightarrow O(1)$ preparation time] - .darkblue[Variants] - [LC'20] proposes to .darkblue[exploit the relative phase for a more dense encoding which requires only half of the qubits] for the same amount of data points - .darkblue[Known Uses] - .darkblue[Classification algorithms] [LC'20,G+'18] based on angle encoding - .darkblue[Quantum image processing]
[YIV'15]
: angle encoding for a pixel's color information in the flexible representation of quantum image (FRQI) and an additional register for the position - In .darkblue[quantum neural networks]
[SSP14]
quantum neurons (quron) use angle encoding ] --- #
.darkblue[Amplitude Encoding] .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[LC'20]
ArXiv
] .more-more-condensed[ - .darkblue[Intent] - Encode .darkblue[data in a compact manner that do not require calculations] - .darkblue[Alias] - .darkblue[Wavefunction Encoding] [LC'20] - Every quantum system is described by its wavefunction $\psi$ defining also the measurement probabilities
$\Rightarrow$ amplitudes of the quantum system represent data values - .darkblue[Context] - Encoding of a .darkblue[numerical input data vector $(x_0,...,x_n)^T$] for a quantum algorithm. ] --- #
.darkblue[Amplitude Encoding] .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[LC'20]
ArXiv
] .more-more-condensed[ - .darkblue[Solution] - .darkblue[Encoding of the input vector in the amplitudes] of the quantum state: .darkblue[$|\psi\rangle=\sum_{i=0}^n x_i|i\rangle$] - Squared moduli of the amplitudes of a quantum state must sum up to 1
$\Rightarrow$
input vector needs to be normalized to length 1
- Vector space of an $n$ qubit register has dimension $2^n$
$\Rightarrow$
input vector can be padded with additional zeros if dimension is not a power of 2
- Amplitudes depend on the data $\Rightarrow$
process of encoding the data
(but not the encoding itself)
is often referred to as
arbitrary state preparation
] --- #
.darkblue[Amplitude Encoding] .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[LC'20]
ArXiv
[SP'18]
] .more-more-condensed[ - .darkblue[Result] - .darkblue[Compact] representation: .darkblue[$\lceil log_2(n+1)\rceil$ qubits] - more compact (in terms of qubits) than Basis, Angle Encoding or Quantum Random Access Memory (QRAM) Encoding - For an arbitrary state represented by .darkblue[$k$ qubits] (i.e., $2^k$ data values), .darkblue[at least $2^k$ parallel operations] for initialization are needed [SP'18] (nearly reached in state-of-the-art approaches) - For special cases logarithmic runtime or $O(1)$ (e.g., Uniform Superposition) - Sparse data vectors can also be prepared more efficiently [SP'18] - Output is also encoded in the amplitude
$\Rightarrow$ .darkblue[Multiple measurements to obtain a good estimate] of the output result
$\Rightarrow$ .darkblue[Number of measurements scales with the number of amplitudes $2^k$] for $k$ qubits [SP'18] ] --- #
.darkblue[Amplitude Encoding] .reference[Data Encoding:
Paper
Preprint
Journal
Web
Source of Icons: QC Patterns
[LC'20]
ArXiv
[HHL'09]
ArXiv
[SFP'17]
ArXiv
] .more-more-condensed[ - .darkblue[Known Uses] - Amplitude Encoding can be used in many .darkblue[quantum machine learning] algorithms [LC'20] - Algorithm of Harrow, Hassidim and Lloyd [HHL'09] (.darkblue[HHL algorithm]) for solving linear equations - .darkblue[Data values are typically normalized in machine learning] [SFP'17], e.g. in support vector machine. - Various ways to construct a state preparation routine for amplitude encoding via e.g. Schmidt Decomposition
[PB'11]
(ArXiv)
[I+16]
(ArXiv)
-
Mathematica
:
[I+'19]
-
Qiskit
:
[SBM'06]
(ArXiv)
QisKit Documentation
-
PennyLane
:
qml.AmplitudeEmbedding
using the algorithm proposed by
[MV'05]
requiring an exponential number of operations to encode $2^k$ data values -
Q#
: approximates the desired amplitude encoding
Q# API reference
] --- #
.darkblue[QRAM Encoding] 1/4 .reference[Data Encoding:
[W+'21]
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[JHG'19]
] .more-more-condensed[ - .darkblue[Intent] - ".darkblue[Use a quantum random access memory to access a superposition of data values at once]" [W+'21] - .darkblue[Context] - Accessing the .darkblue[values of input] data .darkblue[via random access memory] - .darkblue[Solution] - .darkblue[.bold[Classical] random access memory (RAM) transfers the data] value .darkblue[stored at a given address into a specified output] register - .darkblue[.bold[Quantum] random access memory (QRAM)]: similar to RAM, but the .darkblue[registers are] not classical but .darkblue[quantum registers] [JHG'19] - Consequently, .darkblue[address and output registers can be in superposition] instead of classical values ] --- #
.darkblue[QRAM Encoding] 2/4 .reference[Data Encoding:
[W+'21]
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[JHG'19]
[KKP'20]
] .more-more-condensed[
$\sum_a c_a|a\rangle \xrightarrow{\text{QRAM}} \sum_a c_a|a\rangle|D_a\rangle$
with $c_a$ amplitude, $|a\rangle$ address and $|D_a\rangle$ data value of address $|a\rangle$
] --- #
.darkblue[QRAM Encoding] 3/4 .reference[Data Encoding:
[W+'21]
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[JHG'19]
[KKP'20]
[SP'18]
] .more-more-condensed[ - .darkblue[Result] - .darkblue[Data values consuming $n$ bits: $n$ qubits] for basis encoded data - .darkblue[Address] register: .darkblue[additional .small-font[$\lceil log(k) \rceil$ qubits]] for up to .small-font[$k$] addresses - .darkblue[Basis Encoding] is used .darkblue[for data values: computational properties
$\approx$ other digital encodings] (e.g., QuAM and Basis Encoding): - Since
data values
are represented
in superposition
, - .darkblue[data values can be manipulated at once] (using quantum parallelism) - .darkblue[multiple arithmetic operations] (e.g., $+, \cdot$) can be applied - .darkblue[State preparation via the QRAM is efficient and of logarithmic runtime] [SP'18]: QRAM queries .small-font[$N$] adresses in .small-font[$O(log(N))$] [KKP'20] -
Exponential speed-up
of an algorithm using QRAM:
only possible if filling QRAM is efficient
- To our best knowledge, there are currently .darkblue[.bold[no] commercial .bold[hardware] implementations for QRAM] - State preparation routine must be used for loading the QRAM,
but
no
routine for arbitrary input data exists that is as efficient as QRAM
] --- #
.darkblue[QRAM Encoding] 4/4 .reference[Data Encoding:
[W+'21]
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[CB'18]
[P'14]
[MKF'19]
[GLM'08]
] .more-more-condensed[ - .darkblue[Known Uses] - .darkblue[Alternative state preparation] to realize QRAM Encoding can be found in [CB'18] (circuit family #3) or [P'14] - Algorithms for .darkblue[solving semi-definite programs] [MKF'19] use QRAM Encoding. - QRAM is required or assumed .darkblue[in various other algorithms] [GLM'08],
[RML'14]
,
[WKS'14]
,
[LMR'13]
- .darkblue[HHL algorithm for solving linear equations]
[HHL'09]
uses QRAM Encoding as an intermediate representation for eigenvalues [MKF'19] ] --- #
.darkblue[Schmidt Decomposition] .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[OS'18]
] .more-more-condensed[ - .darkblue[Context] - A .darkblue[state $|s\rangle$ has to be prepared] on an empty $n$-qubit register - .darkblue[Forces] - .darkblue[Small depth of] the constructed .darkblue[state preparation circuit] - .darkblue[Runtime for constructing the state preparation circuit on classical computer should not outweigh] the potential benefit of quantum computing - .darkblue[Solution] - Express $|s\rangle$ in terms of two subspaces $V$ and $W$ that span $H^{\otimes n}$ - Choose orthogonal basis
$\\{f_1, …, f_k\\}\in V\wedge \\{g_1, …, g_k\\}\in W$
, such that: - $|s\rangle=\sum b_{ij}\cdot f_i\otimes g_j$ - $M:=\\{b_{ij}\\}$ - Compute the singular value decomposition (SVD) $M=\biggl(U_1 U_2\biggr)\left(\\begin{array}{c} A\\\\ 0 \\end{array}\right)V^*$ of $M$ .darkgray[(see [OS'18] for detailed instructions)] ] --- #
.darkblue[Schmidt Decomposition] .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[OS'18]
[LB'20]
[A+20]
] .more-more-condensed[ - .darkblue[Solution] .darkgray[(continued)] - Entries .small-font[$\\\\{\alpha_1, …,\alpha_m\\\\}$] of the diagonal matrix .small-font[$A$]: Schmidt decomposition - With .small-font[$\alpha_1,…,\alpha_m$] Schmidt coefficients for the Schmidt basis .small-font[$\\\\{u_i\\\\}, \\\\{v_i\\\\}$]:
- Circuit for state preparation [A+20] -
$B$
transforms the amplitude of the first register to the Schmidt coefficients - Copy this state to the second register using CNOT operations - .smaller-font[$U_1$] and .smaller-font[$V$] transform the basis states .smaller-font[$\\\\{e_i\\\\}$] into the Schmidt basis states
Example 1:
$|s\rangle=\frac{|00\rangle+|01\rangle}{\sqrt{2}}$
$B=U_1=I$
$V=H$
Example 2:
$|s\rangle=\frac{\sqrt{2}\cdot|00\rangle+|11\rangle}{\sqrt{3}}$
$B=\frac{1}{\sqrt{3}}\left[\begin{array}{c} \sqrt{2} & 0 \\ 1 & 0 \end{array}\right]$
$U_1=V=I$
- For the execution on a quantum computer, the unitary matrices .smaller-font[$B, U_1, V$] must be further decomposed into one and two qubit gates [LB'20] ] --- #
.darkblue[Schmidt Decomposition] .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
[NC'10]
[PB'11]
ArXiv
[DGK'14]
[I+21]
] .more-more-condensed[ - .darkblue[Result] - The state $|s\rangle$ is created in the register for which the Schmidt coefficients $\alpha_i$ are known, which can be used to quantify entanglement [NC'10] - The .darkblue[state $|s\rangle$ is separable (i.e., not entangled) if and only if exactly one of the Schmidt coefficients is non-zero] - Depth of the circuit is $\frac{23}{48}2^n$ in the worst case [PB'11] -
Arbitrary state preparation is of exponential complexity
in general (in the worst case) - .darkblue[Related Patterns] - Schmidt Decomposition can be used as a state preparation method .darkblue[for Amplitude or QRAM Encoding] - .darkblue[Known Uses] - Schmidt Decomposition can be used to create random states with a controlled amount of entanglement [DGK'14] - Mathematica implementation: [I+21] ] --- # .darkblue[Comparison Data Encoding] Patterns .reference[Data Encoding:
Paper
Preprint
Journal Paper
Web
Source of Icons: QC Patterns
] .more-more-condensed[ - $k$ data points, one data point consumes $n$ bits
Encoding Pattern
Encoding
#Qubits
Prepa-
ration
Digital
Enco-
ding
.darkblue[Basis]
$x_i\approx\sum_i b_i\cdot 2^i$
$\mapsto |x_i \rangle=|b_{n-1} \ldots b_1 b_0\rangle$
$k\cdot n$
$O(1)$
✓
.darkblue[Angle]
$x_i\mapsto cos(x_i)|0\rangle+sin(x_i)|1\rangle$
$k$
$O(1)$
.darkblue[QuAM]
$X\mapsto\frac{1}{\sqrt{k}}\sum_{i=1}^k |x_i\rangle$
$n$
$O(k)$
✓
.darkblue[QRAM]
$X\mapsto\sum_i c_i|i\rangle|x_i\rangle$
$n+\lceil log_2(k)\rceil$
$O(2^k)$ (Schmidt)
✓
.darkblue[Ampli-
tude]
$X\mapsto\sum_{i=0}^{k-1} x_i|i\rangle$
$\lceil log_2(k)\rceil$
$O(2^k)$ (Schmidt)
] --- # .darkblue[Summary & Conclusions] .more-more-condensed[ - Quantum Patterns - Software design patterns using quantum algorithms - In this lecture - Patterns for Data Encoding - State Preparations refined by - Basis Encoding - Quantum Associative Memory (QuAM) - Angle Encoding - Amplitude Encoding - QRAM Encoding - Schmidt Decomposition to be used as basic state preparation method for Amplitude and QRAM Encoding ]