Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
44 views

Programming Quantum Computers

This document discusses programming quantum computers. It begins by explaining why learning quantum programming is important, as quantum technology promises to solve hard computing problems faster than classical computers. It then covers some prerequisites in linear algebra needed for quantum programming, including vectors, matrices, tensors, and eigenvectors. The document explains key quantum concepts like superposition, qubits, qubit basis states, operations on qubits, quantum gates, multi-qubit states, and entanglement. It concludes by discussing how quantum logic gates represent operations on qubits through unitary matrices.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Programming Quantum Computers

This document discusses programming quantum computers. It begins by explaining why learning quantum programming is important, as quantum technology promises to solve hard computing problems faster than classical computers. It then covers some prerequisites in linear algebra needed for quantum programming, including vectors, matrices, tensors, and eigenvectors. The document explains key quantum concepts like superposition, qubits, qubit basis states, operations on qubits, quantum gates, multi-qubit states, and entanglement. It concludes by discussing how quantum logic gates represent operations on qubits through unitary matrices.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Programming Quantum

Computers

Prof. Balwinder Singh Sodhi


Dept of Computer Science and Engineering,
IIT Ropar
Credits/acknowledgement

● Some of the slides have content adapted from following


publicly available documents:
○ https://en.wikipedia.org/wiki/Quantum_information_scien
ce

○ https://docs.microsoft.com/en-us/quantum

○ https://quantumexperience.ng.bluemix.net/qx/user-guide

○ http://pyquil.readthedocs.io/en/latest/

○ https://www.quantiki.org

2
Why learn quantum programming?

● Technology that promises to solve hard computing


problems
○ Quantum supremacy: Speedups over the best known
classical algorithms
● Still in its infancy, but quickly evolving
○ Opportunities for early adopters
● Quantum programming is a distinct art from classical
programming
○ Requires very different tools to understand and express
quantum algorithmic thinking

3
Major player in quantum computing

https://docs.microsoft.com/en-us/quantum

https://quantumexperience.ng.bluemix.net/qx/experience

https://www.dwavesys.com/

https://www.rigetti.com/forest

4
Few prerequisites in maths

● A vector v of dimension n is a collection of n complex


numbers (v1, v2, … vn) arranged as a column

● Norm of the vector v is:


● A unit vector has norm 1
● Adjoint of vector v is denoted as v☨ and is defined as:
Here * denotes
complex conjugate

5
Vectors

● Two vectors multiply via the inner or dot product


○ express one vector as a sum of other simpler vectors
● The inner product between u and v, denoted ⟨u,v⟩ is
defined as: ⟨u,v⟩ =u†v = u∗1v1+⋯+u∗nvn.

6
Matrices and tensors

● A matrix of size m×n is a collection of mn complex


numbers arranged in m rows and n columns as shown
below:
● Matrix M of dimension m×n and
N of dimension n×p multiply
to give m×p matrix P: Pik=∑jMijNjk

7
Tensor product

● Tensor product of two matrices Mm×n and Np×q is a larger


matrix P=M⊗N of size mp×nq, and is obtained from M
and N as follows:

8
Tensor product examples

9
A convention about notation

For a vector v or matrix M, v⊗n or M⊗n is shorthand for an


n-fold repeated tensor product

10
Eigenvalues and Eigenvectors

● Let M be a square matrix and v be a vector that is not


having all entries equal to 0.
● We say v is an eigenvector of M if:
Mv = cv for some number c
● In that case, c is the eigenvalue corresponding to the
eigenvector v.
● In general a matrix M may transform a vector into any
other vector, but an eigenvector is special because it is
left unchanged except for being multiplied by a
number.
11
Unitary matrix

A complex square matrix U is unitary if its conjugate


transpose U* is also its inverse.
That is, if:

U*U = UU* = I, U*U = UU* = I,

where I is the identity matrix

● Given two complex vectors x and y, multiplication by U


preserves their inner product; that is, ⟨Ux, Uy⟩ = ⟨x, y⟩.

12
Wave-particle-quantum

13
Quantum superposition

14
Classical bits

● Bits (0 and 1) are fundamental objects of information


on classical computer
● At any given time
○ A single bit can be either 0 or 1
○ N bits taken together can be in only one of 2N states
● Classical CPU processes information using basic digital
circuits:
○ Logic gates such as AND, OR, NOT, NAND etc.
○ Flip-flops or latches for storing information

15
Qubits and their basis states
● A qubit or quantum bit or qbit is the fundamental object
of information on a quantum computer
● One qubit can represent following values:
○ One of the two basis states (Something corresponding to one
classical bit i.e. 1 or 0)
○ A quantum superposition of the two basis states
● The two states in which a qubit may be measured are
known as basis states (or basis vectors)
Dirac or
“Bra-Ket”
notation

“Ket 0” “Ket 1”

16
Qubit system

● It is a two-dimensional complex vector space, and


● State of a qubit is a complex vector in that space
● A pure qubit can be represented as a superposition (i.e.
linear combination) of basis states |0⟩ and |1⟩

|ψ⟩ = α|0⟩ + β|1⟩, such that |α|2 + |β|2 = 1


○ |β|2 is the probability of finding the qubit in |1⟩

○ |α|2 is the probability of finding the qubit in |0⟩

● Any two-dimensional column vector of real or complex


numbers with norm 1 represents a possible quantum
state held by a qubit

17
Representation of qubit vectors

Where, 0 ≤ θ ≤ π
0 ≤ Φ ≤ 2π

18
Examples of valid qubit superposition

Basis states
● Any quantum state vector can be written as a sum of
these basis vectors

● Two basis quantum states correspond to classical bits 0


and 1, normally as:

19
Operations on qubit states

● “Measuring” the state of a qubit Ψ=


○ “Collapses” the qubit to one of the classical states
○ Measuring a qubit ψ gives 0 with probability |α|2 and 1 with
probability |β|2 , s.t |α|2+|β|2 = 1
● “Transforming” a qubit state by applying quantum gate
○ Quantum gates can emulate any rotation of the quantum
state vector
○ Mathematically speaking, the qubit undergoes a unitary
transformation
■ Unitary transformation preserves the inner product of two vectors

20
Quantum gates

● Mathematically, are matrices with two properties


○ Operations that they represent are reversible
○ When applied to a state vector on the Bloch sphere, the
resulting vector is also on the Bloch sphere
● Matrices that satisfy these two properties are called
unitary matrices
● Applying a gate to a quantum state is the same as
multiplying a vector by one of these matrices

21
Multi-qubits states

● Qubit base states can also be combined


○ 2 qubits have the following base states

● Basis for two-qubit states is formed by the tensor


products of one-qubit states

22
Entangled states

● Not all two-qubit quantum states can be written as the


tensor product of two single-qubit states
○ E.g. there are no states ψ and ϕ such that their tensor product
is the state ψ ⊗ ϕ as expressed below:

● Such two qubits are said


to be entangled

23
Entanglement implications

● The information that an entangled 2 qubit state holds is


not confined to either of the qubits individually
● Rather, the information is stored non-locally in the
correlations between the states of two qubits
● This non-locality of information is one of the major
distinguishing features of quantum computing

Related interesting reading:

○ https://en.wikipedia.org/wiki/Bell_state
○ https://en.wikipedia.org/wiki/EPR_paradox
24
Simple description of entanglement

“two systems that appear too far apart to influence


each other can nevertheless behave in ways that,
though individually random, are too strongly
correlated to be described by any classical local
theory”

25
Example of entangled state

● Bell state, denoted as:


○ Subscript A means qubit held by Alice and B held by Bob
● Qubit held by Alice can be 0 as well as 1
● If Alice measured her qubit in the standard basis
○ the outcome would be perfectly random
○ either possibility |0⟩ and |1⟩ having probability ½
● Now if Bob measured his qubit, due to entanglement of
qubits, outcome will be same as Alice’s
● So, individually Alice and Bob see random outcomes but
seen together outcomes are correlated
26
Quantum logic gates

● Represented by unitary matrices


● Operate on spaces of one or two qubits
○ Just like classical logic gates operate on one or two bits
● Can be described by 2n x 2n sized unitary matrices,
where n is the number of qubits that the gate act on
● Act upon variables that are vectors of 2n complex
dimensions
○ n is the number of qubits of the variable
○ Measurement outcomes are the base vectors, and a quantum
state is a linear combination of these outcomes

27
Quantum logic gates

● The number of qubits in the input and output of the


gate have to be equal
● To find the action of a gate on a specific quantum state:
○ Multiply the vector which represents the state by the matrix
representing the gate

28
Grover’s algorithm

● Typically described as “database/list search” algorithm


○ Finds an item in a given list/database
● If we have a function y = f(x) that can be evaluated on a
quantum computer, Grover's algorithm allows us to
calculate x when given y
● Finds with high probability the unique input to a
function that produces a given output value
○ Uses just O(√N) evaluations of the function, where N is the
size of the function's domain
● It was devised by Lov Grover in 1996.
29
Algorithm outline

1. Choose suitable encoding of list for representing it in


qubits
2. Initialize the qubits to a uniform superposition |s⟩ over
all qubit states
3. Perform the following "Grover iteration" r(N) times. The
function r(N) is O(N1/2)
a. Apply the operator Uf (Described shortly)
b. Apply the operator Us
4. Perform the measurement on qubits state

30
Providing input list to the quantum computer

● Consider an unsorted list with N entries.


● Encode the list in terms of a function f such that:
○ f(x)=1 for the searched item and 0 for the rest
● Choose a binary encoding of items x,w ∈ {0,1}n s.t N=2n
○ Can be represented by n = log2 N qubits.
● Define the oracle matrix Uf to act on any of the simple,
standard basis states |x⟩ by Uf|x⟩=(−1)f(x)|x⟩
○ It maps Uf|w⟩ to −|w⟩
○ A reflection about origin for the marked item in an N=2n
dimensional vector space.

31
Amplitude amplification

● Initially, location of target item w is unknown


○ Any guess of its location is as good as any other
○ Can be expressed in terms of a quantum state called a
uniform superposition:
● Chances of guessing the right value w is 1 in 2n
● On average we need to try ~ N=2n times to guess the
correct item
● Amplitude amplification trick is used to enhance this
probability

32
STEP-1 :: Initialize system state

● At t=0 the initial state is |ψ0⟩ = |s⟩


○ |s⟩ is uniform superposition state made from |s⟩ = H⊗n|0⟩n

Amplitudes of the state |ψt⟩


for the case N=22=4
Two-dimensional plane Dotted line shows average
spanned by |w⟩, |s⟩

33
STEP 2 :: Grover iteration step-a
● Apply the oracle reflection Uf to the state |ψt⟩ giving
|ψt′⟩ = Uf|ψt⟩
● Corresponds to a reflection of the state |ψt⟩ about −|w⟩
○ It means that amplitude in front of |w⟩ becomes negative,
which implies that average amplitude has been lowered

34
STEP 2 :: Grover iteration step-b

● Apply an additional reflection Us about the state |s⟩


where Us=2 |s⟩⟨s| −

35
STEP 2 :: Grover iteration step-b

● This transformation maps the state to Us|ψt′⟩ and


completes the transformation |ψt+1⟩ = UsUf|ψt⟩
● Transformation UsUf rotates the initial state |s⟩ closer
towards the winner |w⟩
○ Reflection Us => A reflection about the average amplitude
● Boosts the negative amplitude of |w⟩ to roughly 3x its
original value
○ Because average amplitude was lowered by 1st reflection

36
STEP 2 :: Grover iteration step-b

● After t steps the state will have transformed to:


|ψt⟩ = (UsUf)t|ψ0⟩
● Amplitude of |w⟩ grows linearly with the number of
applications ∼tN−1/2
● Thus roughly N1/2 rotations suffice

37

You might also like